documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081
  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 corrseponding 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. * @returns a BoundingInfo
  24940. */
  24941. getBoundingInfo(): BoundingInfo;
  24942. /**
  24943. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24944. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24945. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24946. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24947. * @returns the current mesh
  24948. */
  24949. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24950. /**
  24951. * Overwrite the current bounding info
  24952. * @param boundingInfo defines the new bounding info
  24953. * @returns the current mesh
  24954. */
  24955. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24956. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24957. readonly useBones: boolean;
  24958. /** @hidden */
  24959. _preActivate(): void;
  24960. /** @hidden */
  24961. _preActivateForIntermediateRendering(renderId: number): void;
  24962. /** @hidden */
  24963. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24964. /** @hidden */
  24965. _postActivate(): void;
  24966. /** @hidden */
  24967. _freeze(): void;
  24968. /** @hidden */
  24969. _unFreeze(): void;
  24970. /**
  24971. * Gets the current world matrix
  24972. * @returns a Matrix
  24973. */
  24974. getWorldMatrix(): Matrix;
  24975. /** @hidden */
  24976. _getWorldMatrixDeterminant(): number;
  24977. /**
  24978. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24979. */
  24980. readonly isAnInstance: boolean;
  24981. /**
  24982. * Perform relative position change from the point of view of behind the front of the mesh.
  24983. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24984. * Supports definition of mesh facing forward or backward
  24985. * @param amountRight defines the distance on the right axis
  24986. * @param amountUp defines the distance on the up axis
  24987. * @param amountForward defines the distance on the forward axis
  24988. * @returns the current mesh
  24989. */
  24990. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24991. /**
  24992. * Calculate relative position change from the point of view of behind the front of the mesh.
  24993. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24994. * Supports definition of mesh facing forward or backward
  24995. * @param amountRight defines the distance on the right axis
  24996. * @param amountUp defines the distance on the up axis
  24997. * @param amountForward defines the distance on the forward axis
  24998. * @returns the new displacement vector
  24999. */
  25000. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25001. /**
  25002. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25003. * Supports definition of mesh facing forward or backward
  25004. * @param flipBack defines the flip
  25005. * @param twirlClockwise defines the twirl
  25006. * @param tiltRight defines the tilt
  25007. * @returns the current mesh
  25008. */
  25009. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25010. /**
  25011. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25012. * Supports definition of mesh facing forward or backward.
  25013. * @param flipBack defines the flip
  25014. * @param twirlClockwise defines the twirl
  25015. * @param tiltRight defines the tilt
  25016. * @returns the new rotation vector
  25017. */
  25018. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25019. /**
  25020. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25021. * This means the mesh underlying bounding box and sphere are recomputed.
  25022. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25023. * @returns the current mesh
  25024. */
  25025. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25026. /** @hidden */
  25027. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25028. /** @hidden */
  25029. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25030. /** @hidden */
  25031. _updateBoundingInfo(): AbstractMesh;
  25032. /** @hidden */
  25033. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25034. /** @hidden */
  25035. protected _afterComputeWorldMatrix(): void;
  25036. /** @hidden */
  25037. readonly _effectiveMesh: AbstractMesh;
  25038. /**
  25039. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25040. * A mesh is in the frustum if its bounding box intersects the frustum
  25041. * @param frustumPlanes defines the frustum to test
  25042. * @returns true if the mesh is in the frustum planes
  25043. */
  25044. isInFrustum(frustumPlanes: Plane[]): boolean;
  25045. /**
  25046. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25047. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25048. * @param frustumPlanes defines the frustum to test
  25049. * @returns true if the mesh is completely in the frustum planes
  25050. */
  25051. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25052. /**
  25053. * True if the mesh intersects another mesh or a SolidParticle object
  25054. * @param mesh defines a target mesh or SolidParticle to test
  25055. * @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)
  25056. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25057. * @returns true if there is an intersection
  25058. */
  25059. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25060. /**
  25061. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25062. * @param point defines the point to test
  25063. * @returns true if there is an intersection
  25064. */
  25065. intersectsPoint(point: Vector3): boolean;
  25066. /**
  25067. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25069. */
  25070. checkCollisions: boolean;
  25071. /**
  25072. * Gets Collider object used to compute collisions (not physics)
  25073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25074. */
  25075. readonly collider: Nullable<Collider>;
  25076. /**
  25077. * Move the mesh using collision engine
  25078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25079. * @param displacement defines the requested displacement vector
  25080. * @returns the current mesh
  25081. */
  25082. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25083. private _onCollisionPositionChange;
  25084. /** @hidden */
  25085. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25086. /** @hidden */
  25087. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25088. /** @hidden */
  25089. _checkCollision(collider: Collider): AbstractMesh;
  25090. /** @hidden */
  25091. _generatePointsArray(): boolean;
  25092. /**
  25093. * Checks if the passed Ray intersects with the mesh
  25094. * @param ray defines the ray to use
  25095. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25097. * @returns the picking info
  25098. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25099. */
  25100. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25101. /**
  25102. * Clones the current mesh
  25103. * @param name defines the mesh name
  25104. * @param newParent defines the new mesh parent
  25105. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25106. * @returns the new mesh
  25107. */
  25108. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25109. /**
  25110. * Disposes all the submeshes of the current meshnp
  25111. * @returns the current mesh
  25112. */
  25113. releaseSubMeshes(): AbstractMesh;
  25114. /**
  25115. * Releases resources associated with this abstract mesh.
  25116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25118. */
  25119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25120. /**
  25121. * Adds the passed mesh as a child to the current mesh
  25122. * @param mesh defines the child mesh
  25123. * @returns the current mesh
  25124. */
  25125. addChild(mesh: AbstractMesh): AbstractMesh;
  25126. /**
  25127. * Removes the passed mesh from the current mesh children list
  25128. * @param mesh defines the child mesh
  25129. * @returns the current mesh
  25130. */
  25131. removeChild(mesh: AbstractMesh): AbstractMesh;
  25132. /** @hidden */
  25133. private _initFacetData;
  25134. /**
  25135. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25136. * This method can be called within the render loop.
  25137. * 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
  25138. * @returns the current mesh
  25139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25140. */
  25141. updateFacetData(): AbstractMesh;
  25142. /**
  25143. * Returns the facetLocalNormals array.
  25144. * The normals are expressed in the mesh local spac
  25145. * @returns an array of Vector3
  25146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25147. */
  25148. getFacetLocalNormals(): Vector3[];
  25149. /**
  25150. * Returns the facetLocalPositions array.
  25151. * The facet positions are expressed in the mesh local space
  25152. * @returns an array of Vector3
  25153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25154. */
  25155. getFacetLocalPositions(): Vector3[];
  25156. /**
  25157. * Returns the facetLocalPartioning array
  25158. * @returns an array of array of numbers
  25159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25160. */
  25161. getFacetLocalPartitioning(): number[][];
  25162. /**
  25163. * Returns the i-th facet position in the world system.
  25164. * This method allocates a new Vector3 per call
  25165. * @param i defines the facet index
  25166. * @returns a new Vector3
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25168. */
  25169. getFacetPosition(i: number): Vector3;
  25170. /**
  25171. * Sets the reference Vector3 with the i-th facet position in the world system
  25172. * @param i defines the facet index
  25173. * @param ref defines the target vector
  25174. * @returns the current mesh
  25175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25176. */
  25177. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25178. /**
  25179. * Returns the i-th facet normal in the world system.
  25180. * This method allocates a new Vector3 per call
  25181. * @param i defines the facet index
  25182. * @returns a new Vector3
  25183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25184. */
  25185. getFacetNormal(i: number): Vector3;
  25186. /**
  25187. * Sets the reference Vector3 with the i-th facet normal in the world system
  25188. * @param i defines the facet index
  25189. * @param ref defines the target vector
  25190. * @returns the current mesh
  25191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25192. */
  25193. getFacetNormalToRef(i: number, ref: Vector3): this;
  25194. /**
  25195. * 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)
  25196. * @param x defines x coordinate
  25197. * @param y defines y coordinate
  25198. * @param z defines z coordinate
  25199. * @returns the array of facet indexes
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25201. */
  25202. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25203. /**
  25204. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25205. * @param projected sets as the (x,y,z) world projection on the facet
  25206. * @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
  25207. * @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
  25208. * @param x defines x coordinate
  25209. * @param y defines y coordinate
  25210. * @param z defines z coordinate
  25211. * @returns the face index if found (or null instead)
  25212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25213. */
  25214. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25215. /**
  25216. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25217. * @param projected sets as the (x,y,z) local projection on the facet
  25218. * @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
  25219. * @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
  25220. * @param x defines x coordinate
  25221. * @param y defines y coordinate
  25222. * @param z defines z coordinate
  25223. * @returns the face index if found (or null instead)
  25224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25225. */
  25226. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25227. /**
  25228. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25229. * @returns the parameters
  25230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25231. */
  25232. getFacetDataParameters(): any;
  25233. /**
  25234. * Disables the feature FacetData and frees the related memory
  25235. * @returns the current mesh
  25236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25237. */
  25238. disableFacetData(): AbstractMesh;
  25239. /**
  25240. * Updates the AbstractMesh indices array
  25241. * @param indices defines the data source
  25242. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25243. * @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)
  25244. * @returns the current mesh
  25245. */
  25246. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25247. /**
  25248. * Creates new normals data for the mesh
  25249. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25250. * @returns the current mesh
  25251. */
  25252. createNormals(updatable: boolean): AbstractMesh;
  25253. /**
  25254. * Align the mesh with a normal
  25255. * @param normal defines the normal to use
  25256. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25257. * @returns the current mesh
  25258. */
  25259. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25260. /** @hidden */
  25261. _checkOcclusionQuery(): boolean;
  25262. /**
  25263. * Disables the mesh edge rendering mode
  25264. * @returns the currentAbstractMesh
  25265. */
  25266. disableEdgesRendering(): AbstractMesh;
  25267. /**
  25268. * Enables the edge rendering mode on the mesh.
  25269. * This mode makes the mesh edges visible
  25270. * @param epsilon defines the maximal distance between two angles to detect a face
  25271. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25272. * @returns the currentAbstractMesh
  25273. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25274. */
  25275. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25276. }
  25277. }
  25278. declare module BABYLON {
  25279. /**
  25280. * Interface used to define ActionEvent
  25281. */
  25282. export interface IActionEvent {
  25283. /** The mesh or sprite that triggered the action */
  25284. source: any;
  25285. /** The X mouse cursor position at the time of the event */
  25286. pointerX: number;
  25287. /** The Y mouse cursor position at the time of the event */
  25288. pointerY: number;
  25289. /** The mesh that is currently pointed at (can be null) */
  25290. meshUnderPointer: Nullable<AbstractMesh>;
  25291. /** the original (browser) event that triggered the ActionEvent */
  25292. sourceEvent?: any;
  25293. /** additional data for the event */
  25294. additionalData?: any;
  25295. }
  25296. /**
  25297. * ActionEvent is the event being sent when an action is triggered.
  25298. */
  25299. export class ActionEvent implements IActionEvent {
  25300. /** The mesh or sprite that triggered the action */
  25301. source: any;
  25302. /** The X mouse cursor position at the time of the event */
  25303. pointerX: number;
  25304. /** The Y mouse cursor position at the time of the event */
  25305. pointerY: number;
  25306. /** The mesh that is currently pointed at (can be null) */
  25307. meshUnderPointer: Nullable<AbstractMesh>;
  25308. /** the original (browser) event that triggered the ActionEvent */
  25309. sourceEvent?: any;
  25310. /** additional data for the event */
  25311. additionalData?: any;
  25312. /**
  25313. * Creates a new ActionEvent
  25314. * @param source The mesh or sprite that triggered the action
  25315. * @param pointerX The X mouse cursor position at the time of the event
  25316. * @param pointerY The Y mouse cursor position at the time of the event
  25317. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25318. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25319. * @param additionalData additional data for the event
  25320. */
  25321. constructor(
  25322. /** The mesh or sprite that triggered the action */
  25323. source: any,
  25324. /** The X mouse cursor position at the time of the event */
  25325. pointerX: number,
  25326. /** The Y mouse cursor position at the time of the event */
  25327. pointerY: number,
  25328. /** The mesh that is currently pointed at (can be null) */
  25329. meshUnderPointer: Nullable<AbstractMesh>,
  25330. /** the original (browser) event that triggered the ActionEvent */
  25331. sourceEvent?: any,
  25332. /** additional data for the event */
  25333. additionalData?: any);
  25334. /**
  25335. * Helper function to auto-create an ActionEvent from a source mesh.
  25336. * @param source The source mesh that triggered the event
  25337. * @param evt The original (browser) event
  25338. * @param additionalData additional data for the event
  25339. * @returns the new ActionEvent
  25340. */
  25341. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25342. /**
  25343. * Helper function to auto-create an ActionEvent from a source sprite
  25344. * @param source The source sprite that triggered the event
  25345. * @param scene Scene associated with the sprite
  25346. * @param evt The original (browser) event
  25347. * @param additionalData additional data for the event
  25348. * @returns the new ActionEvent
  25349. */
  25350. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25351. /**
  25352. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25353. * @param scene the scene where the event occurred
  25354. * @param evt The original (browser) event
  25355. * @returns the new ActionEvent
  25356. */
  25357. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25358. /**
  25359. * Helper function to auto-create an ActionEvent from a primitive
  25360. * @param prim defines the target primitive
  25361. * @param pointerPos defines the pointer position
  25362. * @param evt The original (browser) event
  25363. * @param additionalData additional data for the event
  25364. * @returns the new ActionEvent
  25365. */
  25366. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25367. }
  25368. }
  25369. declare module BABYLON {
  25370. /**
  25371. * Abstract class used to decouple action Manager from scene and meshes.
  25372. * Do not instantiate.
  25373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25374. */
  25375. export abstract class AbstractActionManager implements IDisposable {
  25376. /** Gets the list of active triggers */
  25377. static Triggers: {
  25378. [key: string]: number;
  25379. };
  25380. /** Gets the cursor to use when hovering items */
  25381. hoverCursor: string;
  25382. /** Gets the list of actions */
  25383. actions: IAction[];
  25384. /**
  25385. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25386. */
  25387. isRecursive: boolean;
  25388. /**
  25389. * Releases all associated resources
  25390. */
  25391. abstract dispose(): void;
  25392. /**
  25393. * Does this action manager has pointer triggers
  25394. */
  25395. abstract readonly hasPointerTriggers: boolean;
  25396. /**
  25397. * Does this action manager has pick triggers
  25398. */
  25399. abstract readonly hasPickTriggers: boolean;
  25400. /**
  25401. * Process a specific trigger
  25402. * @param trigger defines the trigger to process
  25403. * @param evt defines the event details to be processed
  25404. */
  25405. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25406. /**
  25407. * Does this action manager handles actions of any of the given triggers
  25408. * @param triggers defines the triggers to be tested
  25409. * @return a boolean indicating whether one (or more) of the triggers is handled
  25410. */
  25411. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25412. /**
  25413. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25414. * speed.
  25415. * @param triggerA defines the trigger to be tested
  25416. * @param triggerB defines the trigger to be tested
  25417. * @return a boolean indicating whether one (or more) of the triggers is handled
  25418. */
  25419. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25420. /**
  25421. * Does this action manager handles actions of a given trigger
  25422. * @param trigger defines the trigger to be tested
  25423. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25424. * @return whether the trigger is handled
  25425. */
  25426. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25427. /**
  25428. * Serialize this manager to a JSON object
  25429. * @param name defines the property name to store this manager
  25430. * @returns a JSON representation of this manager
  25431. */
  25432. abstract serialize(name: string): any;
  25433. /**
  25434. * Registers an action to this action manager
  25435. * @param action defines the action to be registered
  25436. * @return the action amended (prepared) after registration
  25437. */
  25438. abstract registerAction(action: IAction): Nullable<IAction>;
  25439. /**
  25440. * Unregisters an action to this action manager
  25441. * @param action defines the action to be unregistered
  25442. * @return a boolean indicating whether the action has been unregistered
  25443. */
  25444. abstract unregisterAction(action: IAction): Boolean;
  25445. /**
  25446. * Does exist one action manager with at least one trigger
  25447. **/
  25448. static readonly HasTriggers: boolean;
  25449. /**
  25450. * Does exist one action manager with at least one pick trigger
  25451. **/
  25452. static readonly HasPickTriggers: boolean;
  25453. /**
  25454. * Does exist one action manager that handles actions of a given trigger
  25455. * @param trigger defines the trigger to be tested
  25456. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25457. **/
  25458. static HasSpecificTrigger(trigger: number): boolean;
  25459. }
  25460. }
  25461. declare module BABYLON {
  25462. /**
  25463. * Defines how a node can be built from a string name.
  25464. */
  25465. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25466. /**
  25467. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25468. */
  25469. export class Node implements IBehaviorAware<Node> {
  25470. /** @hidden */
  25471. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25472. private static _NodeConstructors;
  25473. /**
  25474. * Add a new node constructor
  25475. * @param type defines the type name of the node to construct
  25476. * @param constructorFunc defines the constructor function
  25477. */
  25478. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25479. /**
  25480. * Returns a node constructor based on type name
  25481. * @param type defines the type name
  25482. * @param name defines the new node name
  25483. * @param scene defines the hosting scene
  25484. * @param options defines optional options to transmit to constructors
  25485. * @returns the new constructor or null
  25486. */
  25487. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25488. /**
  25489. * Gets or sets the name of the node
  25490. */
  25491. name: string;
  25492. /**
  25493. * Gets or sets the id of the node
  25494. */
  25495. id: string;
  25496. /**
  25497. * Gets or sets the unique id of the node
  25498. */
  25499. uniqueId: number;
  25500. /**
  25501. * Gets or sets a string used to store user defined state for the node
  25502. */
  25503. state: string;
  25504. /**
  25505. * Gets or sets an object used to store user defined information for the node
  25506. */
  25507. metadata: any;
  25508. /**
  25509. * For internal use only. Please do not use.
  25510. */
  25511. reservedDataStore: any;
  25512. /**
  25513. * List of inspectable custom properties (used by the Inspector)
  25514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25515. */
  25516. inspectableCustomProperties: IInspectable[];
  25517. /**
  25518. * Gets or sets a boolean used to define if the node must be serialized
  25519. */
  25520. doNotSerialize: boolean;
  25521. /** @hidden */
  25522. _isDisposed: boolean;
  25523. /**
  25524. * Gets a list of Animations associated with the node
  25525. */
  25526. animations: Animation[];
  25527. protected _ranges: {
  25528. [name: string]: Nullable<AnimationRange>;
  25529. };
  25530. /**
  25531. * Callback raised when the node is ready to be used
  25532. */
  25533. onReady: Nullable<(node: Node) => void>;
  25534. private _isEnabled;
  25535. private _isParentEnabled;
  25536. private _isReady;
  25537. /** @hidden */
  25538. _currentRenderId: number;
  25539. private _parentUpdateId;
  25540. /** @hidden */
  25541. _childUpdateId: number;
  25542. /** @hidden */
  25543. _waitingParentId: Nullable<string>;
  25544. /** @hidden */
  25545. _scene: Scene;
  25546. /** @hidden */
  25547. _cache: any;
  25548. private _parentNode;
  25549. private _children;
  25550. /** @hidden */
  25551. _worldMatrix: Matrix;
  25552. /** @hidden */
  25553. _worldMatrixDeterminant: number;
  25554. /** @hidden */
  25555. _worldMatrixDeterminantIsDirty: boolean;
  25556. /** @hidden */
  25557. private _sceneRootNodesIndex;
  25558. /**
  25559. * Gets a boolean indicating if the node has been disposed
  25560. * @returns true if the node was disposed
  25561. */
  25562. isDisposed(): boolean;
  25563. /**
  25564. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25565. * @see https://doc.babylonjs.com/how_to/parenting
  25566. */
  25567. parent: Nullable<Node>;
  25568. private addToSceneRootNodes;
  25569. private removeFromSceneRootNodes;
  25570. private _animationPropertiesOverride;
  25571. /**
  25572. * Gets or sets the animation properties override
  25573. */
  25574. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25575. /**
  25576. * Gets a string idenfifying the name of the class
  25577. * @returns "Node" string
  25578. */
  25579. getClassName(): string;
  25580. /** @hidden */
  25581. readonly _isNode: boolean;
  25582. /**
  25583. * An event triggered when the mesh is disposed
  25584. */
  25585. onDisposeObservable: Observable<Node>;
  25586. private _onDisposeObserver;
  25587. /**
  25588. * Sets a callback that will be raised when the node will be disposed
  25589. */
  25590. onDispose: () => void;
  25591. /**
  25592. * Creates a new Node
  25593. * @param name the name and id to be given to this node
  25594. * @param scene the scene this node will be added to
  25595. * @param addToRootNodes the node will be added to scene.rootNodes
  25596. */
  25597. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25598. /**
  25599. * Gets the scene of the node
  25600. * @returns a scene
  25601. */
  25602. getScene(): Scene;
  25603. /**
  25604. * Gets the engine of the node
  25605. * @returns a Engine
  25606. */
  25607. getEngine(): Engine;
  25608. private _behaviors;
  25609. /**
  25610. * Attach a behavior to the node
  25611. * @see http://doc.babylonjs.com/features/behaviour
  25612. * @param behavior defines the behavior to attach
  25613. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25614. * @returns the current Node
  25615. */
  25616. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25617. /**
  25618. * Remove an attached behavior
  25619. * @see http://doc.babylonjs.com/features/behaviour
  25620. * @param behavior defines the behavior to attach
  25621. * @returns the current Node
  25622. */
  25623. removeBehavior(behavior: Behavior<Node>): Node;
  25624. /**
  25625. * Gets the list of attached behaviors
  25626. * @see http://doc.babylonjs.com/features/behaviour
  25627. */
  25628. readonly behaviors: Behavior<Node>[];
  25629. /**
  25630. * Gets an attached behavior by name
  25631. * @param name defines the name of the behavior to look for
  25632. * @see http://doc.babylonjs.com/features/behaviour
  25633. * @returns null if behavior was not found else the requested behavior
  25634. */
  25635. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25636. /**
  25637. * Returns the latest update of the World matrix
  25638. * @returns a Matrix
  25639. */
  25640. getWorldMatrix(): Matrix;
  25641. /** @hidden */
  25642. _getWorldMatrixDeterminant(): number;
  25643. /**
  25644. * Returns directly the latest state of the mesh World matrix.
  25645. * A Matrix is returned.
  25646. */
  25647. readonly worldMatrixFromCache: Matrix;
  25648. /** @hidden */
  25649. _initCache(): void;
  25650. /** @hidden */
  25651. updateCache(force?: boolean): void;
  25652. /** @hidden */
  25653. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25654. /** @hidden */
  25655. _updateCache(ignoreParentClass?: boolean): void;
  25656. /** @hidden */
  25657. _isSynchronized(): boolean;
  25658. /** @hidden */
  25659. _markSyncedWithParent(): void;
  25660. /** @hidden */
  25661. isSynchronizedWithParent(): boolean;
  25662. /** @hidden */
  25663. isSynchronized(): boolean;
  25664. /**
  25665. * Is this node ready to be used/rendered
  25666. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25667. * @return true if the node is ready
  25668. */
  25669. isReady(completeCheck?: boolean): boolean;
  25670. /**
  25671. * Is this node enabled?
  25672. * 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
  25673. * @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
  25674. * @return whether this node (and its parent) is enabled
  25675. */
  25676. isEnabled(checkAncestors?: boolean): boolean;
  25677. /** @hidden */
  25678. protected _syncParentEnabledState(): void;
  25679. /**
  25680. * Set the enabled state of this node
  25681. * @param value defines the new enabled state
  25682. */
  25683. setEnabled(value: boolean): void;
  25684. /**
  25685. * Is this node a descendant of the given node?
  25686. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25687. * @param ancestor defines the parent node to inspect
  25688. * @returns a boolean indicating if this node is a descendant of the given node
  25689. */
  25690. isDescendantOf(ancestor: Node): boolean;
  25691. /** @hidden */
  25692. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25693. /**
  25694. * Will return all nodes that have this node as ascendant
  25695. * @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
  25696. * @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
  25697. * @return all children nodes of all types
  25698. */
  25699. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25700. /**
  25701. * Get all child-meshes of this node
  25702. * @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)
  25703. * @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
  25704. * @returns an array of AbstractMesh
  25705. */
  25706. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25707. /**
  25708. * Get all direct children of this node
  25709. * @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
  25710. * @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)
  25711. * @returns an array of Node
  25712. */
  25713. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25714. /** @hidden */
  25715. _setReady(state: boolean): void;
  25716. /**
  25717. * Get an animation by name
  25718. * @param name defines the name of the animation to look for
  25719. * @returns null if not found else the requested animation
  25720. */
  25721. getAnimationByName(name: string): Nullable<Animation>;
  25722. /**
  25723. * Creates an animation range for this node
  25724. * @param name defines the name of the range
  25725. * @param from defines the starting key
  25726. * @param to defines the end key
  25727. */
  25728. createAnimationRange(name: string, from: number, to: number): void;
  25729. /**
  25730. * Delete a specific animation range
  25731. * @param name defines the name of the range to delete
  25732. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25733. */
  25734. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25735. /**
  25736. * Get an animation range by name
  25737. * @param name defines the name of the animation range to look for
  25738. * @returns null if not found else the requested animation range
  25739. */
  25740. getAnimationRange(name: string): Nullable<AnimationRange>;
  25741. /**
  25742. * Gets the list of all animation ranges defined on this node
  25743. * @returns an array
  25744. */
  25745. getAnimationRanges(): Nullable<AnimationRange>[];
  25746. /**
  25747. * Will start the animation sequence
  25748. * @param name defines the range frames for animation sequence
  25749. * @param loop defines if the animation should loop (false by default)
  25750. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25751. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25752. * @returns the object created for this animation. If range does not exist, it will return null
  25753. */
  25754. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25755. /**
  25756. * Serialize animation ranges into a JSON compatible object
  25757. * @returns serialization object
  25758. */
  25759. serializeAnimationRanges(): any;
  25760. /**
  25761. * Computes the world matrix of the node
  25762. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25763. * @returns the world matrix
  25764. */
  25765. computeWorldMatrix(force?: boolean): Matrix;
  25766. /**
  25767. * Releases resources associated with this node.
  25768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25770. */
  25771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25772. /**
  25773. * Parse animation range data from a serialization object and store them into a given node
  25774. * @param node defines where to store the animation ranges
  25775. * @param parsedNode defines the serialization object to read data from
  25776. * @param scene defines the hosting scene
  25777. */
  25778. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25779. /**
  25780. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25781. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25782. * @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
  25783. * @returns the new bounding vectors
  25784. */
  25785. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25786. min: Vector3;
  25787. max: Vector3;
  25788. };
  25789. }
  25790. }
  25791. declare module BABYLON {
  25792. /**
  25793. * @hidden
  25794. */
  25795. export class _IAnimationState {
  25796. key: number;
  25797. repeatCount: number;
  25798. workValue?: any;
  25799. loopMode?: number;
  25800. offsetValue?: any;
  25801. highLimitValue?: any;
  25802. }
  25803. /**
  25804. * Class used to store any kind of animation
  25805. */
  25806. export class Animation {
  25807. /**Name of the animation */
  25808. name: string;
  25809. /**Property to animate */
  25810. targetProperty: string;
  25811. /**The frames per second of the animation */
  25812. framePerSecond: number;
  25813. /**The data type of the animation */
  25814. dataType: number;
  25815. /**The loop mode of the animation */
  25816. loopMode?: number | undefined;
  25817. /**Specifies if blending should be enabled */
  25818. enableBlending?: boolean | undefined;
  25819. /**
  25820. * Use matrix interpolation instead of using direct key value when animating matrices
  25821. */
  25822. static AllowMatricesInterpolation: boolean;
  25823. /**
  25824. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25825. */
  25826. static AllowMatrixDecomposeForInterpolation: boolean;
  25827. /**
  25828. * Stores the key frames of the animation
  25829. */
  25830. private _keys;
  25831. /**
  25832. * Stores the easing function of the animation
  25833. */
  25834. private _easingFunction;
  25835. /**
  25836. * @hidden Internal use only
  25837. */
  25838. _runtimeAnimations: RuntimeAnimation[];
  25839. /**
  25840. * The set of event that will be linked to this animation
  25841. */
  25842. private _events;
  25843. /**
  25844. * Stores an array of target property paths
  25845. */
  25846. targetPropertyPath: string[];
  25847. /**
  25848. * Stores the blending speed of the animation
  25849. */
  25850. blendingSpeed: number;
  25851. /**
  25852. * Stores the animation ranges for the animation
  25853. */
  25854. private _ranges;
  25855. /**
  25856. * @hidden Internal use
  25857. */
  25858. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25859. /**
  25860. * Sets up an animation
  25861. * @param property The property to animate
  25862. * @param animationType The animation type to apply
  25863. * @param framePerSecond The frames per second of the animation
  25864. * @param easingFunction The easing function used in the animation
  25865. * @returns The created animation
  25866. */
  25867. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25868. /**
  25869. * Create and start an animation on a node
  25870. * @param name defines the name of the global animation that will be run on all nodes
  25871. * @param node defines the root node where the animation will take place
  25872. * @param targetProperty defines property to animate
  25873. * @param framePerSecond defines the number of frame per second yo use
  25874. * @param totalFrame defines the number of frames in total
  25875. * @param from defines the initial value
  25876. * @param to defines the final value
  25877. * @param loopMode defines which loop mode you want to use (off by default)
  25878. * @param easingFunction defines the easing function to use (linear by default)
  25879. * @param onAnimationEnd defines the callback to call when animation end
  25880. * @returns the animatable created for this animation
  25881. */
  25882. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25883. /**
  25884. * Create and start an animation on a node and its descendants
  25885. * @param name defines the name of the global animation that will be run on all nodes
  25886. * @param node defines the root node where the animation will take place
  25887. * @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
  25888. * @param targetProperty defines property to animate
  25889. * @param framePerSecond defines the number of frame per second to use
  25890. * @param totalFrame defines the number of frames in total
  25891. * @param from defines the initial value
  25892. * @param to defines the final value
  25893. * @param loopMode defines which loop mode you want to use (off by default)
  25894. * @param easingFunction defines the easing function to use (linear by default)
  25895. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25896. * @returns the list of animatables created for all nodes
  25897. * @example https://www.babylonjs-playground.com/#MH0VLI
  25898. */
  25899. 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[]>;
  25900. /**
  25901. * Creates a new animation, merges it with the existing animations and starts it
  25902. * @param name Name of the animation
  25903. * @param node Node which contains the scene that begins the animations
  25904. * @param targetProperty Specifies which property to animate
  25905. * @param framePerSecond The frames per second of the animation
  25906. * @param totalFrame The total number of frames
  25907. * @param from The frame at the beginning of the animation
  25908. * @param to The frame at the end of the animation
  25909. * @param loopMode Specifies the loop mode of the animation
  25910. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25911. * @param onAnimationEnd Callback to run once the animation is complete
  25912. * @returns Nullable animation
  25913. */
  25914. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25915. /**
  25916. * Transition property of an host to the target Value
  25917. * @param property The property to transition
  25918. * @param targetValue The target Value of the property
  25919. * @param host The object where the property to animate belongs
  25920. * @param scene Scene used to run the animation
  25921. * @param frameRate Framerate (in frame/s) to use
  25922. * @param transition The transition type we want to use
  25923. * @param duration The duration of the animation, in milliseconds
  25924. * @param onAnimationEnd Callback trigger at the end of the animation
  25925. * @returns Nullable animation
  25926. */
  25927. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25928. /**
  25929. * Return the array of runtime animations currently using this animation
  25930. */
  25931. readonly runtimeAnimations: RuntimeAnimation[];
  25932. /**
  25933. * Specifies if any of the runtime animations are currently running
  25934. */
  25935. readonly hasRunningRuntimeAnimations: boolean;
  25936. /**
  25937. * Initializes the animation
  25938. * @param name Name of the animation
  25939. * @param targetProperty Property to animate
  25940. * @param framePerSecond The frames per second of the animation
  25941. * @param dataType The data type of the animation
  25942. * @param loopMode The loop mode of the animation
  25943. * @param enableBlending Specifies if blending should be enabled
  25944. */
  25945. constructor(
  25946. /**Name of the animation */
  25947. name: string,
  25948. /**Property to animate */
  25949. targetProperty: string,
  25950. /**The frames per second of the animation */
  25951. framePerSecond: number,
  25952. /**The data type of the animation */
  25953. dataType: number,
  25954. /**The loop mode of the animation */
  25955. loopMode?: number | undefined,
  25956. /**Specifies if blending should be enabled */
  25957. enableBlending?: boolean | undefined);
  25958. /**
  25959. * Converts the animation to a string
  25960. * @param fullDetails support for multiple levels of logging within scene loading
  25961. * @returns String form of the animation
  25962. */
  25963. toString(fullDetails?: boolean): string;
  25964. /**
  25965. * Add an event to this animation
  25966. * @param event Event to add
  25967. */
  25968. addEvent(event: AnimationEvent): void;
  25969. /**
  25970. * Remove all events found at the given frame
  25971. * @param frame The frame to remove events from
  25972. */
  25973. removeEvents(frame: number): void;
  25974. /**
  25975. * Retrieves all the events from the animation
  25976. * @returns Events from the animation
  25977. */
  25978. getEvents(): AnimationEvent[];
  25979. /**
  25980. * Creates an animation range
  25981. * @param name Name of the animation range
  25982. * @param from Starting frame of the animation range
  25983. * @param to Ending frame of the animation
  25984. */
  25985. createRange(name: string, from: number, to: number): void;
  25986. /**
  25987. * Deletes an animation range by name
  25988. * @param name Name of the animation range to delete
  25989. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25990. */
  25991. deleteRange(name: string, deleteFrames?: boolean): void;
  25992. /**
  25993. * Gets the animation range by name, or null if not defined
  25994. * @param name Name of the animation range
  25995. * @returns Nullable animation range
  25996. */
  25997. getRange(name: string): Nullable<AnimationRange>;
  25998. /**
  25999. * Gets the key frames from the animation
  26000. * @returns The key frames of the animation
  26001. */
  26002. getKeys(): Array<IAnimationKey>;
  26003. /**
  26004. * Gets the highest frame rate of the animation
  26005. * @returns Highest frame rate of the animation
  26006. */
  26007. getHighestFrame(): number;
  26008. /**
  26009. * Gets the easing function of the animation
  26010. * @returns Easing function of the animation
  26011. */
  26012. getEasingFunction(): IEasingFunction;
  26013. /**
  26014. * Sets the easing function of the animation
  26015. * @param easingFunction A custom mathematical formula for animation
  26016. */
  26017. setEasingFunction(easingFunction: EasingFunction): void;
  26018. /**
  26019. * Interpolates a scalar linearly
  26020. * @param startValue Start value of the animation curve
  26021. * @param endValue End value of the animation curve
  26022. * @param gradient Scalar amount to interpolate
  26023. * @returns Interpolated scalar value
  26024. */
  26025. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26026. /**
  26027. * Interpolates a scalar cubically
  26028. * @param startValue Start value of the animation curve
  26029. * @param outTangent End tangent of the animation
  26030. * @param endValue End value of the animation curve
  26031. * @param inTangent Start tangent of the animation curve
  26032. * @param gradient Scalar amount to interpolate
  26033. * @returns Interpolated scalar value
  26034. */
  26035. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26036. /**
  26037. * Interpolates a quaternion using a spherical linear interpolation
  26038. * @param startValue Start value of the animation curve
  26039. * @param endValue End value of the animation curve
  26040. * @param gradient Scalar amount to interpolate
  26041. * @returns Interpolated quaternion value
  26042. */
  26043. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26044. /**
  26045. * Interpolates a quaternion cubically
  26046. * @param startValue Start value of the animation curve
  26047. * @param outTangent End tangent of the animation curve
  26048. * @param endValue End value of the animation curve
  26049. * @param inTangent Start tangent of the animation curve
  26050. * @param gradient Scalar amount to interpolate
  26051. * @returns Interpolated quaternion value
  26052. */
  26053. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26054. /**
  26055. * Interpolates a Vector3 linearl
  26056. * @param startValue Start value of the animation curve
  26057. * @param endValue End value of the animation curve
  26058. * @param gradient Scalar amount to interpolate
  26059. * @returns Interpolated scalar value
  26060. */
  26061. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26062. /**
  26063. * Interpolates a Vector3 cubically
  26064. * @param startValue Start value of the animation curve
  26065. * @param outTangent End tangent of the animation
  26066. * @param endValue End value of the animation curve
  26067. * @param inTangent Start tangent of the animation curve
  26068. * @param gradient Scalar amount to interpolate
  26069. * @returns InterpolatedVector3 value
  26070. */
  26071. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26072. /**
  26073. * Interpolates a Vector2 linearly
  26074. * @param startValue Start value of the animation curve
  26075. * @param endValue End value of the animation curve
  26076. * @param gradient Scalar amount to interpolate
  26077. * @returns Interpolated Vector2 value
  26078. */
  26079. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26080. /**
  26081. * Interpolates a Vector2 cubically
  26082. * @param startValue Start value of the animation curve
  26083. * @param outTangent End tangent of the animation
  26084. * @param endValue End value of the animation curve
  26085. * @param inTangent Start tangent of the animation curve
  26086. * @param gradient Scalar amount to interpolate
  26087. * @returns Interpolated Vector2 value
  26088. */
  26089. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26090. /**
  26091. * Interpolates a size linearly
  26092. * @param startValue Start value of the animation curve
  26093. * @param endValue End value of the animation curve
  26094. * @param gradient Scalar amount to interpolate
  26095. * @returns Interpolated Size value
  26096. */
  26097. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26098. /**
  26099. * Interpolates a Color3 linearly
  26100. * @param startValue Start value of the animation curve
  26101. * @param endValue End value of the animation curve
  26102. * @param gradient Scalar amount to interpolate
  26103. * @returns Interpolated Color3 value
  26104. */
  26105. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26106. /**
  26107. * @hidden Internal use only
  26108. */
  26109. _getKeyValue(value: any): any;
  26110. /**
  26111. * @hidden Internal use only
  26112. */
  26113. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26114. /**
  26115. * Defines the function to use to interpolate matrices
  26116. * @param startValue defines the start matrix
  26117. * @param endValue defines the end matrix
  26118. * @param gradient defines the gradient between both matrices
  26119. * @param result defines an optional target matrix where to store the interpolation
  26120. * @returns the interpolated matrix
  26121. */
  26122. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26123. /**
  26124. * Makes a copy of the animation
  26125. * @returns Cloned animation
  26126. */
  26127. clone(): Animation;
  26128. /**
  26129. * Sets the key frames of the animation
  26130. * @param values The animation key frames to set
  26131. */
  26132. setKeys(values: Array<IAnimationKey>): void;
  26133. /**
  26134. * Serializes the animation to an object
  26135. * @returns Serialized object
  26136. */
  26137. serialize(): any;
  26138. /**
  26139. * Float animation type
  26140. */
  26141. private static _ANIMATIONTYPE_FLOAT;
  26142. /**
  26143. * Vector3 animation type
  26144. */
  26145. private static _ANIMATIONTYPE_VECTOR3;
  26146. /**
  26147. * Quaternion animation type
  26148. */
  26149. private static _ANIMATIONTYPE_QUATERNION;
  26150. /**
  26151. * Matrix animation type
  26152. */
  26153. private static _ANIMATIONTYPE_MATRIX;
  26154. /**
  26155. * Color3 animation type
  26156. */
  26157. private static _ANIMATIONTYPE_COLOR3;
  26158. /**
  26159. * Vector2 animation type
  26160. */
  26161. private static _ANIMATIONTYPE_VECTOR2;
  26162. /**
  26163. * Size animation type
  26164. */
  26165. private static _ANIMATIONTYPE_SIZE;
  26166. /**
  26167. * Relative Loop Mode
  26168. */
  26169. private static _ANIMATIONLOOPMODE_RELATIVE;
  26170. /**
  26171. * Cycle Loop Mode
  26172. */
  26173. private static _ANIMATIONLOOPMODE_CYCLE;
  26174. /**
  26175. * Constant Loop Mode
  26176. */
  26177. private static _ANIMATIONLOOPMODE_CONSTANT;
  26178. /**
  26179. * Get the float animation type
  26180. */
  26181. static readonly ANIMATIONTYPE_FLOAT: number;
  26182. /**
  26183. * Get the Vector3 animation type
  26184. */
  26185. static readonly ANIMATIONTYPE_VECTOR3: number;
  26186. /**
  26187. * Get the Vector2 animation type
  26188. */
  26189. static readonly ANIMATIONTYPE_VECTOR2: number;
  26190. /**
  26191. * Get the Size animation type
  26192. */
  26193. static readonly ANIMATIONTYPE_SIZE: number;
  26194. /**
  26195. * Get the Quaternion animation type
  26196. */
  26197. static readonly ANIMATIONTYPE_QUATERNION: number;
  26198. /**
  26199. * Get the Matrix animation type
  26200. */
  26201. static readonly ANIMATIONTYPE_MATRIX: number;
  26202. /**
  26203. * Get the Color3 animation type
  26204. */
  26205. static readonly ANIMATIONTYPE_COLOR3: number;
  26206. /**
  26207. * Get the Relative Loop Mode
  26208. */
  26209. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26210. /**
  26211. * Get the Cycle Loop Mode
  26212. */
  26213. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26214. /**
  26215. * Get the Constant Loop Mode
  26216. */
  26217. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26218. /** @hidden */
  26219. static _UniversalLerp(left: any, right: any, amount: number): any;
  26220. /**
  26221. * Parses an animation object and creates an animation
  26222. * @param parsedAnimation Parsed animation object
  26223. * @returns Animation object
  26224. */
  26225. static Parse(parsedAnimation: any): Animation;
  26226. /**
  26227. * Appends the serialized animations from the source animations
  26228. * @param source Source containing the animations
  26229. * @param destination Target to store the animations
  26230. */
  26231. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26232. }
  26233. }
  26234. declare module BABYLON {
  26235. /**
  26236. * Base class of all the textures in babylon.
  26237. * It groups all the common properties the materials, post process, lights... might need
  26238. * in order to make a correct use of the texture.
  26239. */
  26240. export class BaseTexture implements IAnimatable {
  26241. /**
  26242. * Default anisotropic filtering level for the application.
  26243. * It is set to 4 as a good tradeoff between perf and quality.
  26244. */
  26245. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26246. /**
  26247. * Gets or sets the unique id of the texture
  26248. */
  26249. uniqueId: number;
  26250. /**
  26251. * Define the name of the texture.
  26252. */
  26253. name: string;
  26254. /**
  26255. * Gets or sets an object used to store user defined information.
  26256. */
  26257. metadata: any;
  26258. /**
  26259. * For internal use only. Please do not use.
  26260. */
  26261. reservedDataStore: any;
  26262. private _hasAlpha;
  26263. /**
  26264. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26265. */
  26266. hasAlpha: boolean;
  26267. /**
  26268. * Defines if the alpha value should be determined via the rgb values.
  26269. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26270. */
  26271. getAlphaFromRGB: boolean;
  26272. /**
  26273. * Intensity or strength of the texture.
  26274. * It is commonly used by materials to fine tune the intensity of the texture
  26275. */
  26276. level: number;
  26277. /**
  26278. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26279. * This is part of the texture as textures usually maps to one uv set.
  26280. */
  26281. coordinatesIndex: number;
  26282. private _coordinatesMode;
  26283. /**
  26284. * How a texture is mapped.
  26285. *
  26286. * | Value | Type | Description |
  26287. * | ----- | ----------------------------------- | ----------- |
  26288. * | 0 | EXPLICIT_MODE | |
  26289. * | 1 | SPHERICAL_MODE | |
  26290. * | 2 | PLANAR_MODE | |
  26291. * | 3 | CUBIC_MODE | |
  26292. * | 4 | PROJECTION_MODE | |
  26293. * | 5 | SKYBOX_MODE | |
  26294. * | 6 | INVCUBIC_MODE | |
  26295. * | 7 | EQUIRECTANGULAR_MODE | |
  26296. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26297. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26298. */
  26299. coordinatesMode: number;
  26300. /**
  26301. * | Value | Type | Description |
  26302. * | ----- | ------------------ | ----------- |
  26303. * | 0 | CLAMP_ADDRESSMODE | |
  26304. * | 1 | WRAP_ADDRESSMODE | |
  26305. * | 2 | MIRROR_ADDRESSMODE | |
  26306. */
  26307. wrapU: number;
  26308. /**
  26309. * | Value | Type | Description |
  26310. * | ----- | ------------------ | ----------- |
  26311. * | 0 | CLAMP_ADDRESSMODE | |
  26312. * | 1 | WRAP_ADDRESSMODE | |
  26313. * | 2 | MIRROR_ADDRESSMODE | |
  26314. */
  26315. wrapV: number;
  26316. /**
  26317. * | Value | Type | Description |
  26318. * | ----- | ------------------ | ----------- |
  26319. * | 0 | CLAMP_ADDRESSMODE | |
  26320. * | 1 | WRAP_ADDRESSMODE | |
  26321. * | 2 | MIRROR_ADDRESSMODE | |
  26322. */
  26323. wrapR: number;
  26324. /**
  26325. * With compliant hardware and browser (supporting anisotropic filtering)
  26326. * this defines the level of anisotropic filtering in the texture.
  26327. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26328. */
  26329. anisotropicFilteringLevel: number;
  26330. /**
  26331. * Define if the texture is a cube texture or if false a 2d texture.
  26332. */
  26333. isCube: boolean;
  26334. /**
  26335. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26336. */
  26337. is3D: boolean;
  26338. /**
  26339. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26340. * HDR texture are usually stored in linear space.
  26341. * This only impacts the PBR and Background materials
  26342. */
  26343. gammaSpace: boolean;
  26344. /**
  26345. * Gets whether or not the texture contains RGBD data.
  26346. */
  26347. readonly isRGBD: boolean;
  26348. /**
  26349. * Is Z inverted in the texture (useful in a cube texture).
  26350. */
  26351. invertZ: boolean;
  26352. /**
  26353. * Are mip maps generated for this texture or not.
  26354. */
  26355. readonly noMipmap: boolean;
  26356. /**
  26357. * @hidden
  26358. */
  26359. lodLevelInAlpha: boolean;
  26360. /**
  26361. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26362. */
  26363. lodGenerationOffset: number;
  26364. /**
  26365. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26366. */
  26367. lodGenerationScale: number;
  26368. /**
  26369. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26370. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26371. * average roughness values.
  26372. */
  26373. linearSpecularLOD: boolean;
  26374. /**
  26375. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26376. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26377. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26378. */
  26379. irradianceTexture: Nullable<BaseTexture>;
  26380. /**
  26381. * Define if the texture is a render target.
  26382. */
  26383. isRenderTarget: boolean;
  26384. /**
  26385. * Define the unique id of the texture in the scene.
  26386. */
  26387. readonly uid: string;
  26388. /**
  26389. * Return a string representation of the texture.
  26390. * @returns the texture as a string
  26391. */
  26392. toString(): string;
  26393. /**
  26394. * Get the class name of the texture.
  26395. * @returns "BaseTexture"
  26396. */
  26397. getClassName(): string;
  26398. /**
  26399. * Define the list of animation attached to the texture.
  26400. */
  26401. animations: Animation[];
  26402. /**
  26403. * An event triggered when the texture is disposed.
  26404. */
  26405. onDisposeObservable: Observable<BaseTexture>;
  26406. private _onDisposeObserver;
  26407. /**
  26408. * Callback triggered when the texture has been disposed.
  26409. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26410. */
  26411. onDispose: () => void;
  26412. /**
  26413. * Define the current state of the loading sequence when in delayed load mode.
  26414. */
  26415. delayLoadState: number;
  26416. private _scene;
  26417. /** @hidden */
  26418. _texture: Nullable<InternalTexture>;
  26419. private _uid;
  26420. /**
  26421. * Define if the texture is preventinga material to render or not.
  26422. * If not and the texture is not ready, the engine will use a default black texture instead.
  26423. */
  26424. readonly isBlocking: boolean;
  26425. /**
  26426. * Instantiates a new BaseTexture.
  26427. * Base class of all the textures in babylon.
  26428. * It groups all the common properties the materials, post process, lights... might need
  26429. * in order to make a correct use of the texture.
  26430. * @param scene Define the scene the texture blongs to
  26431. */
  26432. constructor(scene: Nullable<Scene>);
  26433. /**
  26434. * Get the scene the texture belongs to.
  26435. * @returns the scene or null if undefined
  26436. */
  26437. getScene(): Nullable<Scene>;
  26438. /**
  26439. * Get the texture transform matrix used to offset tile the texture for istance.
  26440. * @returns the transformation matrix
  26441. */
  26442. getTextureMatrix(): Matrix;
  26443. /**
  26444. * Get the texture reflection matrix used to rotate/transform the reflection.
  26445. * @returns the reflection matrix
  26446. */
  26447. getReflectionTextureMatrix(): Matrix;
  26448. /**
  26449. * Get the underlying lower level texture from Babylon.
  26450. * @returns the insternal texture
  26451. */
  26452. getInternalTexture(): Nullable<InternalTexture>;
  26453. /**
  26454. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26455. * @returns true if ready or not blocking
  26456. */
  26457. isReadyOrNotBlocking(): boolean;
  26458. /**
  26459. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26460. * @returns true if fully ready
  26461. */
  26462. isReady(): boolean;
  26463. private _cachedSize;
  26464. /**
  26465. * Get the size of the texture.
  26466. * @returns the texture size.
  26467. */
  26468. getSize(): ISize;
  26469. /**
  26470. * Get the base size of the texture.
  26471. * It can be different from the size if the texture has been resized for POT for instance
  26472. * @returns the base size
  26473. */
  26474. getBaseSize(): ISize;
  26475. /**
  26476. * Update the sampling mode of the texture.
  26477. * Default is Trilinear mode.
  26478. *
  26479. * | Value | Type | Description |
  26480. * | ----- | ------------------ | ----------- |
  26481. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26482. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26483. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26484. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26485. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26486. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26487. * | 7 | NEAREST_LINEAR | |
  26488. * | 8 | NEAREST_NEAREST | |
  26489. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26490. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26491. * | 11 | LINEAR_LINEAR | |
  26492. * | 12 | LINEAR_NEAREST | |
  26493. *
  26494. * > _mag_: magnification filter (close to the viewer)
  26495. * > _min_: minification filter (far from the viewer)
  26496. * > _mip_: filter used between mip map levels
  26497. *@param samplingMode Define the new sampling mode of the texture
  26498. */
  26499. updateSamplingMode(samplingMode: number): void;
  26500. /**
  26501. * Scales the texture if is `canRescale()`
  26502. * @param ratio the resize factor we want to use to rescale
  26503. */
  26504. scale(ratio: number): void;
  26505. /**
  26506. * Get if the texture can rescale.
  26507. */
  26508. readonly canRescale: boolean;
  26509. /** @hidden */
  26510. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26511. /** @hidden */
  26512. _rebuild(): void;
  26513. /**
  26514. * Triggers the load sequence in delayed load mode.
  26515. */
  26516. delayLoad(): void;
  26517. /**
  26518. * Clones the texture.
  26519. * @returns the cloned texture
  26520. */
  26521. clone(): Nullable<BaseTexture>;
  26522. /**
  26523. * Get the texture underlying type (INT, FLOAT...)
  26524. */
  26525. readonly textureType: number;
  26526. /**
  26527. * Get the texture underlying format (RGB, RGBA...)
  26528. */
  26529. readonly textureFormat: number;
  26530. /**
  26531. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26532. * This will returns an RGBA array buffer containing either in values (0-255) or
  26533. * float values (0-1) depending of the underlying buffer type.
  26534. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26535. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26536. * @param buffer defines a user defined buffer to fill with data (can be null)
  26537. * @returns The Array buffer containing the pixels data.
  26538. */
  26539. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26540. /**
  26541. * Release and destroy the underlying lower level texture aka internalTexture.
  26542. */
  26543. releaseInternalTexture(): void;
  26544. /**
  26545. * Get the polynomial representation of the texture data.
  26546. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26547. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26548. */
  26549. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26550. /** @hidden */
  26551. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26552. /** @hidden */
  26553. readonly _lodTextureMid: Nullable<BaseTexture>;
  26554. /** @hidden */
  26555. readonly _lodTextureLow: Nullable<BaseTexture>;
  26556. /**
  26557. * Dispose the texture and release its associated resources.
  26558. */
  26559. dispose(): void;
  26560. /**
  26561. * Serialize the texture into a JSON representation that can be parsed later on.
  26562. * @returns the JSON representation of the texture
  26563. */
  26564. serialize(): any;
  26565. /**
  26566. * Helper function to be called back once a list of texture contains only ready textures.
  26567. * @param textures Define the list of textures to wait for
  26568. * @param callback Define the callback triggered once the entire list will be ready
  26569. */
  26570. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26571. }
  26572. }
  26573. declare module BABYLON {
  26574. /**
  26575. * Uniform buffer objects.
  26576. *
  26577. * Handles blocks of uniform on the GPU.
  26578. *
  26579. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26580. *
  26581. * For more information, please refer to :
  26582. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26583. */
  26584. export class UniformBuffer {
  26585. private _engine;
  26586. private _buffer;
  26587. private _data;
  26588. private _bufferData;
  26589. private _dynamic?;
  26590. private _uniformLocations;
  26591. private _uniformSizes;
  26592. private _uniformLocationPointer;
  26593. private _needSync;
  26594. private _noUBO;
  26595. private _currentEffect;
  26596. private static _MAX_UNIFORM_SIZE;
  26597. private static _tempBuffer;
  26598. /**
  26599. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26600. * This is dynamic to allow compat with webgl 1 and 2.
  26601. * You will need to pass the name of the uniform as well as the value.
  26602. */
  26603. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26604. /**
  26605. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26606. * This is dynamic to allow compat with webgl 1 and 2.
  26607. * You will need to pass the name of the uniform as well as the value.
  26608. */
  26609. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26610. /**
  26611. * Lambda to Update a single float in a uniform buffer.
  26612. * This is dynamic to allow compat with webgl 1 and 2.
  26613. * You will need to pass the name of the uniform as well as the value.
  26614. */
  26615. updateFloat: (name: string, x: number) => void;
  26616. /**
  26617. * Lambda to Update a vec2 of float in a uniform buffer.
  26618. * This is dynamic to allow compat with webgl 1 and 2.
  26619. * You will need to pass the name of the uniform as well as the value.
  26620. */
  26621. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26622. /**
  26623. * Lambda to Update a vec3 of float in a uniform buffer.
  26624. * This is dynamic to allow compat with webgl 1 and 2.
  26625. * You will need to pass the name of the uniform as well as the value.
  26626. */
  26627. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26628. /**
  26629. * Lambda to Update a vec4 of float in a uniform buffer.
  26630. * This is dynamic to allow compat with webgl 1 and 2.
  26631. * You will need to pass the name of the uniform as well as the value.
  26632. */
  26633. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26634. /**
  26635. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26636. * This is dynamic to allow compat with webgl 1 and 2.
  26637. * You will need to pass the name of the uniform as well as the value.
  26638. */
  26639. updateMatrix: (name: string, mat: Matrix) => void;
  26640. /**
  26641. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26642. * This is dynamic to allow compat with webgl 1 and 2.
  26643. * You will need to pass the name of the uniform as well as the value.
  26644. */
  26645. updateVector3: (name: string, vector: Vector3) => void;
  26646. /**
  26647. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26648. * This is dynamic to allow compat with webgl 1 and 2.
  26649. * You will need to pass the name of the uniform as well as the value.
  26650. */
  26651. updateVector4: (name: string, vector: Vector4) => void;
  26652. /**
  26653. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26654. * This is dynamic to allow compat with webgl 1 and 2.
  26655. * You will need to pass the name of the uniform as well as the value.
  26656. */
  26657. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26658. /**
  26659. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26660. * This is dynamic to allow compat with webgl 1 and 2.
  26661. * You will need to pass the name of the uniform as well as the value.
  26662. */
  26663. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26664. /**
  26665. * Instantiates a new Uniform buffer objects.
  26666. *
  26667. * Handles blocks of uniform on the GPU.
  26668. *
  26669. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26670. *
  26671. * For more information, please refer to :
  26672. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26673. * @param engine Define the engine the buffer is associated with
  26674. * @param data Define the data contained in the buffer
  26675. * @param dynamic Define if the buffer is updatable
  26676. */
  26677. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26678. /**
  26679. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26680. * or just falling back on setUniformXXX calls.
  26681. */
  26682. readonly useUbo: boolean;
  26683. /**
  26684. * Indicates if the WebGL underlying uniform buffer is in sync
  26685. * with the javascript cache data.
  26686. */
  26687. readonly isSync: boolean;
  26688. /**
  26689. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26690. * Also, a dynamic UniformBuffer will disable cache verification and always
  26691. * update the underlying WebGL uniform buffer to the GPU.
  26692. * @returns if Dynamic, otherwise false
  26693. */
  26694. isDynamic(): boolean;
  26695. /**
  26696. * The data cache on JS side.
  26697. * @returns the underlying data as a float array
  26698. */
  26699. getData(): Float32Array;
  26700. /**
  26701. * The underlying WebGL Uniform buffer.
  26702. * @returns the webgl buffer
  26703. */
  26704. getBuffer(): Nullable<DataBuffer>;
  26705. /**
  26706. * std140 layout specifies how to align data within an UBO structure.
  26707. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26708. * for specs.
  26709. */
  26710. private _fillAlignment;
  26711. /**
  26712. * Adds an uniform in the buffer.
  26713. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26714. * for the layout to be correct !
  26715. * @param name Name of the uniform, as used in the uniform block in the shader.
  26716. * @param size Data size, or data directly.
  26717. */
  26718. addUniform(name: string, size: number | number[]): void;
  26719. /**
  26720. * Adds a Matrix 4x4 to the uniform buffer.
  26721. * @param name Name of the uniform, as used in the uniform block in the shader.
  26722. * @param mat A 4x4 matrix.
  26723. */
  26724. addMatrix(name: string, mat: Matrix): void;
  26725. /**
  26726. * Adds a vec2 to the uniform buffer.
  26727. * @param name Name of the uniform, as used in the uniform block in the shader.
  26728. * @param x Define the x component value of the vec2
  26729. * @param y Define the y component value of the vec2
  26730. */
  26731. addFloat2(name: string, x: number, y: number): void;
  26732. /**
  26733. * Adds a vec3 to the uniform buffer.
  26734. * @param name Name of the uniform, as used in the uniform block in the shader.
  26735. * @param x Define the x component value of the vec3
  26736. * @param y Define the y component value of the vec3
  26737. * @param z Define the z component value of the vec3
  26738. */
  26739. addFloat3(name: string, x: number, y: number, z: number): void;
  26740. /**
  26741. * Adds a vec3 to the uniform buffer.
  26742. * @param name Name of the uniform, as used in the uniform block in the shader.
  26743. * @param color Define the vec3 from a Color
  26744. */
  26745. addColor3(name: string, color: Color3): void;
  26746. /**
  26747. * Adds a vec4 to the uniform buffer.
  26748. * @param name Name of the uniform, as used in the uniform block in the shader.
  26749. * @param color Define the rgb components from a Color
  26750. * @param alpha Define the a component of the vec4
  26751. */
  26752. addColor4(name: string, color: Color3, alpha: number): void;
  26753. /**
  26754. * Adds a vec3 to the uniform buffer.
  26755. * @param name Name of the uniform, as used in the uniform block in the shader.
  26756. * @param vector Define the vec3 components from a Vector
  26757. */
  26758. addVector3(name: string, vector: Vector3): void;
  26759. /**
  26760. * Adds a Matrix 3x3 to the uniform buffer.
  26761. * @param name Name of the uniform, as used in the uniform block in the shader.
  26762. */
  26763. addMatrix3x3(name: string): void;
  26764. /**
  26765. * Adds a Matrix 2x2 to the uniform buffer.
  26766. * @param name Name of the uniform, as used in the uniform block in the shader.
  26767. */
  26768. addMatrix2x2(name: string): void;
  26769. /**
  26770. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26771. */
  26772. create(): void;
  26773. /** @hidden */
  26774. _rebuild(): void;
  26775. /**
  26776. * Updates the WebGL Uniform Buffer on the GPU.
  26777. * If the `dynamic` flag is set to true, no cache comparison is done.
  26778. * Otherwise, the buffer will be updated only if the cache differs.
  26779. */
  26780. update(): void;
  26781. /**
  26782. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26783. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26784. * @param data Define the flattened data
  26785. * @param size Define the size of the data.
  26786. */
  26787. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26788. private _updateMatrix3x3ForUniform;
  26789. private _updateMatrix3x3ForEffect;
  26790. private _updateMatrix2x2ForEffect;
  26791. private _updateMatrix2x2ForUniform;
  26792. private _updateFloatForEffect;
  26793. private _updateFloatForUniform;
  26794. private _updateFloat2ForEffect;
  26795. private _updateFloat2ForUniform;
  26796. private _updateFloat3ForEffect;
  26797. private _updateFloat3ForUniform;
  26798. private _updateFloat4ForEffect;
  26799. private _updateFloat4ForUniform;
  26800. private _updateMatrixForEffect;
  26801. private _updateMatrixForUniform;
  26802. private _updateVector3ForEffect;
  26803. private _updateVector3ForUniform;
  26804. private _updateVector4ForEffect;
  26805. private _updateVector4ForUniform;
  26806. private _updateColor3ForEffect;
  26807. private _updateColor3ForUniform;
  26808. private _updateColor4ForEffect;
  26809. private _updateColor4ForUniform;
  26810. /**
  26811. * Sets a sampler uniform on the effect.
  26812. * @param name Define the name of the sampler.
  26813. * @param texture Define the texture to set in the sampler
  26814. */
  26815. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26816. /**
  26817. * Directly updates the value of the uniform in the cache AND on the GPU.
  26818. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26819. * @param data Define the flattened data
  26820. */
  26821. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26822. /**
  26823. * Binds this uniform buffer to an effect.
  26824. * @param effect Define the effect to bind the buffer to
  26825. * @param name Name of the uniform block in the shader.
  26826. */
  26827. bindToEffect(effect: Effect, name: string): void;
  26828. /**
  26829. * Disposes the uniform buffer.
  26830. */
  26831. dispose(): void;
  26832. }
  26833. }
  26834. declare module BABYLON {
  26835. /**
  26836. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26838. */
  26839. export class Analyser {
  26840. /**
  26841. * Gets or sets the smoothing
  26842. * @ignorenaming
  26843. */
  26844. SMOOTHING: number;
  26845. /**
  26846. * Gets or sets the FFT table size
  26847. * @ignorenaming
  26848. */
  26849. FFT_SIZE: number;
  26850. /**
  26851. * Gets or sets the bar graph amplitude
  26852. * @ignorenaming
  26853. */
  26854. BARGRAPHAMPLITUDE: number;
  26855. /**
  26856. * Gets or sets the position of the debug canvas
  26857. * @ignorenaming
  26858. */
  26859. DEBUGCANVASPOS: {
  26860. x: number;
  26861. y: number;
  26862. };
  26863. /**
  26864. * Gets or sets the debug canvas size
  26865. * @ignorenaming
  26866. */
  26867. DEBUGCANVASSIZE: {
  26868. width: number;
  26869. height: number;
  26870. };
  26871. private _byteFreqs;
  26872. private _byteTime;
  26873. private _floatFreqs;
  26874. private _webAudioAnalyser;
  26875. private _debugCanvas;
  26876. private _debugCanvasContext;
  26877. private _scene;
  26878. private _registerFunc;
  26879. private _audioEngine;
  26880. /**
  26881. * Creates a new analyser
  26882. * @param scene defines hosting scene
  26883. */
  26884. constructor(scene: Scene);
  26885. /**
  26886. * Get the number of data values you will have to play with for the visualization
  26887. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26888. * @returns a number
  26889. */
  26890. getFrequencyBinCount(): number;
  26891. /**
  26892. * Gets the current frequency data as a byte array
  26893. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26894. * @returns a Uint8Array
  26895. */
  26896. getByteFrequencyData(): Uint8Array;
  26897. /**
  26898. * Gets the current waveform as a byte array
  26899. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26900. * @returns a Uint8Array
  26901. */
  26902. getByteTimeDomainData(): Uint8Array;
  26903. /**
  26904. * Gets the current frequency data as a float array
  26905. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26906. * @returns a Float32Array
  26907. */
  26908. getFloatFrequencyData(): Float32Array;
  26909. /**
  26910. * Renders the debug canvas
  26911. */
  26912. drawDebugCanvas(): void;
  26913. /**
  26914. * Stops rendering the debug canvas and removes it
  26915. */
  26916. stopDebugCanvas(): void;
  26917. /**
  26918. * Connects two audio nodes
  26919. * @param inputAudioNode defines first node to connect
  26920. * @param outputAudioNode defines second node to connect
  26921. */
  26922. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26923. /**
  26924. * Releases all associated resources
  26925. */
  26926. dispose(): void;
  26927. }
  26928. }
  26929. declare module BABYLON {
  26930. /**
  26931. * This represents an audio engine and it is responsible
  26932. * to play, synchronize and analyse sounds throughout the application.
  26933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26934. */
  26935. export interface IAudioEngine extends IDisposable {
  26936. /**
  26937. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26938. */
  26939. readonly canUseWebAudio: boolean;
  26940. /**
  26941. * Gets the current AudioContext if available.
  26942. */
  26943. readonly audioContext: Nullable<AudioContext>;
  26944. /**
  26945. * The master gain node defines the global audio volume of your audio engine.
  26946. */
  26947. readonly masterGain: GainNode;
  26948. /**
  26949. * Gets whether or not mp3 are supported by your browser.
  26950. */
  26951. readonly isMP3supported: boolean;
  26952. /**
  26953. * Gets whether or not ogg are supported by your browser.
  26954. */
  26955. readonly isOGGsupported: boolean;
  26956. /**
  26957. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26958. * @ignoreNaming
  26959. */
  26960. WarnedWebAudioUnsupported: boolean;
  26961. /**
  26962. * Defines if the audio engine relies on a custom unlocked button.
  26963. * In this case, the embedded button will not be displayed.
  26964. */
  26965. useCustomUnlockedButton: boolean;
  26966. /**
  26967. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26968. */
  26969. readonly unlocked: boolean;
  26970. /**
  26971. * Event raised when audio has been unlocked on the browser.
  26972. */
  26973. onAudioUnlockedObservable: Observable<AudioEngine>;
  26974. /**
  26975. * Event raised when audio has been locked on the browser.
  26976. */
  26977. onAudioLockedObservable: Observable<AudioEngine>;
  26978. /**
  26979. * Flags the audio engine in Locked state.
  26980. * This happens due to new browser policies preventing audio to autoplay.
  26981. */
  26982. lock(): void;
  26983. /**
  26984. * Unlocks the audio engine once a user action has been done on the dom.
  26985. * This is helpful to resume play once browser policies have been satisfied.
  26986. */
  26987. unlock(): void;
  26988. }
  26989. /**
  26990. * This represents the default audio engine used in babylon.
  26991. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26993. */
  26994. export class AudioEngine implements IAudioEngine {
  26995. private _audioContext;
  26996. private _audioContextInitialized;
  26997. private _muteButton;
  26998. private _hostElement;
  26999. /**
  27000. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27001. */
  27002. canUseWebAudio: boolean;
  27003. /**
  27004. * The master gain node defines the global audio volume of your audio engine.
  27005. */
  27006. masterGain: GainNode;
  27007. /**
  27008. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27009. * @ignoreNaming
  27010. */
  27011. WarnedWebAudioUnsupported: boolean;
  27012. /**
  27013. * Gets whether or not mp3 are supported by your browser.
  27014. */
  27015. isMP3supported: boolean;
  27016. /**
  27017. * Gets whether or not ogg are supported by your browser.
  27018. */
  27019. isOGGsupported: boolean;
  27020. /**
  27021. * Gets whether audio has been unlocked on the device.
  27022. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27023. * a user interaction has happened.
  27024. */
  27025. unlocked: boolean;
  27026. /**
  27027. * Defines if the audio engine relies on a custom unlocked button.
  27028. * In this case, the embedded button will not be displayed.
  27029. */
  27030. useCustomUnlockedButton: boolean;
  27031. /**
  27032. * Event raised when audio has been unlocked on the browser.
  27033. */
  27034. onAudioUnlockedObservable: Observable<AudioEngine>;
  27035. /**
  27036. * Event raised when audio has been locked on the browser.
  27037. */
  27038. onAudioLockedObservable: Observable<AudioEngine>;
  27039. /**
  27040. * Gets the current AudioContext if available.
  27041. */
  27042. readonly audioContext: Nullable<AudioContext>;
  27043. private _connectedAnalyser;
  27044. /**
  27045. * Instantiates a new audio engine.
  27046. *
  27047. * There should be only one per page as some browsers restrict the number
  27048. * of audio contexts you can create.
  27049. * @param hostElement defines the host element where to display the mute icon if necessary
  27050. */
  27051. constructor(hostElement?: Nullable<HTMLElement>);
  27052. /**
  27053. * Flags the audio engine in Locked state.
  27054. * This happens due to new browser policies preventing audio to autoplay.
  27055. */
  27056. lock(): void;
  27057. /**
  27058. * Unlocks the audio engine once a user action has been done on the dom.
  27059. * This is helpful to resume play once browser policies have been satisfied.
  27060. */
  27061. unlock(): void;
  27062. private _resumeAudioContext;
  27063. private _initializeAudioContext;
  27064. private _tryToRun;
  27065. private _triggerRunningState;
  27066. private _triggerSuspendedState;
  27067. private _displayMuteButton;
  27068. private _moveButtonToTopLeft;
  27069. private _onResize;
  27070. private _hideMuteButton;
  27071. /**
  27072. * Destroy and release the resources associated with the audio ccontext.
  27073. */
  27074. dispose(): void;
  27075. /**
  27076. * Gets the global volume sets on the master gain.
  27077. * @returns the global volume if set or -1 otherwise
  27078. */
  27079. getGlobalVolume(): number;
  27080. /**
  27081. * Sets the global volume of your experience (sets on the master gain).
  27082. * @param newVolume Defines the new global volume of the application
  27083. */
  27084. setGlobalVolume(newVolume: number): void;
  27085. /**
  27086. * Connect the audio engine to an audio analyser allowing some amazing
  27087. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27089. * @param analyser The analyser to connect to the engine
  27090. */
  27091. connectToAnalyser(analyser: Analyser): void;
  27092. }
  27093. }
  27094. declare module BABYLON {
  27095. /**
  27096. * Interface used to present a loading screen while loading a scene
  27097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27098. */
  27099. export interface ILoadingScreen {
  27100. /**
  27101. * Function called to display the loading screen
  27102. */
  27103. displayLoadingUI: () => void;
  27104. /**
  27105. * Function called to hide the loading screen
  27106. */
  27107. hideLoadingUI: () => void;
  27108. /**
  27109. * Gets or sets the color to use for the background
  27110. */
  27111. loadingUIBackgroundColor: string;
  27112. /**
  27113. * Gets or sets the text to display while loading
  27114. */
  27115. loadingUIText: string;
  27116. }
  27117. /**
  27118. * Class used for the default loading screen
  27119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27120. */
  27121. export class DefaultLoadingScreen implements ILoadingScreen {
  27122. private _renderingCanvas;
  27123. private _loadingText;
  27124. private _loadingDivBackgroundColor;
  27125. private _loadingDiv;
  27126. private _loadingTextDiv;
  27127. /** Gets or sets the logo url to use for the default loading screen */
  27128. static DefaultLogoUrl: string;
  27129. /** Gets or sets the spinner url to use for the default loading screen */
  27130. static DefaultSpinnerUrl: string;
  27131. /**
  27132. * Creates a new default loading screen
  27133. * @param _renderingCanvas defines the canvas used to render the scene
  27134. * @param _loadingText defines the default text to display
  27135. * @param _loadingDivBackgroundColor defines the default background color
  27136. */
  27137. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27138. /**
  27139. * Function called to display the loading screen
  27140. */
  27141. displayLoadingUI(): void;
  27142. /**
  27143. * Function called to hide the loading screen
  27144. */
  27145. hideLoadingUI(): void;
  27146. /**
  27147. * Gets or sets the text to display while loading
  27148. */
  27149. loadingUIText: string;
  27150. /**
  27151. * Gets or sets the color to use for the background
  27152. */
  27153. loadingUIBackgroundColor: string;
  27154. private _resizeLoadingUI;
  27155. }
  27156. }
  27157. declare module BABYLON {
  27158. /** @hidden */
  27159. export class WebGLPipelineContext implements IPipelineContext {
  27160. engine: Engine;
  27161. program: Nullable<WebGLProgram>;
  27162. context?: WebGLRenderingContext;
  27163. vertexShader?: WebGLShader;
  27164. fragmentShader?: WebGLShader;
  27165. isParallelCompiled: boolean;
  27166. onCompiled?: () => void;
  27167. transformFeedback?: WebGLTransformFeedback | null;
  27168. readonly isAsync: boolean;
  27169. readonly isReady: boolean;
  27170. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27171. }
  27172. }
  27173. declare module BABYLON {
  27174. /** @hidden */
  27175. export class WebGLDataBuffer extends DataBuffer {
  27176. private _buffer;
  27177. constructor(resource: WebGLBuffer);
  27178. readonly underlyingResource: any;
  27179. }
  27180. }
  27181. declare module BABYLON {
  27182. /** @hidden */
  27183. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27184. attributeProcessor(attribute: string): string;
  27185. varyingProcessor(varying: string, isFragment: boolean): string;
  27186. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27187. }
  27188. }
  27189. declare module BABYLON {
  27190. /**
  27191. * Settings for finer control over video usage
  27192. */
  27193. export interface VideoTextureSettings {
  27194. /**
  27195. * Applies `autoplay` to video, if specified
  27196. */
  27197. autoPlay?: boolean;
  27198. /**
  27199. * Applies `loop` to video, if specified
  27200. */
  27201. loop?: boolean;
  27202. /**
  27203. * Automatically updates internal texture from video at every frame in the render loop
  27204. */
  27205. autoUpdateTexture: boolean;
  27206. /**
  27207. * Image src displayed during the video loading or until the user interacts with the video.
  27208. */
  27209. poster?: string;
  27210. }
  27211. /**
  27212. * If you want to display a video in your scene, this is the special texture for that.
  27213. * This special texture works similar to other textures, with the exception of a few parameters.
  27214. * @see https://doc.babylonjs.com/how_to/video_texture
  27215. */
  27216. export class VideoTexture extends Texture {
  27217. /**
  27218. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27219. */
  27220. readonly autoUpdateTexture: boolean;
  27221. /**
  27222. * The video instance used by the texture internally
  27223. */
  27224. readonly video: HTMLVideoElement;
  27225. private _onUserActionRequestedObservable;
  27226. /**
  27227. * Event triggerd when a dom action is required by the user to play the video.
  27228. * This happens due to recent changes in browser policies preventing video to auto start.
  27229. */
  27230. readonly onUserActionRequestedObservable: Observable<Texture>;
  27231. private _generateMipMaps;
  27232. private _engine;
  27233. private _stillImageCaptured;
  27234. private _displayingPosterTexture;
  27235. private _settings;
  27236. private _createInternalTextureOnEvent;
  27237. /**
  27238. * Creates a video texture.
  27239. * If you want to display a video in your scene, this is the special texture for that.
  27240. * This special texture works similar to other textures, with the exception of a few parameters.
  27241. * @see https://doc.babylonjs.com/how_to/video_texture
  27242. * @param name optional name, will detect from video source, if not defined
  27243. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27244. * @param scene is obviously the current scene.
  27245. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27246. * @param invertY is false by default but can be used to invert video on Y axis
  27247. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27248. * @param settings allows finer control over video usage
  27249. */
  27250. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27251. private _getName;
  27252. private _getVideo;
  27253. private _createInternalTexture;
  27254. private reset;
  27255. /**
  27256. * @hidden Internal method to initiate `update`.
  27257. */
  27258. _rebuild(): void;
  27259. /**
  27260. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27261. */
  27262. update(): void;
  27263. /**
  27264. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27265. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27266. */
  27267. updateTexture(isVisible: boolean): void;
  27268. protected _updateInternalTexture: () => void;
  27269. /**
  27270. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27271. * @param url New url.
  27272. */
  27273. updateURL(url: string): void;
  27274. /**
  27275. * Dispose the texture and release its associated resources.
  27276. */
  27277. dispose(): void;
  27278. /**
  27279. * Creates a video texture straight from a stream.
  27280. * @param scene Define the scene the texture should be created in
  27281. * @param stream Define the stream the texture should be created from
  27282. * @returns The created video texture as a promise
  27283. */
  27284. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27285. /**
  27286. * Creates a video texture straight from your WebCam video feed.
  27287. * @param scene Define the scene the texture should be created in
  27288. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27289. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27290. * @returns The created video texture as a promise
  27291. */
  27292. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27293. minWidth: number;
  27294. maxWidth: number;
  27295. minHeight: number;
  27296. maxHeight: number;
  27297. deviceId: string;
  27298. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27299. /**
  27300. * Creates a video texture straight from your WebCam video feed.
  27301. * @param scene Define the scene the texture should be created in
  27302. * @param onReady Define a callback to triggered once the texture will be ready
  27303. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27304. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27305. */
  27306. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27307. minWidth: number;
  27308. maxWidth: number;
  27309. minHeight: number;
  27310. maxHeight: number;
  27311. deviceId: string;
  27312. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27313. }
  27314. }
  27315. declare module BABYLON {
  27316. /**
  27317. * Interface for attribute information associated with buffer instanciation
  27318. */
  27319. export class InstancingAttributeInfo {
  27320. /**
  27321. * Index/offset of the attribute in the vertex shader
  27322. */
  27323. index: number;
  27324. /**
  27325. * size of the attribute, 1, 2, 3 or 4
  27326. */
  27327. attributeSize: number;
  27328. /**
  27329. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27330. * default is FLOAT
  27331. */
  27332. attribyteType: number;
  27333. /**
  27334. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27335. */
  27336. normalized: boolean;
  27337. /**
  27338. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27339. */
  27340. offset: number;
  27341. /**
  27342. * Name of the GLSL attribute, for debugging purpose only
  27343. */
  27344. attributeName: string;
  27345. }
  27346. /**
  27347. * Define options used to create a depth texture
  27348. */
  27349. export class DepthTextureCreationOptions {
  27350. /** Specifies whether or not a stencil should be allocated in the texture */
  27351. generateStencil?: boolean;
  27352. /** Specifies whether or not bilinear filtering is enable on the texture */
  27353. bilinearFiltering?: boolean;
  27354. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27355. comparisonFunction?: number;
  27356. /** Specifies if the created texture is a cube texture */
  27357. isCube?: boolean;
  27358. }
  27359. /**
  27360. * Class used to describe the capabilities of the engine relatively to the current browser
  27361. */
  27362. export class EngineCapabilities {
  27363. /** Maximum textures units per fragment shader */
  27364. maxTexturesImageUnits: number;
  27365. /** Maximum texture units per vertex shader */
  27366. maxVertexTextureImageUnits: number;
  27367. /** Maximum textures units in the entire pipeline */
  27368. maxCombinedTexturesImageUnits: number;
  27369. /** Maximum texture size */
  27370. maxTextureSize: number;
  27371. /** Maximum cube texture size */
  27372. maxCubemapTextureSize: number;
  27373. /** Maximum render texture size */
  27374. maxRenderTextureSize: number;
  27375. /** Maximum number of vertex attributes */
  27376. maxVertexAttribs: number;
  27377. /** Maximum number of varyings */
  27378. maxVaryingVectors: number;
  27379. /** Maximum number of uniforms per vertex shader */
  27380. maxVertexUniformVectors: number;
  27381. /** Maximum number of uniforms per fragment shader */
  27382. maxFragmentUniformVectors: number;
  27383. /** Defines if standard derivates (dx/dy) are supported */
  27384. standardDerivatives: boolean;
  27385. /** Defines if s3tc texture compression is supported */
  27386. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27387. /** Defines if pvrtc texture compression is supported */
  27388. pvrtc: any;
  27389. /** Defines if etc1 texture compression is supported */
  27390. etc1: any;
  27391. /** Defines if etc2 texture compression is supported */
  27392. etc2: any;
  27393. /** Defines if astc texture compression is supported */
  27394. astc: any;
  27395. /** Defines if float textures are supported */
  27396. textureFloat: boolean;
  27397. /** Defines if vertex array objects are supported */
  27398. vertexArrayObject: boolean;
  27399. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27400. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27401. /** Gets the maximum level of anisotropy supported */
  27402. maxAnisotropy: number;
  27403. /** Defines if instancing is supported */
  27404. instancedArrays: boolean;
  27405. /** Defines if 32 bits indices are supported */
  27406. uintIndices: boolean;
  27407. /** Defines if high precision shaders are supported */
  27408. highPrecisionShaderSupported: boolean;
  27409. /** Defines if depth reading in the fragment shader is supported */
  27410. fragmentDepthSupported: boolean;
  27411. /** Defines if float texture linear filtering is supported*/
  27412. textureFloatLinearFiltering: boolean;
  27413. /** Defines if rendering to float textures is supported */
  27414. textureFloatRender: boolean;
  27415. /** Defines if half float textures are supported*/
  27416. textureHalfFloat: boolean;
  27417. /** Defines if half float texture linear filtering is supported*/
  27418. textureHalfFloatLinearFiltering: boolean;
  27419. /** Defines if rendering to half float textures is supported */
  27420. textureHalfFloatRender: boolean;
  27421. /** Defines if textureLOD shader command is supported */
  27422. textureLOD: boolean;
  27423. /** Defines if draw buffers extension is supported */
  27424. drawBuffersExtension: boolean;
  27425. /** Defines if depth textures are supported */
  27426. depthTextureExtension: boolean;
  27427. /** Defines if float color buffer are supported */
  27428. colorBufferFloat: boolean;
  27429. /** Gets disjoint timer query extension (null if not supported) */
  27430. timerQuery: EXT_disjoint_timer_query;
  27431. /** Defines if timestamp can be used with timer query */
  27432. canUseTimestampForTimerQuery: boolean;
  27433. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27434. multiview: any;
  27435. /** Function used to let the system compiles shaders in background */
  27436. parallelShaderCompile: {
  27437. COMPLETION_STATUS_KHR: number;
  27438. };
  27439. }
  27440. /** Interface defining initialization parameters for Engine class */
  27441. export interface EngineOptions extends WebGLContextAttributes {
  27442. /**
  27443. * Defines if the engine should no exceed a specified device ratio
  27444. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27445. */
  27446. limitDeviceRatio?: number;
  27447. /**
  27448. * Defines if webvr should be enabled automatically
  27449. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27450. */
  27451. autoEnableWebVR?: boolean;
  27452. /**
  27453. * Defines if webgl2 should be turned off even if supported
  27454. * @see http://doc.babylonjs.com/features/webgl2
  27455. */
  27456. disableWebGL2Support?: boolean;
  27457. /**
  27458. * Defines if webaudio should be initialized as well
  27459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27460. */
  27461. audioEngine?: boolean;
  27462. /**
  27463. * Defines if animations should run using a deterministic lock step
  27464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27465. */
  27466. deterministicLockstep?: boolean;
  27467. /** Defines the maximum steps to use with deterministic lock step mode */
  27468. lockstepMaxSteps?: number;
  27469. /**
  27470. * Defines that engine should ignore context lost events
  27471. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27472. */
  27473. doNotHandleContextLost?: boolean;
  27474. /**
  27475. * Defines that engine should ignore modifying touch action attribute and style
  27476. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27477. */
  27478. doNotHandleTouchAction?: boolean;
  27479. /**
  27480. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27481. */
  27482. useHighPrecisionFloats?: boolean;
  27483. }
  27484. /**
  27485. * Defines the interface used by display changed events
  27486. */
  27487. export interface IDisplayChangedEventArgs {
  27488. /** Gets the vrDisplay object (if any) */
  27489. vrDisplay: Nullable<any>;
  27490. /** Gets a boolean indicating if webVR is supported */
  27491. vrSupported: boolean;
  27492. }
  27493. /**
  27494. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27495. */
  27496. export class Engine {
  27497. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27498. static ExceptionList: ({
  27499. key: string;
  27500. capture: string;
  27501. captureConstraint: number;
  27502. targets: string[];
  27503. } | {
  27504. key: string;
  27505. capture: null;
  27506. captureConstraint: null;
  27507. targets: string[];
  27508. })[];
  27509. /** Gets the list of created engines */
  27510. static readonly Instances: Engine[];
  27511. /**
  27512. * Gets the latest created engine
  27513. */
  27514. static readonly LastCreatedEngine: Nullable<Engine>;
  27515. /**
  27516. * Gets the latest created scene
  27517. */
  27518. static readonly LastCreatedScene: Nullable<Scene>;
  27519. /**
  27520. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27521. * @param flag defines which part of the materials must be marked as dirty
  27522. * @param predicate defines a predicate used to filter which materials should be affected
  27523. */
  27524. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27525. /** @hidden */
  27526. static _TextureLoaders: IInternalTextureLoader[];
  27527. /** Defines that alpha blending is disabled */
  27528. static readonly ALPHA_DISABLE: number;
  27529. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27530. static readonly ALPHA_ADD: number;
  27531. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27532. static readonly ALPHA_COMBINE: number;
  27533. /** Defines that alpha blending to DEST - SRC * DEST */
  27534. static readonly ALPHA_SUBTRACT: number;
  27535. /** Defines that alpha blending to SRC * DEST */
  27536. static readonly ALPHA_MULTIPLY: number;
  27537. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27538. static readonly ALPHA_MAXIMIZED: number;
  27539. /** Defines that alpha blending to SRC + DEST */
  27540. static readonly ALPHA_ONEONE: number;
  27541. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27542. static readonly ALPHA_PREMULTIPLIED: number;
  27543. /**
  27544. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27545. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27546. */
  27547. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27548. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27549. static readonly ALPHA_INTERPOLATE: number;
  27550. /**
  27551. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27552. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27553. */
  27554. static readonly ALPHA_SCREENMODE: number;
  27555. /** Defines that the ressource is not delayed*/
  27556. static readonly DELAYLOADSTATE_NONE: number;
  27557. /** Defines that the ressource was successfully delay loaded */
  27558. static readonly DELAYLOADSTATE_LOADED: number;
  27559. /** Defines that the ressource is currently delay loading */
  27560. static readonly DELAYLOADSTATE_LOADING: number;
  27561. /** Defines that the ressource is delayed and has not started loading */
  27562. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27563. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27564. static readonly NEVER: number;
  27565. /** 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 */
  27566. static readonly ALWAYS: number;
  27567. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27568. static readonly LESS: number;
  27569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27570. static readonly EQUAL: number;
  27571. /** 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 */
  27572. static readonly LEQUAL: number;
  27573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27574. static readonly GREATER: number;
  27575. /** 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 */
  27576. static readonly GEQUAL: number;
  27577. /** 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 */
  27578. static readonly NOTEQUAL: number;
  27579. /** Passed to stencilOperation to specify that stencil value must be kept */
  27580. static readonly KEEP: number;
  27581. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27582. static readonly REPLACE: number;
  27583. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27584. static readonly INCR: number;
  27585. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27586. static readonly DECR: number;
  27587. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27588. static readonly INVERT: number;
  27589. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27590. static readonly INCR_WRAP: number;
  27591. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27592. static readonly DECR_WRAP: number;
  27593. /** Texture is not repeating outside of 0..1 UVs */
  27594. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27595. /** Texture is repeating outside of 0..1 UVs */
  27596. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27597. /** Texture is repeating and mirrored */
  27598. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27599. /** ALPHA */
  27600. static readonly TEXTUREFORMAT_ALPHA: number;
  27601. /** LUMINANCE */
  27602. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27603. /** LUMINANCE_ALPHA */
  27604. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27605. /** RGB */
  27606. static readonly TEXTUREFORMAT_RGB: number;
  27607. /** RGBA */
  27608. static readonly TEXTUREFORMAT_RGBA: number;
  27609. /** RED */
  27610. static readonly TEXTUREFORMAT_RED: number;
  27611. /** RED (2nd reference) */
  27612. static readonly TEXTUREFORMAT_R: number;
  27613. /** RG */
  27614. static readonly TEXTUREFORMAT_RG: number;
  27615. /** RED_INTEGER */
  27616. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27617. /** RED_INTEGER (2nd reference) */
  27618. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27619. /** RG_INTEGER */
  27620. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27621. /** RGB_INTEGER */
  27622. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27623. /** RGBA_INTEGER */
  27624. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27625. /** UNSIGNED_BYTE */
  27626. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27627. /** UNSIGNED_BYTE (2nd reference) */
  27628. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27629. /** FLOAT */
  27630. static readonly TEXTURETYPE_FLOAT: number;
  27631. /** HALF_FLOAT */
  27632. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27633. /** BYTE */
  27634. static readonly TEXTURETYPE_BYTE: number;
  27635. /** SHORT */
  27636. static readonly TEXTURETYPE_SHORT: number;
  27637. /** UNSIGNED_SHORT */
  27638. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27639. /** INT */
  27640. static readonly TEXTURETYPE_INT: number;
  27641. /** UNSIGNED_INT */
  27642. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27643. /** UNSIGNED_SHORT_4_4_4_4 */
  27644. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27645. /** UNSIGNED_SHORT_5_5_5_1 */
  27646. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27647. /** UNSIGNED_SHORT_5_6_5 */
  27648. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27649. /** UNSIGNED_INT_2_10_10_10_REV */
  27650. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27651. /** UNSIGNED_INT_24_8 */
  27652. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27653. /** UNSIGNED_INT_10F_11F_11F_REV */
  27654. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27655. /** UNSIGNED_INT_5_9_9_9_REV */
  27656. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27657. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27658. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27659. /** nearest is mag = nearest and min = nearest and mip = linear */
  27660. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27661. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27662. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27663. /** Trilinear is mag = linear and min = linear and mip = linear */
  27664. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27665. /** nearest is mag = nearest and min = nearest and mip = linear */
  27666. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27667. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27668. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27669. /** Trilinear is mag = linear and min = linear and mip = linear */
  27670. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27671. /** mag = nearest and min = nearest and mip = nearest */
  27672. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27673. /** mag = nearest and min = linear and mip = nearest */
  27674. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27675. /** mag = nearest and min = linear and mip = linear */
  27676. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27677. /** mag = nearest and min = linear and mip = none */
  27678. static readonly TEXTURE_NEAREST_LINEAR: number;
  27679. /** mag = nearest and min = nearest and mip = none */
  27680. static readonly TEXTURE_NEAREST_NEAREST: number;
  27681. /** mag = linear and min = nearest and mip = nearest */
  27682. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27683. /** mag = linear and min = nearest and mip = linear */
  27684. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27685. /** mag = linear and min = linear and mip = none */
  27686. static readonly TEXTURE_LINEAR_LINEAR: number;
  27687. /** mag = linear and min = nearest and mip = none */
  27688. static readonly TEXTURE_LINEAR_NEAREST: number;
  27689. /** Explicit coordinates mode */
  27690. static readonly TEXTURE_EXPLICIT_MODE: number;
  27691. /** Spherical coordinates mode */
  27692. static readonly TEXTURE_SPHERICAL_MODE: number;
  27693. /** Planar coordinates mode */
  27694. static readonly TEXTURE_PLANAR_MODE: number;
  27695. /** Cubic coordinates mode */
  27696. static readonly TEXTURE_CUBIC_MODE: number;
  27697. /** Projection coordinates mode */
  27698. static readonly TEXTURE_PROJECTION_MODE: number;
  27699. /** Skybox coordinates mode */
  27700. static readonly TEXTURE_SKYBOX_MODE: number;
  27701. /** Inverse Cubic coordinates mode */
  27702. static readonly TEXTURE_INVCUBIC_MODE: number;
  27703. /** Equirectangular coordinates mode */
  27704. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27705. /** Equirectangular Fixed coordinates mode */
  27706. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27707. /** Equirectangular Fixed Mirrored coordinates mode */
  27708. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27709. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27710. static readonly SCALEMODE_FLOOR: number;
  27711. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27712. static readonly SCALEMODE_NEAREST: number;
  27713. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27714. static readonly SCALEMODE_CEILING: number;
  27715. /**
  27716. * Returns the current npm package of the sdk
  27717. */
  27718. static readonly NpmPackage: string;
  27719. /**
  27720. * Returns the current version of the framework
  27721. */
  27722. static readonly Version: string;
  27723. /**
  27724. * Returns a string describing the current engine
  27725. */
  27726. readonly description: string;
  27727. /**
  27728. * Gets or sets the epsilon value used by collision engine
  27729. */
  27730. static CollisionsEpsilon: number;
  27731. /**
  27732. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27733. */
  27734. static ShadersRepository: string;
  27735. /**
  27736. * Method called to create the default loading screen.
  27737. * This can be overriden in your own app.
  27738. * @param canvas The rendering canvas element
  27739. * @returns The loading screen
  27740. */
  27741. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27742. /**
  27743. * Method called to create the default rescale post process on each engine.
  27744. */
  27745. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27746. /** @hidden */
  27747. _shaderProcessor: IShaderProcessor;
  27748. /**
  27749. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27750. */
  27751. forcePOTTextures: boolean;
  27752. /**
  27753. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27754. */
  27755. isFullscreen: boolean;
  27756. /**
  27757. * Gets a boolean indicating if the pointer is currently locked
  27758. */
  27759. isPointerLock: boolean;
  27760. /**
  27761. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27762. */
  27763. cullBackFaces: boolean;
  27764. /**
  27765. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27766. */
  27767. renderEvenInBackground: boolean;
  27768. /**
  27769. * Gets or sets a boolean indicating that cache can be kept between frames
  27770. */
  27771. preventCacheWipeBetweenFrames: boolean;
  27772. /**
  27773. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27774. **/
  27775. enableOfflineSupport: boolean;
  27776. /**
  27777. * 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)
  27778. **/
  27779. disableManifestCheck: boolean;
  27780. /**
  27781. * Gets the list of created scenes
  27782. */
  27783. scenes: Scene[];
  27784. /**
  27785. * Event raised when a new scene is created
  27786. */
  27787. onNewSceneAddedObservable: Observable<Scene>;
  27788. /**
  27789. * Gets the list of created postprocesses
  27790. */
  27791. postProcesses: PostProcess[];
  27792. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27793. validateShaderPrograms: boolean;
  27794. /**
  27795. * Observable event triggered each time the rendering canvas is resized
  27796. */
  27797. onResizeObservable: Observable<Engine>;
  27798. /**
  27799. * Observable event triggered each time the canvas loses focus
  27800. */
  27801. onCanvasBlurObservable: Observable<Engine>;
  27802. /**
  27803. * Observable event triggered each time the canvas gains focus
  27804. */
  27805. onCanvasFocusObservable: Observable<Engine>;
  27806. /**
  27807. * Observable event triggered each time the canvas receives pointerout event
  27808. */
  27809. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27810. /**
  27811. * Observable event triggered before each texture is initialized
  27812. */
  27813. onBeforeTextureInitObservable: Observable<Texture>;
  27814. /**
  27815. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27816. */
  27817. disableUniformBuffers: boolean;
  27818. /** @hidden */
  27819. _uniformBuffers: UniformBuffer[];
  27820. /**
  27821. * Gets a boolean indicating that the engine supports uniform buffers
  27822. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27823. */
  27824. readonly supportsUniformBuffers: boolean;
  27825. /**
  27826. * Observable raised when the engine begins a new frame
  27827. */
  27828. onBeginFrameObservable: Observable<Engine>;
  27829. /**
  27830. * If set, will be used to request the next animation frame for the render loop
  27831. */
  27832. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27833. /**
  27834. * Observable raised when the engine ends the current frame
  27835. */
  27836. onEndFrameObservable: Observable<Engine>;
  27837. /**
  27838. * Observable raised when the engine is about to compile a shader
  27839. */
  27840. onBeforeShaderCompilationObservable: Observable<Engine>;
  27841. /**
  27842. * Observable raised when the engine has jsut compiled a shader
  27843. */
  27844. onAfterShaderCompilationObservable: Observable<Engine>;
  27845. /** @hidden */
  27846. _gl: WebGLRenderingContext;
  27847. private _renderingCanvas;
  27848. private _windowIsBackground;
  27849. private _webGLVersion;
  27850. protected _highPrecisionShadersAllowed: boolean;
  27851. /** @hidden */
  27852. readonly _shouldUseHighPrecisionShader: boolean;
  27853. /**
  27854. * Gets a boolean indicating that only power of 2 textures are supported
  27855. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27856. */
  27857. readonly needPOTTextures: boolean;
  27858. /** @hidden */
  27859. _badOS: boolean;
  27860. /** @hidden */
  27861. _badDesktopOS: boolean;
  27862. /**
  27863. * Gets the audio engine
  27864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27865. * @ignorenaming
  27866. */
  27867. static audioEngine: IAudioEngine;
  27868. /**
  27869. * Default AudioEngine factory responsible of creating the Audio Engine.
  27870. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27871. */
  27872. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27873. /**
  27874. * Default offline support factory responsible of creating a tool used to store data locally.
  27875. * By default, this will create a Database object if the workload has been embedded.
  27876. */
  27877. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27878. private _onFocus;
  27879. private _onBlur;
  27880. private _onCanvasPointerOut;
  27881. private _onCanvasBlur;
  27882. private _onCanvasFocus;
  27883. private _onFullscreenChange;
  27884. private _onPointerLockChange;
  27885. private _hardwareScalingLevel;
  27886. /** @hidden */
  27887. _caps: EngineCapabilities;
  27888. private _pointerLockRequested;
  27889. private _isStencilEnable;
  27890. private _colorWrite;
  27891. private _loadingScreen;
  27892. /** @hidden */
  27893. _drawCalls: PerfCounter;
  27894. private _glVersion;
  27895. private _glRenderer;
  27896. private _glVendor;
  27897. private _videoTextureSupported;
  27898. private _renderingQueueLaunched;
  27899. private _activeRenderLoops;
  27900. private _deterministicLockstep;
  27901. private _lockstepMaxSteps;
  27902. /**
  27903. * Observable signaled when a context lost event is raised
  27904. */
  27905. onContextLostObservable: Observable<Engine>;
  27906. /**
  27907. * Observable signaled when a context restored event is raised
  27908. */
  27909. onContextRestoredObservable: Observable<Engine>;
  27910. private _onContextLost;
  27911. private _onContextRestored;
  27912. private _contextWasLost;
  27913. /** @hidden */
  27914. _doNotHandleContextLost: boolean;
  27915. /**
  27916. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27918. */
  27919. doNotHandleContextLost: boolean;
  27920. private _performanceMonitor;
  27921. private _fps;
  27922. private _deltaTime;
  27923. /**
  27924. * Turn this value on if you want to pause FPS computation when in background
  27925. */
  27926. disablePerformanceMonitorInBackground: boolean;
  27927. /**
  27928. * Gets the performance monitor attached to this engine
  27929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27930. */
  27931. readonly performanceMonitor: PerformanceMonitor;
  27932. /**
  27933. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27934. */
  27935. disableVertexArrayObjects: boolean;
  27936. /** @hidden */
  27937. protected _depthCullingState: _DepthCullingState;
  27938. /** @hidden */
  27939. protected _stencilState: _StencilState;
  27940. /** @hidden */
  27941. protected _alphaState: _AlphaState;
  27942. /** @hidden */
  27943. protected _alphaMode: number;
  27944. /** @hidden */
  27945. _internalTexturesCache: InternalTexture[];
  27946. /** @hidden */
  27947. protected _activeChannel: number;
  27948. private _currentTextureChannel;
  27949. /** @hidden */
  27950. protected _boundTexturesCache: {
  27951. [key: string]: Nullable<InternalTexture>;
  27952. };
  27953. /** @hidden */
  27954. protected _currentEffect: Nullable<Effect>;
  27955. /** @hidden */
  27956. protected _currentProgram: Nullable<WebGLProgram>;
  27957. private _compiledEffects;
  27958. private _vertexAttribArraysEnabled;
  27959. /** @hidden */
  27960. protected _cachedViewport: Nullable<Viewport>;
  27961. private _cachedVertexArrayObject;
  27962. /** @hidden */
  27963. protected _cachedVertexBuffers: any;
  27964. /** @hidden */
  27965. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27966. /** @hidden */
  27967. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27968. /** @hidden */
  27969. _currentRenderTarget: Nullable<InternalTexture>;
  27970. private _uintIndicesCurrentlySet;
  27971. private _currentBoundBuffer;
  27972. /** @hidden */
  27973. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27974. private _currentBufferPointers;
  27975. private _currentInstanceLocations;
  27976. private _currentInstanceBuffers;
  27977. private _textureUnits;
  27978. /** @hidden */
  27979. _workingCanvas: Nullable<HTMLCanvasElement>;
  27980. /** @hidden */
  27981. _workingContext: Nullable<CanvasRenderingContext2D>;
  27982. private _rescalePostProcess;
  27983. private _dummyFramebuffer;
  27984. private _externalData;
  27985. /** @hidden */
  27986. _bindedRenderFunction: any;
  27987. private _vaoRecordInProgress;
  27988. private _mustWipeVertexAttributes;
  27989. private _emptyTexture;
  27990. private _emptyCubeTexture;
  27991. private _emptyTexture3D;
  27992. /** @hidden */
  27993. _frameHandler: number;
  27994. private _nextFreeTextureSlots;
  27995. private _maxSimultaneousTextures;
  27996. private _activeRequests;
  27997. private _texturesSupported;
  27998. /** @hidden */
  27999. _textureFormatInUse: Nullable<string>;
  28000. /**
  28001. * Gets the list of texture formats supported
  28002. */
  28003. readonly texturesSupported: Array<string>;
  28004. /**
  28005. * Gets the list of texture formats in use
  28006. */
  28007. readonly textureFormatInUse: Nullable<string>;
  28008. /**
  28009. * Gets the current viewport
  28010. */
  28011. readonly currentViewport: Nullable<Viewport>;
  28012. /**
  28013. * Gets the default empty texture
  28014. */
  28015. readonly emptyTexture: InternalTexture;
  28016. /**
  28017. * Gets the default empty 3D texture
  28018. */
  28019. readonly emptyTexture3D: InternalTexture;
  28020. /**
  28021. * Gets the default empty cube texture
  28022. */
  28023. readonly emptyCubeTexture: InternalTexture;
  28024. /**
  28025. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28026. */
  28027. readonly premultipliedAlpha: boolean;
  28028. /**
  28029. * Creates a new engine
  28030. * @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
  28031. * @param antialias defines enable antialiasing (default: false)
  28032. * @param options defines further options to be sent to the getContext() function
  28033. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28034. */
  28035. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28036. /**
  28037. * Initializes a webVR display and starts listening to display change events
  28038. * The onVRDisplayChangedObservable will be notified upon these changes
  28039. * @returns The onVRDisplayChangedObservable
  28040. */
  28041. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28042. /** @hidden */
  28043. _prepareVRComponent(): void;
  28044. /** @hidden */
  28045. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28046. /** @hidden */
  28047. _submitVRFrame(): void;
  28048. /**
  28049. * Call this function to leave webVR mode
  28050. * Will do nothing if webVR is not supported or if there is no webVR device
  28051. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28052. */
  28053. disableVR(): void;
  28054. /**
  28055. * Gets a boolean indicating that the system is in VR mode and is presenting
  28056. * @returns true if VR mode is engaged
  28057. */
  28058. isVRPresenting(): boolean;
  28059. /** @hidden */
  28060. _requestVRFrame(): void;
  28061. private _disableTouchAction;
  28062. private _rebuildInternalTextures;
  28063. private _rebuildEffects;
  28064. /**
  28065. * Gets a boolean indicating if all created effects are ready
  28066. * @returns true if all effects are ready
  28067. */
  28068. areAllEffectsReady(): boolean;
  28069. private _rebuildBuffers;
  28070. private _initGLContext;
  28071. /**
  28072. * Gets version of the current webGL context
  28073. */
  28074. readonly webGLVersion: number;
  28075. /**
  28076. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28077. */
  28078. readonly isStencilEnable: boolean;
  28079. /** @hidden */
  28080. _prepareWorkingCanvas(): void;
  28081. /**
  28082. * Reset the texture cache to empty state
  28083. */
  28084. resetTextureCache(): void;
  28085. /**
  28086. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28088. * @returns true if engine is in deterministic lock step mode
  28089. */
  28090. isDeterministicLockStep(): boolean;
  28091. /**
  28092. * Gets the max steps when engine is running in deterministic lock step
  28093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28094. * @returns the max steps
  28095. */
  28096. getLockstepMaxSteps(): number;
  28097. /**
  28098. * Gets an object containing information about the current webGL context
  28099. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28100. */
  28101. getGlInfo(): {
  28102. vendor: string;
  28103. renderer: string;
  28104. version: string;
  28105. };
  28106. /**
  28107. * Gets current aspect ratio
  28108. * @param camera defines the camera to use to get the aspect ratio
  28109. * @param useScreen defines if screen size must be used (or the current render target if any)
  28110. * @returns a number defining the aspect ratio
  28111. */
  28112. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28113. /**
  28114. * Gets current screen aspect ratio
  28115. * @returns a number defining the aspect ratio
  28116. */
  28117. getScreenAspectRatio(): number;
  28118. /**
  28119. * Gets the current render width
  28120. * @param useScreen defines if screen size must be used (or the current render target if any)
  28121. * @returns a number defining the current render width
  28122. */
  28123. getRenderWidth(useScreen?: boolean): number;
  28124. /**
  28125. * Gets the current render height
  28126. * @param useScreen defines if screen size must be used (or the current render target if any)
  28127. * @returns a number defining the current render height
  28128. */
  28129. getRenderHeight(useScreen?: boolean): number;
  28130. /**
  28131. * Gets the HTML canvas attached with the current webGL context
  28132. * @returns a HTML canvas
  28133. */
  28134. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28135. /**
  28136. * Gets the client rect of the HTML canvas attached with the current webGL context
  28137. * @returns a client rectanglee
  28138. */
  28139. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28140. /**
  28141. * Defines the hardware scaling level.
  28142. * By default the hardware scaling level is computed from the window device ratio.
  28143. * 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.
  28144. * @param level defines the level to use
  28145. */
  28146. setHardwareScalingLevel(level: number): void;
  28147. /**
  28148. * Gets the current hardware scaling level.
  28149. * By default the hardware scaling level is computed from the window device ratio.
  28150. * 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.
  28151. * @returns a number indicating the current hardware scaling level
  28152. */
  28153. getHardwareScalingLevel(): number;
  28154. /**
  28155. * Gets the list of loaded textures
  28156. * @returns an array containing all loaded textures
  28157. */
  28158. getLoadedTexturesCache(): InternalTexture[];
  28159. /**
  28160. * Gets the object containing all engine capabilities
  28161. * @returns the EngineCapabilities object
  28162. */
  28163. getCaps(): EngineCapabilities;
  28164. /**
  28165. * Gets the current depth function
  28166. * @returns a number defining the depth function
  28167. */
  28168. getDepthFunction(): Nullable<number>;
  28169. /**
  28170. * Sets the current depth function
  28171. * @param depthFunc defines the function to use
  28172. */
  28173. setDepthFunction(depthFunc: number): void;
  28174. /**
  28175. * Sets the current depth function to GREATER
  28176. */
  28177. setDepthFunctionToGreater(): void;
  28178. /**
  28179. * Sets the current depth function to GEQUAL
  28180. */
  28181. setDepthFunctionToGreaterOrEqual(): void;
  28182. /**
  28183. * Sets the current depth function to LESS
  28184. */
  28185. setDepthFunctionToLess(): void;
  28186. private _cachedStencilBuffer;
  28187. private _cachedStencilFunction;
  28188. private _cachedStencilMask;
  28189. private _cachedStencilOperationPass;
  28190. private _cachedStencilOperationFail;
  28191. private _cachedStencilOperationDepthFail;
  28192. private _cachedStencilReference;
  28193. /**
  28194. * Caches the the state of the stencil buffer
  28195. */
  28196. cacheStencilState(): void;
  28197. /**
  28198. * Restores the state of the stencil buffer
  28199. */
  28200. restoreStencilState(): void;
  28201. /**
  28202. * Sets the current depth function to LEQUAL
  28203. */
  28204. setDepthFunctionToLessOrEqual(): void;
  28205. /**
  28206. * Gets a boolean indicating if stencil buffer is enabled
  28207. * @returns the current stencil buffer state
  28208. */
  28209. getStencilBuffer(): boolean;
  28210. /**
  28211. * Enable or disable the stencil buffer
  28212. * @param enable defines if the stencil buffer must be enabled or disabled
  28213. */
  28214. setStencilBuffer(enable: boolean): void;
  28215. /**
  28216. * Gets the current stencil mask
  28217. * @returns a number defining the new stencil mask to use
  28218. */
  28219. getStencilMask(): number;
  28220. /**
  28221. * Sets the current stencil mask
  28222. * @param mask defines the new stencil mask to use
  28223. */
  28224. setStencilMask(mask: number): void;
  28225. /**
  28226. * Gets the current stencil function
  28227. * @returns a number defining the stencil function to use
  28228. */
  28229. getStencilFunction(): number;
  28230. /**
  28231. * Gets the current stencil reference value
  28232. * @returns a number defining the stencil reference value to use
  28233. */
  28234. getStencilFunctionReference(): number;
  28235. /**
  28236. * Gets the current stencil mask
  28237. * @returns a number defining the stencil mask to use
  28238. */
  28239. getStencilFunctionMask(): number;
  28240. /**
  28241. * Sets the current stencil function
  28242. * @param stencilFunc defines the new stencil function to use
  28243. */
  28244. setStencilFunction(stencilFunc: number): void;
  28245. /**
  28246. * Sets the current stencil reference
  28247. * @param reference defines the new stencil reference to use
  28248. */
  28249. setStencilFunctionReference(reference: number): void;
  28250. /**
  28251. * Sets the current stencil mask
  28252. * @param mask defines the new stencil mask to use
  28253. */
  28254. setStencilFunctionMask(mask: number): void;
  28255. /**
  28256. * Gets the current stencil operation when stencil fails
  28257. * @returns a number defining stencil operation to use when stencil fails
  28258. */
  28259. getStencilOperationFail(): number;
  28260. /**
  28261. * Gets the current stencil operation when depth fails
  28262. * @returns a number defining stencil operation to use when depth fails
  28263. */
  28264. getStencilOperationDepthFail(): number;
  28265. /**
  28266. * Gets the current stencil operation when stencil passes
  28267. * @returns a number defining stencil operation to use when stencil passes
  28268. */
  28269. getStencilOperationPass(): number;
  28270. /**
  28271. * Sets the stencil operation to use when stencil fails
  28272. * @param operation defines the stencil operation to use when stencil fails
  28273. */
  28274. setStencilOperationFail(operation: number): void;
  28275. /**
  28276. * Sets the stencil operation to use when depth fails
  28277. * @param operation defines the stencil operation to use when depth fails
  28278. */
  28279. setStencilOperationDepthFail(operation: number): void;
  28280. /**
  28281. * Sets the stencil operation to use when stencil passes
  28282. * @param operation defines the stencil operation to use when stencil passes
  28283. */
  28284. setStencilOperationPass(operation: number): void;
  28285. /**
  28286. * Sets a boolean indicating if the dithering state is enabled or disabled
  28287. * @param value defines the dithering state
  28288. */
  28289. setDitheringState(value: boolean): void;
  28290. /**
  28291. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28292. * @param value defines the rasterizer state
  28293. */
  28294. setRasterizerState(value: boolean): void;
  28295. /**
  28296. * stop executing a render loop function and remove it from the execution array
  28297. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28298. */
  28299. stopRenderLoop(renderFunction?: () => void): void;
  28300. /** @hidden */
  28301. _renderLoop(): void;
  28302. /**
  28303. * Register and execute a render loop. The engine can have more than one render function
  28304. * @param renderFunction defines the function to continuously execute
  28305. */
  28306. runRenderLoop(renderFunction: () => void): void;
  28307. /**
  28308. * Toggle full screen mode
  28309. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28310. */
  28311. switchFullscreen(requestPointerLock: boolean): void;
  28312. /**
  28313. * Enters full screen mode
  28314. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28315. */
  28316. enterFullscreen(requestPointerLock: boolean): void;
  28317. /**
  28318. * Exits full screen mode
  28319. */
  28320. exitFullscreen(): void;
  28321. /**
  28322. * Enters Pointerlock mode
  28323. */
  28324. enterPointerlock(): void;
  28325. /**
  28326. * Exits Pointerlock mode
  28327. */
  28328. exitPointerlock(): void;
  28329. /**
  28330. * Clear the current render buffer or the current render target (if any is set up)
  28331. * @param color defines the color to use
  28332. * @param backBuffer defines if the back buffer must be cleared
  28333. * @param depth defines if the depth buffer must be cleared
  28334. * @param stencil defines if the stencil buffer must be cleared
  28335. */
  28336. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28337. /**
  28338. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28339. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28340. * @param y defines the y-coordinate of the corner of the clear rectangle
  28341. * @param width defines the width of the clear rectangle
  28342. * @param height defines the height of the clear rectangle
  28343. * @param clearColor defines the clear color
  28344. */
  28345. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28346. /**
  28347. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28348. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28349. * @param y defines the y-coordinate of the corner of the clear rectangle
  28350. * @param width defines the width of the clear rectangle
  28351. * @param height defines the height of the clear rectangle
  28352. */
  28353. enableScissor(x: number, y: number, width: number, height: number): void;
  28354. /**
  28355. * Disable previously set scissor test rectangle
  28356. */
  28357. disableScissor(): void;
  28358. private _viewportCached;
  28359. /** @hidden */
  28360. _viewport(x: number, y: number, width: number, height: number): void;
  28361. /**
  28362. * Set the WebGL's viewport
  28363. * @param viewport defines the viewport element to be used
  28364. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28365. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28366. */
  28367. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28368. /**
  28369. * Directly set the WebGL Viewport
  28370. * @param x defines the x coordinate of the viewport (in screen space)
  28371. * @param y defines the y coordinate of the viewport (in screen space)
  28372. * @param width defines the width of the viewport (in screen space)
  28373. * @param height defines the height of the viewport (in screen space)
  28374. * @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
  28375. */
  28376. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28377. /**
  28378. * Begin a new frame
  28379. */
  28380. beginFrame(): void;
  28381. /**
  28382. * Enf the current frame
  28383. */
  28384. endFrame(): void;
  28385. /**
  28386. * Resize the view according to the canvas' size
  28387. */
  28388. resize(): void;
  28389. /**
  28390. * Force a specific size of the canvas
  28391. * @param width defines the new canvas' width
  28392. * @param height defines the new canvas' height
  28393. */
  28394. setSize(width: number, height: number): void;
  28395. /**
  28396. * Binds the frame buffer to the specified texture.
  28397. * @param texture The texture to render to or null for the default canvas
  28398. * @param faceIndex The face of the texture to render to in case of cube texture
  28399. * @param requiredWidth The width of the target to render to
  28400. * @param requiredHeight The height of the target to render to
  28401. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28402. * @param depthStencilTexture The depth stencil texture to use to render
  28403. * @param lodLevel defines le lod level to bind to the frame buffer
  28404. */
  28405. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28406. /** @hidden */
  28407. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28408. /**
  28409. * Unbind the current render target texture from the webGL context
  28410. * @param texture defines the render target texture to unbind
  28411. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28412. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28413. */
  28414. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28415. /**
  28416. * Force the mipmap generation for the given render target texture
  28417. * @param texture defines the render target texture to use
  28418. */
  28419. generateMipMapsForCubemap(texture: InternalTexture): void;
  28420. /**
  28421. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28422. */
  28423. flushFramebuffer(): void;
  28424. /**
  28425. * Unbind the current render target and bind the default framebuffer
  28426. */
  28427. restoreDefaultFramebuffer(): void;
  28428. /**
  28429. * Create an uniform buffer
  28430. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28431. * @param elements defines the content of the uniform buffer
  28432. * @returns the webGL uniform buffer
  28433. */
  28434. createUniformBuffer(elements: FloatArray): DataBuffer;
  28435. /**
  28436. * Create a dynamic uniform buffer
  28437. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28438. * @param elements defines the content of the uniform buffer
  28439. * @returns the webGL uniform buffer
  28440. */
  28441. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28442. /**
  28443. * Update an existing uniform buffer
  28444. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28445. * @param uniformBuffer defines the target uniform buffer
  28446. * @param elements defines the content to update
  28447. * @param offset defines the offset in the uniform buffer where update should start
  28448. * @param count defines the size of the data to update
  28449. */
  28450. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28451. private _resetVertexBufferBinding;
  28452. /**
  28453. * Creates a vertex buffer
  28454. * @param data the data for the vertex buffer
  28455. * @returns the new WebGL static buffer
  28456. */
  28457. createVertexBuffer(data: DataArray): DataBuffer;
  28458. /**
  28459. * Creates a dynamic vertex buffer
  28460. * @param data the data for the dynamic vertex buffer
  28461. * @returns the new WebGL dynamic buffer
  28462. */
  28463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28464. /**
  28465. * Update a dynamic index buffer
  28466. * @param indexBuffer defines the target index buffer
  28467. * @param indices defines the data to update
  28468. * @param offset defines the offset in the target index buffer where update should start
  28469. */
  28470. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28471. /**
  28472. * Updates a dynamic vertex buffer.
  28473. * @param vertexBuffer the vertex buffer to update
  28474. * @param data the data used to update the vertex buffer
  28475. * @param byteOffset the byte offset of the data
  28476. * @param byteLength the byte length of the data
  28477. */
  28478. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28479. private _resetIndexBufferBinding;
  28480. /**
  28481. * Creates a new index buffer
  28482. * @param indices defines the content of the index buffer
  28483. * @param updatable defines if the index buffer must be updatable
  28484. * @returns a new webGL buffer
  28485. */
  28486. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28487. /**
  28488. * Bind a webGL buffer to the webGL context
  28489. * @param buffer defines the buffer to bind
  28490. */
  28491. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28492. /**
  28493. * Bind an uniform buffer to the current webGL context
  28494. * @param buffer defines the buffer to bind
  28495. */
  28496. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28497. /**
  28498. * Bind a buffer to the current webGL context at a given location
  28499. * @param buffer defines the buffer to bind
  28500. * @param location defines the index where to bind the buffer
  28501. */
  28502. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28503. /**
  28504. * Bind a specific block at a given index in a specific shader program
  28505. * @param pipelineContext defines the pipeline context to use
  28506. * @param blockName defines the block name
  28507. * @param index defines the index where to bind the block
  28508. */
  28509. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28510. private bindIndexBuffer;
  28511. private bindBuffer;
  28512. /**
  28513. * update the bound buffer with the given data
  28514. * @param data defines the data to update
  28515. */
  28516. updateArrayBuffer(data: Float32Array): void;
  28517. private _vertexAttribPointer;
  28518. private _bindIndexBufferWithCache;
  28519. private _bindVertexBuffersAttributes;
  28520. /**
  28521. * Records a vertex array object
  28522. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28523. * @param vertexBuffers defines the list of vertex buffers to store
  28524. * @param indexBuffer defines the index buffer to store
  28525. * @param effect defines the effect to store
  28526. * @returns the new vertex array object
  28527. */
  28528. recordVertexArrayObject(vertexBuffers: {
  28529. [key: string]: VertexBuffer;
  28530. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28531. /**
  28532. * Bind a specific vertex array object
  28533. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28534. * @param vertexArrayObject defines the vertex array object to bind
  28535. * @param indexBuffer defines the index buffer to bind
  28536. */
  28537. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28538. /**
  28539. * Bind webGl buffers directly to the webGL context
  28540. * @param vertexBuffer defines the vertex buffer to bind
  28541. * @param indexBuffer defines the index buffer to bind
  28542. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28543. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28544. * @param effect defines the effect associated with the vertex buffer
  28545. */
  28546. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28547. private _unbindVertexArrayObject;
  28548. /**
  28549. * Bind a list of vertex buffers to the webGL context
  28550. * @param vertexBuffers defines the list of vertex buffers to bind
  28551. * @param indexBuffer defines the index buffer to bind
  28552. * @param effect defines the effect associated with the vertex buffers
  28553. */
  28554. bindBuffers(vertexBuffers: {
  28555. [key: string]: Nullable<VertexBuffer>;
  28556. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28557. /**
  28558. * Unbind all instance attributes
  28559. */
  28560. unbindInstanceAttributes(): void;
  28561. /**
  28562. * Release and free the memory of a vertex array object
  28563. * @param vao defines the vertex array object to delete
  28564. */
  28565. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28566. /** @hidden */
  28567. _releaseBuffer(buffer: DataBuffer): boolean;
  28568. /**
  28569. * Creates a webGL buffer to use with instanciation
  28570. * @param capacity defines the size of the buffer
  28571. * @returns the webGL buffer
  28572. */
  28573. createInstancesBuffer(capacity: number): DataBuffer;
  28574. /**
  28575. * Delete a webGL buffer used with instanciation
  28576. * @param buffer defines the webGL buffer to delete
  28577. */
  28578. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28579. /**
  28580. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28581. * @param instancesBuffer defines the webGL buffer to update and bind
  28582. * @param data defines the data to store in the buffer
  28583. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28584. */
  28585. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28586. /**
  28587. * Apply all cached states (depth, culling, stencil and alpha)
  28588. */
  28589. applyStates(): void;
  28590. /**
  28591. * Send a draw order
  28592. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28593. * @param indexStart defines the starting index
  28594. * @param indexCount defines the number of index to draw
  28595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28596. */
  28597. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28598. /**
  28599. * Draw a list of points
  28600. * @param verticesStart defines the index of first vertex to draw
  28601. * @param verticesCount defines the count of vertices to draw
  28602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28603. */
  28604. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28605. /**
  28606. * Draw a list of unindexed primitives
  28607. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28608. * @param verticesStart defines the index of first vertex to draw
  28609. * @param verticesCount defines the count of vertices to draw
  28610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28611. */
  28612. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28613. /**
  28614. * Draw a list of indexed primitives
  28615. * @param fillMode defines the primitive to use
  28616. * @param indexStart defines the starting index
  28617. * @param indexCount defines the number of index to draw
  28618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28619. */
  28620. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28621. /**
  28622. * Draw a list of unindexed primitives
  28623. * @param fillMode defines the primitive to use
  28624. * @param verticesStart defines the index of first vertex to draw
  28625. * @param verticesCount defines the count of vertices to draw
  28626. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28627. */
  28628. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28629. private _drawMode;
  28630. /** @hidden */
  28631. _releaseEffect(effect: Effect): void;
  28632. /** @hidden */
  28633. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28634. /**
  28635. * Create a new effect (used to store vertex/fragment shaders)
  28636. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28637. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28638. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28639. * @param samplers defines an array of string used to represent textures
  28640. * @param defines defines the string containing the defines to use to compile the shaders
  28641. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28642. * @param onCompiled defines a function to call when the effect creation is successful
  28643. * @param onError defines a function to call when the effect creation has failed
  28644. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28645. * @returns the new Effect
  28646. */
  28647. 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;
  28648. private _compileShader;
  28649. private _compileRawShader;
  28650. /**
  28651. * Directly creates a webGL program
  28652. * @param pipelineContext defines the pipeline context to attach to
  28653. * @param vertexCode defines the vertex shader code to use
  28654. * @param fragmentCode defines the fragment shader code to use
  28655. * @param context defines the webGL context to use (if not set, the current one will be used)
  28656. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28657. * @returns the new webGL program
  28658. */
  28659. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28660. /**
  28661. * Creates a webGL program
  28662. * @param pipelineContext defines the pipeline context to attach to
  28663. * @param vertexCode defines the vertex shader code to use
  28664. * @param fragmentCode defines the fragment shader code to use
  28665. * @param defines defines the string containing the defines to use to compile the shaders
  28666. * @param context defines the webGL context to use (if not set, the current one will be used)
  28667. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28668. * @returns the new webGL program
  28669. */
  28670. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28671. /**
  28672. * Creates a new pipeline context
  28673. * @returns the new pipeline
  28674. */
  28675. createPipelineContext(): WebGLPipelineContext;
  28676. private _createShaderProgram;
  28677. private _finalizePipelineContext;
  28678. /** @hidden */
  28679. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28680. /** @hidden */
  28681. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28682. /** @hidden */
  28683. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28684. /**
  28685. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28686. * @param pipelineContext defines the pipeline context to use
  28687. * @param uniformsNames defines the list of uniform names
  28688. * @returns an array of webGL uniform locations
  28689. */
  28690. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28691. /**
  28692. * Gets the lsit of active attributes for a given webGL program
  28693. * @param pipelineContext defines the pipeline context to use
  28694. * @param attributesNames defines the list of attribute names to get
  28695. * @returns an array of indices indicating the offset of each attribute
  28696. */
  28697. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28698. /**
  28699. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28700. * @param effect defines the effect to activate
  28701. */
  28702. enableEffect(effect: Nullable<Effect>): void;
  28703. /**
  28704. * Set the value of an uniform to an array of int32
  28705. * @param uniform defines the webGL uniform location where to store the value
  28706. * @param array defines the array of int32 to store
  28707. */
  28708. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28709. /**
  28710. * Set the value of an uniform to an array of int32 (stored as vec2)
  28711. * @param uniform defines the webGL uniform location where to store the value
  28712. * @param array defines the array of int32 to store
  28713. */
  28714. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28715. /**
  28716. * Set the value of an uniform to an array of int32 (stored as vec3)
  28717. * @param uniform defines the webGL uniform location where to store the value
  28718. * @param array defines the array of int32 to store
  28719. */
  28720. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28721. /**
  28722. * Set the value of an uniform to an array of int32 (stored as vec4)
  28723. * @param uniform defines the webGL uniform location where to store the value
  28724. * @param array defines the array of int32 to store
  28725. */
  28726. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28727. /**
  28728. * Set the value of an uniform to an array of float32
  28729. * @param uniform defines the webGL uniform location where to store the value
  28730. * @param array defines the array of float32 to store
  28731. */
  28732. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28733. /**
  28734. * Set the value of an uniform to an array of float32 (stored as vec2)
  28735. * @param uniform defines the webGL uniform location where to store the value
  28736. * @param array defines the array of float32 to store
  28737. */
  28738. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28739. /**
  28740. * Set the value of an uniform to an array of float32 (stored as vec3)
  28741. * @param uniform defines the webGL uniform location where to store the value
  28742. * @param array defines the array of float32 to store
  28743. */
  28744. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28745. /**
  28746. * Set the value of an uniform to an array of float32 (stored as vec4)
  28747. * @param uniform defines the webGL uniform location where to store the value
  28748. * @param array defines the array of float32 to store
  28749. */
  28750. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28751. /**
  28752. * Set the value of an uniform to an array of number
  28753. * @param uniform defines the webGL uniform location where to store the value
  28754. * @param array defines the array of number to store
  28755. */
  28756. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28757. /**
  28758. * Set the value of an uniform to an array of number (stored as vec2)
  28759. * @param uniform defines the webGL uniform location where to store the value
  28760. * @param array defines the array of number to store
  28761. */
  28762. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28763. /**
  28764. * Set the value of an uniform to an array of number (stored as vec3)
  28765. * @param uniform defines the webGL uniform location where to store the value
  28766. * @param array defines the array of number to store
  28767. */
  28768. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28769. /**
  28770. * Set the value of an uniform to an array of number (stored as vec4)
  28771. * @param uniform defines the webGL uniform location where to store the value
  28772. * @param array defines the array of number to store
  28773. */
  28774. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28775. /**
  28776. * Set the value of an uniform to an array of float32 (stored as matrices)
  28777. * @param uniform defines the webGL uniform location where to store the value
  28778. * @param matrices defines the array of float32 to store
  28779. */
  28780. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28781. /**
  28782. * Set the value of an uniform to a matrix
  28783. * @param uniform defines the webGL uniform location where to store the value
  28784. * @param matrix defines the matrix to store
  28785. */
  28786. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28787. /**
  28788. * Set the value of an uniform to a matrix (3x3)
  28789. * @param uniform defines the webGL uniform location where to store the value
  28790. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28791. */
  28792. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28793. /**
  28794. * Set the value of an uniform to a matrix (2x2)
  28795. * @param uniform defines the webGL uniform location where to store the value
  28796. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28797. */
  28798. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28799. /**
  28800. * Set the value of an uniform to a number (int)
  28801. * @param uniform defines the webGL uniform location where to store the value
  28802. * @param value defines the int number to store
  28803. */
  28804. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28805. /**
  28806. * Set the value of an uniform to a number (float)
  28807. * @param uniform defines the webGL uniform location where to store the value
  28808. * @param value defines the float number to store
  28809. */
  28810. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28811. /**
  28812. * Set the value of an uniform to a vec2
  28813. * @param uniform defines the webGL uniform location where to store the value
  28814. * @param x defines the 1st component of the value
  28815. * @param y defines the 2nd component of the value
  28816. */
  28817. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28818. /**
  28819. * Set the value of an uniform to a vec3
  28820. * @param uniform defines the webGL uniform location where to store the value
  28821. * @param x defines the 1st component of the value
  28822. * @param y defines the 2nd component of the value
  28823. * @param z defines the 3rd component of the value
  28824. */
  28825. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28826. /**
  28827. * Set the value of an uniform to a boolean
  28828. * @param uniform defines the webGL uniform location where to store the value
  28829. * @param bool defines the boolean to store
  28830. */
  28831. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28832. /**
  28833. * Set the value of an uniform to a vec4
  28834. * @param uniform defines the webGL uniform location where to store the value
  28835. * @param x defines the 1st component of the value
  28836. * @param y defines the 2nd component of the value
  28837. * @param z defines the 3rd component of the value
  28838. * @param w defines the 4th component of the value
  28839. */
  28840. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28841. /**
  28842. * Set the value of an uniform to a Color3
  28843. * @param uniform defines the webGL uniform location where to store the value
  28844. * @param color3 defines the color to store
  28845. */
  28846. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28847. /**
  28848. * Set the value of an uniform to a Color3 and an alpha value
  28849. * @param uniform defines the webGL uniform location where to store the value
  28850. * @param color3 defines the color to store
  28851. * @param alpha defines the alpha component to store
  28852. */
  28853. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28854. /**
  28855. * Sets a Color4 on a uniform variable
  28856. * @param uniform defines the uniform location
  28857. * @param color4 defines the value to be set
  28858. */
  28859. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28860. /**
  28861. * Set various states to the webGL context
  28862. * @param culling defines backface culling state
  28863. * @param zOffset defines the value to apply to zOffset (0 by default)
  28864. * @param force defines if states must be applied even if cache is up to date
  28865. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28866. */
  28867. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28868. /**
  28869. * Set the z offset to apply to current rendering
  28870. * @param value defines the offset to apply
  28871. */
  28872. setZOffset(value: number): void;
  28873. /**
  28874. * Gets the current value of the zOffset
  28875. * @returns the current zOffset state
  28876. */
  28877. getZOffset(): number;
  28878. /**
  28879. * Enable or disable depth buffering
  28880. * @param enable defines the state to set
  28881. */
  28882. setDepthBuffer(enable: boolean): void;
  28883. /**
  28884. * Gets a boolean indicating if depth writing is enabled
  28885. * @returns the current depth writing state
  28886. */
  28887. getDepthWrite(): boolean;
  28888. /**
  28889. * Enable or disable depth writing
  28890. * @param enable defines the state to set
  28891. */
  28892. setDepthWrite(enable: boolean): void;
  28893. /**
  28894. * Enable or disable color writing
  28895. * @param enable defines the state to set
  28896. */
  28897. setColorWrite(enable: boolean): void;
  28898. /**
  28899. * Gets a boolean indicating if color writing is enabled
  28900. * @returns the current color writing state
  28901. */
  28902. getColorWrite(): boolean;
  28903. /**
  28904. * Sets alpha constants used by some alpha blending modes
  28905. * @param r defines the red component
  28906. * @param g defines the green component
  28907. * @param b defines the blue component
  28908. * @param a defines the alpha component
  28909. */
  28910. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28911. /**
  28912. * Sets the current alpha mode
  28913. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28914. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28916. */
  28917. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28918. /**
  28919. * Gets the current alpha mode
  28920. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28921. * @returns the current alpha mode
  28922. */
  28923. getAlphaMode(): number;
  28924. /**
  28925. * Clears the list of texture accessible through engine.
  28926. * This can help preventing texture load conflict due to name collision.
  28927. */
  28928. clearInternalTexturesCache(): void;
  28929. /**
  28930. * Force the entire cache to be cleared
  28931. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28932. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28933. */
  28934. wipeCaches(bruteForce?: boolean): void;
  28935. /**
  28936. * Set the compressed texture format to use, based on the formats you have, and the formats
  28937. * supported by the hardware / browser.
  28938. *
  28939. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28940. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28941. * to API arguments needed to compressed textures. This puts the burden on the container
  28942. * generator to house the arcane code for determining these for current & future formats.
  28943. *
  28944. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28945. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28946. *
  28947. * Note: The result of this call is not taken into account when a texture is base64.
  28948. *
  28949. * @param formatsAvailable defines the list of those format families you have created
  28950. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28951. *
  28952. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28953. * @returns The extension selected.
  28954. */
  28955. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28956. /** @hidden */
  28957. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28958. min: number;
  28959. mag: number;
  28960. };
  28961. /** @hidden */
  28962. _createTexture(): WebGLTexture;
  28963. /**
  28964. * Usually called from Texture.ts.
  28965. * Passed information to create a WebGLTexture
  28966. * @param urlArg defines a value which contains one of the following:
  28967. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28968. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28969. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28970. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28971. * @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)
  28972. * @param scene needed for loading to the correct scene
  28973. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28974. * @param onLoad optional callback to be called upon successful completion
  28975. * @param onError optional callback to be called upon failure
  28976. * @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
  28977. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28978. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28979. * @param forcedExtension defines the extension to use to pick the right loader
  28980. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28981. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28982. */
  28983. 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;
  28984. /**
  28985. * @hidden
  28986. * Rescales a texture
  28987. * @param source input texutre
  28988. * @param destination destination texture
  28989. * @param scene scene to use to render the resize
  28990. * @param internalFormat format to use when resizing
  28991. * @param onComplete callback to be called when resize has completed
  28992. */
  28993. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28994. private _unpackFlipYCached;
  28995. /**
  28996. * In case you are sharing the context with other applications, it might
  28997. * be interested to not cache the unpack flip y state to ensure a consistent
  28998. * value would be set.
  28999. */
  29000. enableUnpackFlipYCached: boolean;
  29001. /** @hidden */
  29002. _unpackFlipY(value: boolean): void;
  29003. /** @hidden */
  29004. _getUnpackAlignement(): number;
  29005. /**
  29006. * Creates a dynamic texture
  29007. * @param width defines the width of the texture
  29008. * @param height defines the height of the texture
  29009. * @param generateMipMaps defines if the engine should generate the mip levels
  29010. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29011. * @returns the dynamic texture inside an InternalTexture
  29012. */
  29013. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29014. /**
  29015. * Update the sampling mode of a given texture
  29016. * @param samplingMode defines the required sampling mode
  29017. * @param texture defines the texture to update
  29018. */
  29019. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29020. /**
  29021. * Update the content of a dynamic texture
  29022. * @param texture defines the texture to update
  29023. * @param canvas defines the canvas containing the source
  29024. * @param invertY defines if data must be stored with Y axis inverted
  29025. * @param premulAlpha defines if alpha is stored as premultiplied
  29026. * @param format defines the format of the data
  29027. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29028. */
  29029. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29030. /**
  29031. * Update a video texture
  29032. * @param texture defines the texture to update
  29033. * @param video defines the video element to use
  29034. * @param invertY defines if data must be stored with Y axis inverted
  29035. */
  29036. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29037. /**
  29038. * Updates a depth texture Comparison Mode and Function.
  29039. * If the comparison Function is equal to 0, the mode will be set to none.
  29040. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29041. * @param texture The texture to set the comparison function for
  29042. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29043. */
  29044. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29045. /** @hidden */
  29046. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29047. width: number;
  29048. height: number;
  29049. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29050. /**
  29051. * Creates a depth stencil texture.
  29052. * This is only available in WebGL 2 or with the depth texture extension available.
  29053. * @param size The size of face edge in the texture.
  29054. * @param options The options defining the texture.
  29055. * @returns The texture
  29056. */
  29057. createDepthStencilTexture(size: number | {
  29058. width: number;
  29059. height: number;
  29060. }, options: DepthTextureCreationOptions): InternalTexture;
  29061. /**
  29062. * Creates a depth stencil texture.
  29063. * This is only available in WebGL 2 or with the depth texture extension available.
  29064. * @param size The size of face edge in the texture.
  29065. * @param options The options defining the texture.
  29066. * @returns The texture
  29067. */
  29068. private _createDepthStencilTexture;
  29069. /**
  29070. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29071. * @param renderTarget The render target to set the frame buffer for
  29072. */
  29073. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29074. /**
  29075. * Creates a new render target texture
  29076. * @param size defines the size of the texture
  29077. * @param options defines the options used to create the texture
  29078. * @returns a new render target texture stored in an InternalTexture
  29079. */
  29080. createRenderTargetTexture(size: number | {
  29081. width: number;
  29082. height: number;
  29083. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29084. /** @hidden */
  29085. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29086. /**
  29087. * Updates the sample count of a render target texture
  29088. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29089. * @param texture defines the texture to update
  29090. * @param samples defines the sample count to set
  29091. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29092. */
  29093. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29094. /** @hidden */
  29095. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29096. /** @hidden */
  29097. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29098. /** @hidden */
  29099. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29100. /** @hidden */
  29101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29102. /**
  29103. * @hidden
  29104. */
  29105. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29106. private _prepareWebGLTextureContinuation;
  29107. private _prepareWebGLTexture;
  29108. /** @hidden */
  29109. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29110. /** @hidden */
  29111. _releaseFramebufferObjects(texture: InternalTexture): void;
  29112. /** @hidden */
  29113. _releaseTexture(texture: InternalTexture): void;
  29114. private setProgram;
  29115. private _boundUniforms;
  29116. /**
  29117. * Binds an effect to the webGL context
  29118. * @param effect defines the effect to bind
  29119. */
  29120. bindSamplers(effect: Effect): void;
  29121. private _activateCurrentTexture;
  29122. /** @hidden */
  29123. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29124. /** @hidden */
  29125. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29126. /**
  29127. * Sets a texture to the webGL context from a postprocess
  29128. * @param channel defines the channel to use
  29129. * @param postProcess defines the source postprocess
  29130. */
  29131. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29132. /**
  29133. * Binds the output of the passed in post process to the texture channel specified
  29134. * @param channel The channel the texture should be bound to
  29135. * @param postProcess The post process which's output should be bound
  29136. */
  29137. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29138. /**
  29139. * Unbind all textures from the webGL context
  29140. */
  29141. unbindAllTextures(): void;
  29142. /**
  29143. * Sets a texture to the according uniform.
  29144. * @param channel The texture channel
  29145. * @param uniform The uniform to set
  29146. * @param texture The texture to apply
  29147. */
  29148. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29149. /**
  29150. * Sets a depth stencil texture from a render target to the according uniform.
  29151. * @param channel The texture channel
  29152. * @param uniform The uniform to set
  29153. * @param texture The render target texture containing the depth stencil texture to apply
  29154. */
  29155. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29156. private _bindSamplerUniformToChannel;
  29157. private _getTextureWrapMode;
  29158. private _setTexture;
  29159. /**
  29160. * Sets an array of texture to the webGL context
  29161. * @param channel defines the channel where the texture array must be set
  29162. * @param uniform defines the associated uniform location
  29163. * @param textures defines the array of textures to bind
  29164. */
  29165. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29166. /** @hidden */
  29167. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29168. private _setTextureParameterFloat;
  29169. private _setTextureParameterInteger;
  29170. /**
  29171. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29172. * @param x defines the x coordinate of the rectangle where pixels must be read
  29173. * @param y defines the y coordinate of the rectangle where pixels must be read
  29174. * @param width defines the width of the rectangle where pixels must be read
  29175. * @param height defines the height of the rectangle where pixels must be read
  29176. * @returns a Uint8Array containing RGBA colors
  29177. */
  29178. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29179. /**
  29180. * Add an externaly attached data from its key.
  29181. * This method call will fail and return false, if such key already exists.
  29182. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29183. * @param key the unique key that identifies the data
  29184. * @param data the data object to associate to the key for this Engine instance
  29185. * @return true if no such key were already present and the data was added successfully, false otherwise
  29186. */
  29187. addExternalData<T>(key: string, data: T): boolean;
  29188. /**
  29189. * Get an externaly attached data from its key
  29190. * @param key the unique key that identifies the data
  29191. * @return the associated data, if present (can be null), or undefined if not present
  29192. */
  29193. getExternalData<T>(key: string): T;
  29194. /**
  29195. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29196. * @param key the unique key that identifies the data
  29197. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29198. * @return the associated data, can be null if the factory returned null.
  29199. */
  29200. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29201. /**
  29202. * Remove an externaly attached data from the Engine instance
  29203. * @param key the unique key that identifies the data
  29204. * @return true if the data was successfully removed, false if it doesn't exist
  29205. */
  29206. removeExternalData(key: string): boolean;
  29207. /**
  29208. * Unbind all vertex attributes from the webGL context
  29209. */
  29210. unbindAllAttributes(): void;
  29211. /**
  29212. * 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
  29213. */
  29214. releaseEffects(): void;
  29215. /**
  29216. * Dispose and release all associated resources
  29217. */
  29218. dispose(): void;
  29219. /**
  29220. * Display the loading screen
  29221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29222. */
  29223. displayLoadingUI(): void;
  29224. /**
  29225. * Hide the loading screen
  29226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29227. */
  29228. hideLoadingUI(): void;
  29229. /**
  29230. * Gets the current loading screen object
  29231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29232. */
  29233. /**
  29234. * Sets the current loading screen object
  29235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29236. */
  29237. loadingScreen: ILoadingScreen;
  29238. /**
  29239. * Sets the current loading screen text
  29240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29241. */
  29242. loadingUIText: string;
  29243. /**
  29244. * Sets the current loading screen background color
  29245. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29246. */
  29247. loadingUIBackgroundColor: string;
  29248. /**
  29249. * Attach a new callback raised when context lost event is fired
  29250. * @param callback defines the callback to call
  29251. */
  29252. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29253. /**
  29254. * Attach a new callback raised when context restored event is fired
  29255. * @param callback defines the callback to call
  29256. */
  29257. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29258. /**
  29259. * Gets the source code of the vertex shader associated with a specific webGL program
  29260. * @param program defines the program to use
  29261. * @returns a string containing the source code of the vertex shader associated with the program
  29262. */
  29263. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29264. /**
  29265. * Gets the source code of the fragment shader associated with a specific webGL program
  29266. * @param program defines the program to use
  29267. * @returns a string containing the source code of the fragment shader associated with the program
  29268. */
  29269. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29270. /**
  29271. * Get the current error code of the webGL context
  29272. * @returns the error code
  29273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29274. */
  29275. getError(): number;
  29276. /**
  29277. * Gets the current framerate
  29278. * @returns a number representing the framerate
  29279. */
  29280. getFps(): number;
  29281. /**
  29282. * Gets the time spent between current and previous frame
  29283. * @returns a number representing the delta time in ms
  29284. */
  29285. getDeltaTime(): number;
  29286. private _measureFps;
  29287. /** @hidden */
  29288. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29289. private _canRenderToFloatFramebuffer;
  29290. private _canRenderToHalfFloatFramebuffer;
  29291. private _canRenderToFramebuffer;
  29292. /** @hidden */
  29293. _getWebGLTextureType(type: number): number;
  29294. /** @hidden */
  29295. _getInternalFormat(format: number): number;
  29296. /** @hidden */
  29297. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29298. /** @hidden */
  29299. _getRGBAMultiSampleBufferFormat(type: number): number;
  29300. /** @hidden */
  29301. _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;
  29302. /** @hidden */
  29303. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29304. /**
  29305. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29306. * @returns true if the engine can be created
  29307. * @ignorenaming
  29308. */
  29309. static isSupported(): boolean;
  29310. }
  29311. }
  29312. declare module BABYLON {
  29313. /**
  29314. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29315. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29316. */
  29317. export class EffectFallbacks {
  29318. private _defines;
  29319. private _currentRank;
  29320. private _maxRank;
  29321. private _mesh;
  29322. /**
  29323. * Removes the fallback from the bound mesh.
  29324. */
  29325. unBindMesh(): void;
  29326. /**
  29327. * Adds a fallback on the specified property.
  29328. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29329. * @param define The name of the define in the shader
  29330. */
  29331. addFallback(rank: number, define: string): void;
  29332. /**
  29333. * Sets the mesh to use CPU skinning when needing to fallback.
  29334. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29335. * @param mesh The mesh to use the fallbacks.
  29336. */
  29337. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29338. /**
  29339. * Checks to see if more fallbacks are still availible.
  29340. */
  29341. readonly isMoreFallbacks: boolean;
  29342. /**
  29343. * Removes the defines that should be removed when falling back.
  29344. * @param currentDefines defines the current define statements for the shader.
  29345. * @param effect defines the current effect we try to compile
  29346. * @returns The resulting defines with defines of the current rank removed.
  29347. */
  29348. reduce(currentDefines: string, effect: Effect): string;
  29349. }
  29350. /**
  29351. * Options to be used when creating an effect.
  29352. */
  29353. export class EffectCreationOptions {
  29354. /**
  29355. * Atrributes that will be used in the shader.
  29356. */
  29357. attributes: string[];
  29358. /**
  29359. * Uniform varible names that will be set in the shader.
  29360. */
  29361. uniformsNames: string[];
  29362. /**
  29363. * Uniform buffer varible names that will be set in the shader.
  29364. */
  29365. uniformBuffersNames: string[];
  29366. /**
  29367. * Sampler texture variable names that will be set in the shader.
  29368. */
  29369. samplers: string[];
  29370. /**
  29371. * Define statements that will be set in the shader.
  29372. */
  29373. defines: any;
  29374. /**
  29375. * Possible fallbacks for this effect to improve performance when needed.
  29376. */
  29377. fallbacks: Nullable<EffectFallbacks>;
  29378. /**
  29379. * Callback that will be called when the shader is compiled.
  29380. */
  29381. onCompiled: Nullable<(effect: Effect) => void>;
  29382. /**
  29383. * Callback that will be called if an error occurs during shader compilation.
  29384. */
  29385. onError: Nullable<(effect: Effect, errors: string) => void>;
  29386. /**
  29387. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29388. */
  29389. indexParameters: any;
  29390. /**
  29391. * Max number of lights that can be used in the shader.
  29392. */
  29393. maxSimultaneousLights: number;
  29394. /**
  29395. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29396. */
  29397. transformFeedbackVaryings: Nullable<string[]>;
  29398. }
  29399. /**
  29400. * Effect containing vertex and fragment shader that can be executed on an object.
  29401. */
  29402. export class Effect implements IDisposable {
  29403. /**
  29404. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29405. */
  29406. static ShadersRepository: string;
  29407. /**
  29408. * Name of the effect.
  29409. */
  29410. name: any;
  29411. /**
  29412. * String container all the define statements that should be set on the shader.
  29413. */
  29414. defines: string;
  29415. /**
  29416. * Callback that will be called when the shader is compiled.
  29417. */
  29418. onCompiled: Nullable<(effect: Effect) => void>;
  29419. /**
  29420. * Callback that will be called if an error occurs during shader compilation.
  29421. */
  29422. onError: Nullable<(effect: Effect, errors: string) => void>;
  29423. /**
  29424. * Callback that will be called when effect is bound.
  29425. */
  29426. onBind: Nullable<(effect: Effect) => void>;
  29427. /**
  29428. * Unique ID of the effect.
  29429. */
  29430. uniqueId: number;
  29431. /**
  29432. * Observable that will be called when the shader is compiled.
  29433. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29434. */
  29435. onCompileObservable: Observable<Effect>;
  29436. /**
  29437. * Observable that will be called if an error occurs during shader compilation.
  29438. */
  29439. onErrorObservable: Observable<Effect>;
  29440. /** @hidden */
  29441. _onBindObservable: Nullable<Observable<Effect>>;
  29442. /**
  29443. * Observable that will be called when effect is bound.
  29444. */
  29445. readonly onBindObservable: Observable<Effect>;
  29446. /** @hidden */
  29447. _bonesComputationForcedToCPU: boolean;
  29448. private static _uniqueIdSeed;
  29449. private _engine;
  29450. private _uniformBuffersNames;
  29451. private _uniformsNames;
  29452. private _samplerList;
  29453. private _samplers;
  29454. private _isReady;
  29455. private _compilationError;
  29456. private _attributesNames;
  29457. private _attributes;
  29458. private _uniforms;
  29459. /**
  29460. * Key for the effect.
  29461. * @hidden
  29462. */
  29463. _key: string;
  29464. private _indexParameters;
  29465. private _fallbacks;
  29466. private _vertexSourceCode;
  29467. private _fragmentSourceCode;
  29468. private _vertexSourceCodeOverride;
  29469. private _fragmentSourceCodeOverride;
  29470. private _transformFeedbackVaryings;
  29471. /**
  29472. * Compiled shader to webGL program.
  29473. * @hidden
  29474. */
  29475. _pipelineContext: Nullable<IPipelineContext>;
  29476. private _valueCache;
  29477. private static _baseCache;
  29478. /**
  29479. * Instantiates an effect.
  29480. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29481. * @param baseName Name of the effect.
  29482. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29483. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29484. * @param samplers List of sampler variables that will be passed to the shader.
  29485. * @param engine Engine to be used to render the effect
  29486. * @param defines Define statements to be added to the shader.
  29487. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29488. * @param onCompiled Callback that will be called when the shader is compiled.
  29489. * @param onError Callback that will be called if an error occurs during shader compilation.
  29490. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29491. */
  29492. 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);
  29493. private _useFinalCode;
  29494. /**
  29495. * Unique key for this effect
  29496. */
  29497. readonly key: string;
  29498. /**
  29499. * If the effect has been compiled and prepared.
  29500. * @returns if the effect is compiled and prepared.
  29501. */
  29502. isReady(): boolean;
  29503. /**
  29504. * The engine the effect was initialized with.
  29505. * @returns the engine.
  29506. */
  29507. getEngine(): Engine;
  29508. /**
  29509. * The pipeline context for this effect
  29510. * @returns the associated pipeline context
  29511. */
  29512. getPipelineContext(): Nullable<IPipelineContext>;
  29513. /**
  29514. * The set of names of attribute variables for the shader.
  29515. * @returns An array of attribute names.
  29516. */
  29517. getAttributesNames(): string[];
  29518. /**
  29519. * Returns the attribute at the given index.
  29520. * @param index The index of the attribute.
  29521. * @returns The location of the attribute.
  29522. */
  29523. getAttributeLocation(index: number): number;
  29524. /**
  29525. * Returns the attribute based on the name of the variable.
  29526. * @param name of the attribute to look up.
  29527. * @returns the attribute location.
  29528. */
  29529. getAttributeLocationByName(name: string): number;
  29530. /**
  29531. * The number of attributes.
  29532. * @returns the numnber of attributes.
  29533. */
  29534. getAttributesCount(): number;
  29535. /**
  29536. * Gets the index of a uniform variable.
  29537. * @param uniformName of the uniform to look up.
  29538. * @returns the index.
  29539. */
  29540. getUniformIndex(uniformName: string): number;
  29541. /**
  29542. * Returns the attribute based on the name of the variable.
  29543. * @param uniformName of the uniform to look up.
  29544. * @returns the location of the uniform.
  29545. */
  29546. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29547. /**
  29548. * Returns an array of sampler variable names
  29549. * @returns The array of sampler variable neames.
  29550. */
  29551. getSamplers(): string[];
  29552. /**
  29553. * The error from the last compilation.
  29554. * @returns the error string.
  29555. */
  29556. getCompilationError(): string;
  29557. /**
  29558. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29559. * @param func The callback to be used.
  29560. */
  29561. executeWhenCompiled(func: (effect: Effect) => void): void;
  29562. private _checkIsReady;
  29563. /** @hidden */
  29564. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29565. /** @hidden */
  29566. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29567. /** @hidden */
  29568. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29569. /**
  29570. * Recompiles the webGL program
  29571. * @param vertexSourceCode The source code for the vertex shader.
  29572. * @param fragmentSourceCode The source code for the fragment shader.
  29573. * @param onCompiled Callback called when completed.
  29574. * @param onError Callback called on error.
  29575. * @hidden
  29576. */
  29577. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29578. /**
  29579. * Prepares the effect
  29580. * @hidden
  29581. */
  29582. _prepareEffect(): void;
  29583. /**
  29584. * Checks if the effect is supported. (Must be called after compilation)
  29585. */
  29586. readonly isSupported: boolean;
  29587. /**
  29588. * Binds a texture to the engine to be used as output of the shader.
  29589. * @param channel Name of the output variable.
  29590. * @param texture Texture to bind.
  29591. * @hidden
  29592. */
  29593. _bindTexture(channel: string, texture: InternalTexture): void;
  29594. /**
  29595. * Sets a texture on the engine to be used in the shader.
  29596. * @param channel Name of the sampler variable.
  29597. * @param texture Texture to set.
  29598. */
  29599. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29600. /**
  29601. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29602. * @param channel Name of the sampler variable.
  29603. * @param texture Texture to set.
  29604. */
  29605. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29606. /**
  29607. * Sets an array of textures on the engine to be used in the shader.
  29608. * @param channel Name of the variable.
  29609. * @param textures Textures to set.
  29610. */
  29611. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29612. /**
  29613. * 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)
  29614. * @param channel Name of the sampler variable.
  29615. * @param postProcess Post process to get the input texture from.
  29616. */
  29617. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29618. /**
  29619. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29620. * 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)
  29621. * @param channel Name of the sampler variable.
  29622. * @param postProcess Post process to get the output texture from.
  29623. */
  29624. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29625. /** @hidden */
  29626. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29627. /** @hidden */
  29628. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29629. /** @hidden */
  29630. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29631. /** @hidden */
  29632. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29633. /**
  29634. * Binds a buffer to a uniform.
  29635. * @param buffer Buffer to bind.
  29636. * @param name Name of the uniform variable to bind to.
  29637. */
  29638. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29639. /**
  29640. * Binds block to a uniform.
  29641. * @param blockName Name of the block to bind.
  29642. * @param index Index to bind.
  29643. */
  29644. bindUniformBlock(blockName: string, index: number): void;
  29645. /**
  29646. * Sets an interger value on a uniform variable.
  29647. * @param uniformName Name of the variable.
  29648. * @param value Value to be set.
  29649. * @returns this effect.
  29650. */
  29651. setInt(uniformName: string, value: number): Effect;
  29652. /**
  29653. * Sets an int array on a uniform variable.
  29654. * @param uniformName Name of the variable.
  29655. * @param array array to be set.
  29656. * @returns this effect.
  29657. */
  29658. setIntArray(uniformName: string, array: Int32Array): Effect;
  29659. /**
  29660. * 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)
  29661. * @param uniformName Name of the variable.
  29662. * @param array array to be set.
  29663. * @returns this effect.
  29664. */
  29665. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29666. /**
  29667. * 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)
  29668. * @param uniformName Name of the variable.
  29669. * @param array array to be set.
  29670. * @returns this effect.
  29671. */
  29672. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29673. /**
  29674. * 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)
  29675. * @param uniformName Name of the variable.
  29676. * @param array array to be set.
  29677. * @returns this effect.
  29678. */
  29679. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29680. /**
  29681. * Sets an float array on a uniform variable.
  29682. * @param uniformName Name of the variable.
  29683. * @param array array to be set.
  29684. * @returns this effect.
  29685. */
  29686. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29687. /**
  29688. * 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)
  29689. * @param uniformName Name of the variable.
  29690. * @param array array to be set.
  29691. * @returns this effect.
  29692. */
  29693. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29694. /**
  29695. * 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)
  29696. * @param uniformName Name of the variable.
  29697. * @param array array to be set.
  29698. * @returns this effect.
  29699. */
  29700. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29701. /**
  29702. * 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)
  29703. * @param uniformName Name of the variable.
  29704. * @param array array to be set.
  29705. * @returns this effect.
  29706. */
  29707. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29708. /**
  29709. * Sets an array on a uniform variable.
  29710. * @param uniformName Name of the variable.
  29711. * @param array array to be set.
  29712. * @returns this effect.
  29713. */
  29714. setArray(uniformName: string, array: number[]): Effect;
  29715. /**
  29716. * 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)
  29717. * @param uniformName Name of the variable.
  29718. * @param array array to be set.
  29719. * @returns this effect.
  29720. */
  29721. setArray2(uniformName: string, array: number[]): Effect;
  29722. /**
  29723. * 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)
  29724. * @param uniformName Name of the variable.
  29725. * @param array array to be set.
  29726. * @returns this effect.
  29727. */
  29728. setArray3(uniformName: string, array: number[]): Effect;
  29729. /**
  29730. * 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)
  29731. * @param uniformName Name of the variable.
  29732. * @param array array to be set.
  29733. * @returns this effect.
  29734. */
  29735. setArray4(uniformName: string, array: number[]): Effect;
  29736. /**
  29737. * Sets matrices on a uniform variable.
  29738. * @param uniformName Name of the variable.
  29739. * @param matrices matrices to be set.
  29740. * @returns this effect.
  29741. */
  29742. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29743. /**
  29744. * Sets matrix on a uniform variable.
  29745. * @param uniformName Name of the variable.
  29746. * @param matrix matrix to be set.
  29747. * @returns this effect.
  29748. */
  29749. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29750. /**
  29751. * 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)
  29752. * @param uniformName Name of the variable.
  29753. * @param matrix matrix to be set.
  29754. * @returns this effect.
  29755. */
  29756. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29757. /**
  29758. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29759. * @param uniformName Name of the variable.
  29760. * @param matrix matrix to be set.
  29761. * @returns this effect.
  29762. */
  29763. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29764. /**
  29765. * Sets a float on a uniform variable.
  29766. * @param uniformName Name of the variable.
  29767. * @param value value to be set.
  29768. * @returns this effect.
  29769. */
  29770. setFloat(uniformName: string, value: number): Effect;
  29771. /**
  29772. * Sets a boolean on a uniform variable.
  29773. * @param uniformName Name of the variable.
  29774. * @param bool value to be set.
  29775. * @returns this effect.
  29776. */
  29777. setBool(uniformName: string, bool: boolean): Effect;
  29778. /**
  29779. * Sets a Vector2 on a uniform variable.
  29780. * @param uniformName Name of the variable.
  29781. * @param vector2 vector2 to be set.
  29782. * @returns this effect.
  29783. */
  29784. setVector2(uniformName: string, vector2: Vector2): Effect;
  29785. /**
  29786. * Sets a float2 on a uniform variable.
  29787. * @param uniformName Name of the variable.
  29788. * @param x First float in float2.
  29789. * @param y Second float in float2.
  29790. * @returns this effect.
  29791. */
  29792. setFloat2(uniformName: string, x: number, y: number): Effect;
  29793. /**
  29794. * Sets a Vector3 on a uniform variable.
  29795. * @param uniformName Name of the variable.
  29796. * @param vector3 Value to be set.
  29797. * @returns this effect.
  29798. */
  29799. setVector3(uniformName: string, vector3: Vector3): Effect;
  29800. /**
  29801. * Sets a float3 on a uniform variable.
  29802. * @param uniformName Name of the variable.
  29803. * @param x First float in float3.
  29804. * @param y Second float in float3.
  29805. * @param z Third float in float3.
  29806. * @returns this effect.
  29807. */
  29808. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29809. /**
  29810. * Sets a Vector4 on a uniform variable.
  29811. * @param uniformName Name of the variable.
  29812. * @param vector4 Value to be set.
  29813. * @returns this effect.
  29814. */
  29815. setVector4(uniformName: string, vector4: Vector4): Effect;
  29816. /**
  29817. * Sets a float4 on a uniform variable.
  29818. * @param uniformName Name of the variable.
  29819. * @param x First float in float4.
  29820. * @param y Second float in float4.
  29821. * @param z Third float in float4.
  29822. * @param w Fourth float in float4.
  29823. * @returns this effect.
  29824. */
  29825. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29826. /**
  29827. * Sets a Color3 on a uniform variable.
  29828. * @param uniformName Name of the variable.
  29829. * @param color3 Value to be set.
  29830. * @returns this effect.
  29831. */
  29832. setColor3(uniformName: string, color3: Color3): Effect;
  29833. /**
  29834. * Sets a Color4 on a uniform variable.
  29835. * @param uniformName Name of the variable.
  29836. * @param color3 Value to be set.
  29837. * @param alpha Alpha value to be set.
  29838. * @returns this effect.
  29839. */
  29840. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29841. /**
  29842. * Sets a Color4 on a uniform variable
  29843. * @param uniformName defines the name of the variable
  29844. * @param color4 defines the value to be set
  29845. * @returns this effect.
  29846. */
  29847. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29848. /** Release all associated resources */
  29849. dispose(): void;
  29850. /**
  29851. * This function will add a new shader to the shader store
  29852. * @param name the name of the shader
  29853. * @param pixelShader optional pixel shader content
  29854. * @param vertexShader optional vertex shader content
  29855. */
  29856. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29857. /**
  29858. * Store of each shader (The can be looked up using effect.key)
  29859. */
  29860. static ShadersStore: {
  29861. [key: string]: string;
  29862. };
  29863. /**
  29864. * Store of each included file for a shader (The can be looked up using effect.key)
  29865. */
  29866. static IncludesShadersStore: {
  29867. [key: string]: string;
  29868. };
  29869. /**
  29870. * Resets the cache of effects.
  29871. */
  29872. static ResetCache(): void;
  29873. }
  29874. }
  29875. declare module BABYLON {
  29876. /**
  29877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29879. * 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;
  29880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29881. */
  29882. export class ColorCurves {
  29883. private _dirty;
  29884. private _tempColor;
  29885. private _globalCurve;
  29886. private _highlightsCurve;
  29887. private _midtonesCurve;
  29888. private _shadowsCurve;
  29889. private _positiveCurve;
  29890. private _negativeCurve;
  29891. private _globalHue;
  29892. private _globalDensity;
  29893. private _globalSaturation;
  29894. private _globalExposure;
  29895. /**
  29896. * Gets the global Hue value.
  29897. * 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).
  29898. */
  29899. /**
  29900. * Sets the global Hue value.
  29901. * 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).
  29902. */
  29903. globalHue: number;
  29904. /**
  29905. * Gets the global Density value.
  29906. * 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.
  29907. * Values less than zero provide a filter of opposite hue.
  29908. */
  29909. /**
  29910. * Sets the global Density value.
  29911. * 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.
  29912. * Values less than zero provide a filter of opposite hue.
  29913. */
  29914. globalDensity: number;
  29915. /**
  29916. * Gets the global Saturation value.
  29917. * 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.
  29918. */
  29919. /**
  29920. * Sets the global Saturation value.
  29921. * 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.
  29922. */
  29923. globalSaturation: number;
  29924. /**
  29925. * Gets the global Exposure value.
  29926. * 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.
  29927. */
  29928. /**
  29929. * Sets the global Exposure value.
  29930. * 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.
  29931. */
  29932. globalExposure: number;
  29933. private _highlightsHue;
  29934. private _highlightsDensity;
  29935. private _highlightsSaturation;
  29936. private _highlightsExposure;
  29937. /**
  29938. * Gets the highlights Hue value.
  29939. * 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).
  29940. */
  29941. /**
  29942. * Sets the highlights Hue value.
  29943. * 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).
  29944. */
  29945. highlightsHue: number;
  29946. /**
  29947. * Gets the highlights Density value.
  29948. * 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.
  29949. * Values less than zero provide a filter of opposite hue.
  29950. */
  29951. /**
  29952. * Sets the highlights Density value.
  29953. * 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.
  29954. * Values less than zero provide a filter of opposite hue.
  29955. */
  29956. highlightsDensity: number;
  29957. /**
  29958. * Gets the highlights Saturation value.
  29959. * 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.
  29960. */
  29961. /**
  29962. * Sets the highlights Saturation value.
  29963. * 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.
  29964. */
  29965. highlightsSaturation: number;
  29966. /**
  29967. * Gets the highlights Exposure value.
  29968. * 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.
  29969. */
  29970. /**
  29971. * Sets the highlights Exposure value.
  29972. * 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.
  29973. */
  29974. highlightsExposure: number;
  29975. private _midtonesHue;
  29976. private _midtonesDensity;
  29977. private _midtonesSaturation;
  29978. private _midtonesExposure;
  29979. /**
  29980. * Gets the midtones Hue value.
  29981. * 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).
  29982. */
  29983. /**
  29984. * Sets the midtones Hue value.
  29985. * 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).
  29986. */
  29987. midtonesHue: number;
  29988. /**
  29989. * Gets the midtones Density value.
  29990. * 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.
  29991. * Values less than zero provide a filter of opposite hue.
  29992. */
  29993. /**
  29994. * Sets the midtones Density value.
  29995. * 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.
  29996. * Values less than zero provide a filter of opposite hue.
  29997. */
  29998. midtonesDensity: number;
  29999. /**
  30000. * Gets the midtones Saturation value.
  30001. * 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.
  30002. */
  30003. /**
  30004. * Sets the midtones Saturation value.
  30005. * 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.
  30006. */
  30007. midtonesSaturation: number;
  30008. /**
  30009. * Gets the midtones Exposure value.
  30010. * 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.
  30011. */
  30012. /**
  30013. * Sets the midtones Exposure value.
  30014. * 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.
  30015. */
  30016. midtonesExposure: number;
  30017. private _shadowsHue;
  30018. private _shadowsDensity;
  30019. private _shadowsSaturation;
  30020. private _shadowsExposure;
  30021. /**
  30022. * Gets the shadows Hue value.
  30023. * 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).
  30024. */
  30025. /**
  30026. * Sets the shadows Hue value.
  30027. * 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).
  30028. */
  30029. shadowsHue: number;
  30030. /**
  30031. * Gets the shadows Density value.
  30032. * 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.
  30033. * Values less than zero provide a filter of opposite hue.
  30034. */
  30035. /**
  30036. * Sets the shadows Density value.
  30037. * 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.
  30038. * Values less than zero provide a filter of opposite hue.
  30039. */
  30040. shadowsDensity: number;
  30041. /**
  30042. * Gets the shadows Saturation value.
  30043. * 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.
  30044. */
  30045. /**
  30046. * Sets the shadows Saturation value.
  30047. * 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.
  30048. */
  30049. shadowsSaturation: number;
  30050. /**
  30051. * Gets the shadows Exposure value.
  30052. * 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.
  30053. */
  30054. /**
  30055. * Sets the shadows Exposure value.
  30056. * 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.
  30057. */
  30058. shadowsExposure: number;
  30059. /**
  30060. * Returns the class name
  30061. * @returns The class name
  30062. */
  30063. getClassName(): string;
  30064. /**
  30065. * Binds the color curves to the shader.
  30066. * @param colorCurves The color curve to bind
  30067. * @param effect The effect to bind to
  30068. * @param positiveUniform The positive uniform shader parameter
  30069. * @param neutralUniform The neutral uniform shader parameter
  30070. * @param negativeUniform The negative uniform shader parameter
  30071. */
  30072. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30073. /**
  30074. * Prepare the list of uniforms associated with the ColorCurves effects.
  30075. * @param uniformsList The list of uniforms used in the effect
  30076. */
  30077. static PrepareUniforms(uniformsList: string[]): void;
  30078. /**
  30079. * Returns color grading data based on a hue, density, saturation and exposure value.
  30080. * @param filterHue The hue of the color filter.
  30081. * @param filterDensity The density of the color filter.
  30082. * @param saturation The saturation.
  30083. * @param exposure The exposure.
  30084. * @param result The result data container.
  30085. */
  30086. private getColorGradingDataToRef;
  30087. /**
  30088. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30089. * @param value The input slider value in range [-100,100].
  30090. * @returns Adjusted value.
  30091. */
  30092. private static applyColorGradingSliderNonlinear;
  30093. /**
  30094. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30095. * @param hue The hue (H) input.
  30096. * @param saturation The saturation (S) input.
  30097. * @param brightness The brightness (B) input.
  30098. * @result An RGBA color represented as Vector4.
  30099. */
  30100. private static fromHSBToRef;
  30101. /**
  30102. * Returns a value clamped between min and max
  30103. * @param value The value to clamp
  30104. * @param min The minimum of value
  30105. * @param max The maximum of value
  30106. * @returns The clamped value.
  30107. */
  30108. private static clamp;
  30109. /**
  30110. * Clones the current color curve instance.
  30111. * @return The cloned curves
  30112. */
  30113. clone(): ColorCurves;
  30114. /**
  30115. * Serializes the current color curve instance to a json representation.
  30116. * @return a JSON representation
  30117. */
  30118. serialize(): any;
  30119. /**
  30120. * Parses the color curve from a json representation.
  30121. * @param source the JSON source to parse
  30122. * @return The parsed curves
  30123. */
  30124. static Parse(source: any): ColorCurves;
  30125. }
  30126. }
  30127. declare module BABYLON {
  30128. /**
  30129. * Interface to follow in your material defines to integrate easily the
  30130. * Image proccessing functions.
  30131. * @hidden
  30132. */
  30133. export interface IImageProcessingConfigurationDefines {
  30134. IMAGEPROCESSING: boolean;
  30135. VIGNETTE: boolean;
  30136. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30137. VIGNETTEBLENDMODEOPAQUE: boolean;
  30138. TONEMAPPING: boolean;
  30139. TONEMAPPING_ACES: boolean;
  30140. CONTRAST: boolean;
  30141. EXPOSURE: boolean;
  30142. COLORCURVES: boolean;
  30143. COLORGRADING: boolean;
  30144. COLORGRADING3D: boolean;
  30145. SAMPLER3DGREENDEPTH: boolean;
  30146. SAMPLER3DBGRMAP: boolean;
  30147. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30148. }
  30149. /**
  30150. * @hidden
  30151. */
  30152. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30153. IMAGEPROCESSING: boolean;
  30154. VIGNETTE: boolean;
  30155. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30156. VIGNETTEBLENDMODEOPAQUE: boolean;
  30157. TONEMAPPING: boolean;
  30158. TONEMAPPING_ACES: boolean;
  30159. CONTRAST: boolean;
  30160. COLORCURVES: boolean;
  30161. COLORGRADING: boolean;
  30162. COLORGRADING3D: boolean;
  30163. SAMPLER3DGREENDEPTH: boolean;
  30164. SAMPLER3DBGRMAP: boolean;
  30165. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30166. EXPOSURE: boolean;
  30167. constructor();
  30168. }
  30169. /**
  30170. * This groups together the common properties used for image processing either in direct forward pass
  30171. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30172. * or not.
  30173. */
  30174. export class ImageProcessingConfiguration {
  30175. /**
  30176. * Default tone mapping applied in BabylonJS.
  30177. */
  30178. static readonly TONEMAPPING_STANDARD: number;
  30179. /**
  30180. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30181. * to other engines rendering to increase portability.
  30182. */
  30183. static readonly TONEMAPPING_ACES: number;
  30184. /**
  30185. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30186. */
  30187. colorCurves: Nullable<ColorCurves>;
  30188. private _colorCurvesEnabled;
  30189. /**
  30190. * Gets wether the color curves effect is enabled.
  30191. */
  30192. /**
  30193. * Sets wether the color curves effect is enabled.
  30194. */
  30195. colorCurvesEnabled: boolean;
  30196. private _colorGradingTexture;
  30197. /**
  30198. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30199. */
  30200. /**
  30201. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30202. */
  30203. colorGradingTexture: Nullable<BaseTexture>;
  30204. private _colorGradingEnabled;
  30205. /**
  30206. * Gets wether the color grading effect is enabled.
  30207. */
  30208. /**
  30209. * Sets wether the color grading effect is enabled.
  30210. */
  30211. colorGradingEnabled: boolean;
  30212. private _colorGradingWithGreenDepth;
  30213. /**
  30214. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30215. */
  30216. /**
  30217. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30218. */
  30219. colorGradingWithGreenDepth: boolean;
  30220. private _colorGradingBGR;
  30221. /**
  30222. * Gets wether the color grading texture contains BGR values.
  30223. */
  30224. /**
  30225. * Sets wether the color grading texture contains BGR values.
  30226. */
  30227. colorGradingBGR: boolean;
  30228. /** @hidden */
  30229. _exposure: number;
  30230. /**
  30231. * Gets the Exposure used in the effect.
  30232. */
  30233. /**
  30234. * Sets the Exposure used in the effect.
  30235. */
  30236. exposure: number;
  30237. private _toneMappingEnabled;
  30238. /**
  30239. * Gets wether the tone mapping effect is enabled.
  30240. */
  30241. /**
  30242. * Sets wether the tone mapping effect is enabled.
  30243. */
  30244. toneMappingEnabled: boolean;
  30245. private _toneMappingType;
  30246. /**
  30247. * Gets the type of tone mapping effect.
  30248. */
  30249. /**
  30250. * Sets the type of tone mapping effect used in BabylonJS.
  30251. */
  30252. toneMappingType: number;
  30253. protected _contrast: number;
  30254. /**
  30255. * Gets the contrast used in the effect.
  30256. */
  30257. /**
  30258. * Sets the contrast used in the effect.
  30259. */
  30260. contrast: number;
  30261. /**
  30262. * Vignette stretch size.
  30263. */
  30264. vignetteStretch: number;
  30265. /**
  30266. * Vignette centre X Offset.
  30267. */
  30268. vignetteCentreX: number;
  30269. /**
  30270. * Vignette centre Y Offset.
  30271. */
  30272. vignetteCentreY: number;
  30273. /**
  30274. * Vignette weight or intensity of the vignette effect.
  30275. */
  30276. vignetteWeight: number;
  30277. /**
  30278. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30279. * if vignetteEnabled is set to true.
  30280. */
  30281. vignetteColor: Color4;
  30282. /**
  30283. * Camera field of view used by the Vignette effect.
  30284. */
  30285. vignetteCameraFov: number;
  30286. private _vignetteBlendMode;
  30287. /**
  30288. * Gets the vignette blend mode allowing different kind of effect.
  30289. */
  30290. /**
  30291. * Sets the vignette blend mode allowing different kind of effect.
  30292. */
  30293. vignetteBlendMode: number;
  30294. private _vignetteEnabled;
  30295. /**
  30296. * Gets wether the vignette effect is enabled.
  30297. */
  30298. /**
  30299. * Sets wether the vignette effect is enabled.
  30300. */
  30301. vignetteEnabled: boolean;
  30302. private _applyByPostProcess;
  30303. /**
  30304. * Gets wether the image processing is applied through a post process or not.
  30305. */
  30306. /**
  30307. * Sets wether the image processing is applied through a post process or not.
  30308. */
  30309. applyByPostProcess: boolean;
  30310. private _isEnabled;
  30311. /**
  30312. * Gets wether the image processing is enabled or not.
  30313. */
  30314. /**
  30315. * Sets wether the image processing is enabled or not.
  30316. */
  30317. isEnabled: boolean;
  30318. /**
  30319. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30320. */
  30321. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30322. /**
  30323. * Method called each time the image processing information changes requires to recompile the effect.
  30324. */
  30325. protected _updateParameters(): void;
  30326. /**
  30327. * Gets the current class name.
  30328. * @return "ImageProcessingConfiguration"
  30329. */
  30330. getClassName(): string;
  30331. /**
  30332. * Prepare the list of uniforms associated with the Image Processing effects.
  30333. * @param uniforms The list of uniforms used in the effect
  30334. * @param defines the list of defines currently in use
  30335. */
  30336. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30337. /**
  30338. * Prepare the list of samplers associated with the Image Processing effects.
  30339. * @param samplersList The list of uniforms used in the effect
  30340. * @param defines the list of defines currently in use
  30341. */
  30342. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30343. /**
  30344. * Prepare the list of defines associated to the shader.
  30345. * @param defines the list of defines to complete
  30346. * @param forPostProcess Define if we are currently in post process mode or not
  30347. */
  30348. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30349. /**
  30350. * Returns true if all the image processing information are ready.
  30351. * @returns True if ready, otherwise, false
  30352. */
  30353. isReady(): boolean;
  30354. /**
  30355. * Binds the image processing to the shader.
  30356. * @param effect The effect to bind to
  30357. * @param aspectRatio Define the current aspect ratio of the effect
  30358. */
  30359. bind(effect: Effect, aspectRatio?: number): void;
  30360. /**
  30361. * Clones the current image processing instance.
  30362. * @return The cloned image processing
  30363. */
  30364. clone(): ImageProcessingConfiguration;
  30365. /**
  30366. * Serializes the current image processing instance to a json representation.
  30367. * @return a JSON representation
  30368. */
  30369. serialize(): any;
  30370. /**
  30371. * Parses the image processing from a json representation.
  30372. * @param source the JSON source to parse
  30373. * @return The parsed image processing
  30374. */
  30375. static Parse(source: any): ImageProcessingConfiguration;
  30376. private static _VIGNETTEMODE_MULTIPLY;
  30377. private static _VIGNETTEMODE_OPAQUE;
  30378. /**
  30379. * Used to apply the vignette as a mix with the pixel color.
  30380. */
  30381. static readonly VIGNETTEMODE_MULTIPLY: number;
  30382. /**
  30383. * Used to apply the vignette as a replacement of the pixel color.
  30384. */
  30385. static readonly VIGNETTEMODE_OPAQUE: number;
  30386. }
  30387. }
  30388. declare module BABYLON {
  30389. /**
  30390. * This represents all the required information to add a fresnel effect on a material:
  30391. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30392. */
  30393. export class FresnelParameters {
  30394. private _isEnabled;
  30395. /**
  30396. * Define if the fresnel effect is enable or not.
  30397. */
  30398. isEnabled: boolean;
  30399. /**
  30400. * Define the color used on edges (grazing angle)
  30401. */
  30402. leftColor: Color3;
  30403. /**
  30404. * Define the color used on center
  30405. */
  30406. rightColor: Color3;
  30407. /**
  30408. * Define bias applied to computed fresnel term
  30409. */
  30410. bias: number;
  30411. /**
  30412. * Defined the power exponent applied to fresnel term
  30413. */
  30414. power: number;
  30415. /**
  30416. * Clones the current fresnel and its valuues
  30417. * @returns a clone fresnel configuration
  30418. */
  30419. clone(): FresnelParameters;
  30420. /**
  30421. * Serializes the current fresnel parameters to a JSON representation.
  30422. * @return the JSON serialization
  30423. */
  30424. serialize(): any;
  30425. /**
  30426. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30427. * @param parsedFresnelParameters Define the JSON representation
  30428. * @returns the parsed parameters
  30429. */
  30430. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30431. }
  30432. }
  30433. declare module BABYLON {
  30434. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30435. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30436. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30446. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. /**
  30448. * Decorator used to define property that can be serialized as reference to a camera
  30449. * @param sourceName defines the name of the property to decorate
  30450. */
  30451. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30452. /**
  30453. * Class used to help serialization objects
  30454. */
  30455. export class SerializationHelper {
  30456. /** @hidden */
  30457. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30458. /** @hidden */
  30459. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30460. /** @hidden */
  30461. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30462. /** @hidden */
  30463. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30464. /**
  30465. * Appends the serialized animations from the source animations
  30466. * @param source Source containing the animations
  30467. * @param destination Target to store the animations
  30468. */
  30469. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30470. /**
  30471. * Static function used to serialized a specific entity
  30472. * @param entity defines the entity to serialize
  30473. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30474. * @returns a JSON compatible object representing the serialization of the entity
  30475. */
  30476. static Serialize<T>(entity: T, serializationObject?: any): any;
  30477. /**
  30478. * Creates a new entity from a serialization data object
  30479. * @param creationFunction defines a function used to instanciated the new entity
  30480. * @param source defines the source serialization data
  30481. * @param scene defines the hosting scene
  30482. * @param rootUrl defines the root url for resources
  30483. * @returns a new entity
  30484. */
  30485. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30486. /**
  30487. * Clones an object
  30488. * @param creationFunction defines the function used to instanciate the new object
  30489. * @param source defines the source object
  30490. * @returns the cloned object
  30491. */
  30492. static Clone<T>(creationFunction: () => T, source: T): T;
  30493. /**
  30494. * Instanciates a new object based on a source one (some data will be shared between both object)
  30495. * @param creationFunction defines the function used to instanciate the new object
  30496. * @param source defines the source object
  30497. * @returns the new object
  30498. */
  30499. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30500. }
  30501. }
  30502. declare module BABYLON {
  30503. /**
  30504. * This is the base class of all the camera used in the application.
  30505. * @see http://doc.babylonjs.com/features/cameras
  30506. */
  30507. export class Camera extends Node {
  30508. /** @hidden */
  30509. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30510. /**
  30511. * This is the default projection mode used by the cameras.
  30512. * It helps recreating a feeling of perspective and better appreciate depth.
  30513. * This is the best way to simulate real life cameras.
  30514. */
  30515. static readonly PERSPECTIVE_CAMERA: number;
  30516. /**
  30517. * This helps creating camera with an orthographic mode.
  30518. * 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.
  30519. */
  30520. static readonly ORTHOGRAPHIC_CAMERA: number;
  30521. /**
  30522. * This is the default FOV mode for perspective cameras.
  30523. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30524. */
  30525. static readonly FOVMODE_VERTICAL_FIXED: number;
  30526. /**
  30527. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30528. */
  30529. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30530. /**
  30531. * This specifies ther is no need for a camera rig.
  30532. * Basically only one eye is rendered corresponding to the camera.
  30533. */
  30534. static readonly RIG_MODE_NONE: number;
  30535. /**
  30536. * Simulates a camera Rig with one blue eye and one red eye.
  30537. * This can be use with 3d blue and red glasses.
  30538. */
  30539. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30540. /**
  30541. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30542. */
  30543. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30544. /**
  30545. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30546. */
  30547. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30548. /**
  30549. * Defines that both eyes of the camera will be rendered over under each other.
  30550. */
  30551. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30552. /**
  30553. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30554. */
  30555. static readonly RIG_MODE_VR: number;
  30556. /**
  30557. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30558. */
  30559. static readonly RIG_MODE_WEBVR: number;
  30560. /**
  30561. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30562. */
  30563. static readonly RIG_MODE_CUSTOM: number;
  30564. /**
  30565. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30566. */
  30567. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30568. /**
  30569. * Define the input manager associated with the camera.
  30570. */
  30571. inputs: CameraInputsManager<Camera>;
  30572. /** @hidden */
  30573. _position: Vector3;
  30574. /**
  30575. * Define the current local position of the camera in the scene
  30576. */
  30577. position: Vector3;
  30578. /**
  30579. * The vector the camera should consider as up.
  30580. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30581. */
  30582. upVector: Vector3;
  30583. /**
  30584. * Define the current limit on the left side for an orthographic camera
  30585. * In scene unit
  30586. */
  30587. orthoLeft: Nullable<number>;
  30588. /**
  30589. * Define the current limit on the right side for an orthographic camera
  30590. * In scene unit
  30591. */
  30592. orthoRight: Nullable<number>;
  30593. /**
  30594. * Define the current limit on the bottom side for an orthographic camera
  30595. * In scene unit
  30596. */
  30597. orthoBottom: Nullable<number>;
  30598. /**
  30599. * Define the current limit on the top side for an orthographic camera
  30600. * In scene unit
  30601. */
  30602. orthoTop: Nullable<number>;
  30603. /**
  30604. * Field Of View is set in Radians. (default is 0.8)
  30605. */
  30606. fov: number;
  30607. /**
  30608. * Define the minimum distance the camera can see from.
  30609. * This is important to note that the depth buffer are not infinite and the closer it starts
  30610. * the more your scene might encounter depth fighting issue.
  30611. */
  30612. minZ: number;
  30613. /**
  30614. * Define the maximum distance the camera can see to.
  30615. * This is important to note that the depth buffer are not infinite and the further it end
  30616. * the more your scene might encounter depth fighting issue.
  30617. */
  30618. maxZ: number;
  30619. /**
  30620. * Define the default inertia of the camera.
  30621. * This helps giving a smooth feeling to the camera movement.
  30622. */
  30623. inertia: number;
  30624. /**
  30625. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30626. */
  30627. mode: number;
  30628. /**
  30629. * Define wether the camera is intermediate.
  30630. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30631. */
  30632. isIntermediate: boolean;
  30633. /**
  30634. * Define the viewport of the camera.
  30635. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30636. */
  30637. viewport: Viewport;
  30638. /**
  30639. * Restricts the camera to viewing objects with the same layerMask.
  30640. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30641. */
  30642. layerMask: number;
  30643. /**
  30644. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30645. */
  30646. fovMode: number;
  30647. /**
  30648. * Rig mode of the camera.
  30649. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30650. * This is normally controlled byt the camera themselves as internal use.
  30651. */
  30652. cameraRigMode: number;
  30653. /**
  30654. * Defines the distance between both "eyes" in case of a RIG
  30655. */
  30656. interaxialDistance: number;
  30657. /**
  30658. * Defines if stereoscopic rendering is done side by side or over under.
  30659. */
  30660. isStereoscopicSideBySide: boolean;
  30661. /**
  30662. * 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
  30663. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30664. * else in the scene.
  30665. */
  30666. customRenderTargets: RenderTargetTexture[];
  30667. /**
  30668. * When set, the camera will render to this render target instead of the default canvas
  30669. */
  30670. outputRenderTarget: Nullable<RenderTargetTexture>;
  30671. /**
  30672. * Observable triggered when the camera view matrix has changed.
  30673. */
  30674. onViewMatrixChangedObservable: Observable<Camera>;
  30675. /**
  30676. * Observable triggered when the camera Projection matrix has changed.
  30677. */
  30678. onProjectionMatrixChangedObservable: Observable<Camera>;
  30679. /**
  30680. * Observable triggered when the inputs have been processed.
  30681. */
  30682. onAfterCheckInputsObservable: Observable<Camera>;
  30683. /**
  30684. * Observable triggered when reset has been called and applied to the camera.
  30685. */
  30686. onRestoreStateObservable: Observable<Camera>;
  30687. /** @hidden */
  30688. _cameraRigParams: any;
  30689. /** @hidden */
  30690. _rigCameras: Camera[];
  30691. /** @hidden */
  30692. _rigPostProcess: Nullable<PostProcess>;
  30693. protected _webvrViewMatrix: Matrix;
  30694. /** @hidden */
  30695. _skipRendering: boolean;
  30696. /** @hidden */
  30697. _projectionMatrix: Matrix;
  30698. /** @hidden */
  30699. _postProcesses: Nullable<PostProcess>[];
  30700. /** @hidden */
  30701. _activeMeshes: SmartArray<AbstractMesh>;
  30702. protected _globalPosition: Vector3;
  30703. /** @hidden */
  30704. _computedViewMatrix: Matrix;
  30705. private _doNotComputeProjectionMatrix;
  30706. private _transformMatrix;
  30707. private _frustumPlanes;
  30708. private _refreshFrustumPlanes;
  30709. private _storedFov;
  30710. private _stateStored;
  30711. /**
  30712. * Instantiates a new camera object.
  30713. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30714. * @see http://doc.babylonjs.com/features/cameras
  30715. * @param name Defines the name of the camera in the scene
  30716. * @param position Defines the position of the camera
  30717. * @param scene Defines the scene the camera belongs too
  30718. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30719. */
  30720. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30721. /**
  30722. * Store current camera state (fov, position, etc..)
  30723. * @returns the camera
  30724. */
  30725. storeState(): Camera;
  30726. /**
  30727. * Restores the camera state values if it has been stored. You must call storeState() first
  30728. */
  30729. protected _restoreStateValues(): boolean;
  30730. /**
  30731. * Restored camera state. You must call storeState() first.
  30732. * @returns true if restored and false otherwise
  30733. */
  30734. restoreState(): boolean;
  30735. /**
  30736. * Gets the class name of the camera.
  30737. * @returns the class name
  30738. */
  30739. getClassName(): string;
  30740. /** @hidden */
  30741. readonly _isCamera: boolean;
  30742. /**
  30743. * Gets a string representation of the camera useful for debug purpose.
  30744. * @param fullDetails Defines that a more verboe level of logging is required
  30745. * @returns the string representation
  30746. */
  30747. toString(fullDetails?: boolean): string;
  30748. /**
  30749. * Gets the current world space position of the camera.
  30750. */
  30751. readonly globalPosition: Vector3;
  30752. /**
  30753. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30754. * @returns the active meshe list
  30755. */
  30756. getActiveMeshes(): SmartArray<AbstractMesh>;
  30757. /**
  30758. * Check wether a mesh is part of the current active mesh list of the camera
  30759. * @param mesh Defines the mesh to check
  30760. * @returns true if active, false otherwise
  30761. */
  30762. isActiveMesh(mesh: Mesh): boolean;
  30763. /**
  30764. * Is this camera ready to be used/rendered
  30765. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30766. * @return true if the camera is ready
  30767. */
  30768. isReady(completeCheck?: boolean): boolean;
  30769. /** @hidden */
  30770. _initCache(): void;
  30771. /** @hidden */
  30772. _updateCache(ignoreParentClass?: boolean): void;
  30773. /** @hidden */
  30774. _isSynchronized(): boolean;
  30775. /** @hidden */
  30776. _isSynchronizedViewMatrix(): boolean;
  30777. /** @hidden */
  30778. _isSynchronizedProjectionMatrix(): boolean;
  30779. /**
  30780. * Attach the input controls to a specific dom element to get the input from.
  30781. * @param element Defines the element the controls should be listened from
  30782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30783. */
  30784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30785. /**
  30786. * Detach the current controls from the specified dom element.
  30787. * @param element Defines the element to stop listening the inputs from
  30788. */
  30789. detachControl(element: HTMLElement): void;
  30790. /**
  30791. * Update the camera state according to the different inputs gathered during the frame.
  30792. */
  30793. update(): void;
  30794. /** @hidden */
  30795. _checkInputs(): void;
  30796. /** @hidden */
  30797. readonly rigCameras: Camera[];
  30798. /**
  30799. * Gets the post process used by the rig cameras
  30800. */
  30801. readonly rigPostProcess: Nullable<PostProcess>;
  30802. /**
  30803. * Internal, gets the first post proces.
  30804. * @returns the first post process to be run on this camera.
  30805. */
  30806. _getFirstPostProcess(): Nullable<PostProcess>;
  30807. private _cascadePostProcessesToRigCams;
  30808. /**
  30809. * Attach a post process to the camera.
  30810. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30811. * @param postProcess The post process to attach to the camera
  30812. * @param insertAt The position of the post process in case several of them are in use in the scene
  30813. * @returns the position the post process has been inserted at
  30814. */
  30815. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30816. /**
  30817. * Detach a post process to the camera.
  30818. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30819. * @param postProcess The post process to detach from the camera
  30820. */
  30821. detachPostProcess(postProcess: PostProcess): void;
  30822. /**
  30823. * Gets the current world matrix of the camera
  30824. */
  30825. getWorldMatrix(): Matrix;
  30826. /** @hidden */
  30827. _getViewMatrix(): Matrix;
  30828. /**
  30829. * Gets the current view matrix of the camera.
  30830. * @param force forces the camera to recompute the matrix without looking at the cached state
  30831. * @returns the view matrix
  30832. */
  30833. getViewMatrix(force?: boolean): Matrix;
  30834. /**
  30835. * Freeze the projection matrix.
  30836. * It will prevent the cache check of the camera projection compute and can speed up perf
  30837. * if no parameter of the camera are meant to change
  30838. * @param projection Defines manually a projection if necessary
  30839. */
  30840. freezeProjectionMatrix(projection?: Matrix): void;
  30841. /**
  30842. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30843. */
  30844. unfreezeProjectionMatrix(): void;
  30845. /**
  30846. * Gets the current projection matrix of the camera.
  30847. * @param force forces the camera to recompute the matrix without looking at the cached state
  30848. * @returns the projection matrix
  30849. */
  30850. getProjectionMatrix(force?: boolean): Matrix;
  30851. /**
  30852. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30853. * @returns a Matrix
  30854. */
  30855. getTransformationMatrix(): Matrix;
  30856. private _updateFrustumPlanes;
  30857. /**
  30858. * Checks if a cullable object (mesh...) is in the camera frustum
  30859. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30860. * @param target The object to check
  30861. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30862. * @returns true if the object is in frustum otherwise false
  30863. */
  30864. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30865. /**
  30866. * Checks if a cullable object (mesh...) is in the camera frustum
  30867. * Unlike isInFrustum this cheks the full bounding box
  30868. * @param target The object to check
  30869. * @returns true if the object is in frustum otherwise false
  30870. */
  30871. isCompletelyInFrustum(target: ICullable): boolean;
  30872. /**
  30873. * Gets a ray in the forward direction from the camera.
  30874. * @param length Defines the length of the ray to create
  30875. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30876. * @param origin Defines the start point of the ray which defaults to the camera position
  30877. * @returns the forward ray
  30878. */
  30879. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30880. /**
  30881. * Releases resources associated with this node.
  30882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30884. */
  30885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30886. /** @hidden */
  30887. _isLeftCamera: boolean;
  30888. /**
  30889. * Gets the left camera of a rig setup in case of Rigged Camera
  30890. */
  30891. readonly isLeftCamera: boolean;
  30892. /** @hidden */
  30893. _isRightCamera: boolean;
  30894. /**
  30895. * Gets the right camera of a rig setup in case of Rigged Camera
  30896. */
  30897. readonly isRightCamera: boolean;
  30898. /**
  30899. * Gets the left camera of a rig setup in case of Rigged Camera
  30900. */
  30901. readonly leftCamera: Nullable<FreeCamera>;
  30902. /**
  30903. * Gets the right camera of a rig setup in case of Rigged Camera
  30904. */
  30905. readonly rightCamera: Nullable<FreeCamera>;
  30906. /**
  30907. * Gets the left camera target of a rig setup in case of Rigged Camera
  30908. * @returns the target position
  30909. */
  30910. getLeftTarget(): Nullable<Vector3>;
  30911. /**
  30912. * Gets the right camera target of a rig setup in case of Rigged Camera
  30913. * @returns the target position
  30914. */
  30915. getRightTarget(): Nullable<Vector3>;
  30916. /**
  30917. * @hidden
  30918. */
  30919. setCameraRigMode(mode: number, rigParams: any): void;
  30920. /** @hidden */
  30921. static _setStereoscopicRigMode(camera: Camera): void;
  30922. /** @hidden */
  30923. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30924. /** @hidden */
  30925. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30926. /** @hidden */
  30927. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30928. /** @hidden */
  30929. _getVRProjectionMatrix(): Matrix;
  30930. protected _updateCameraRotationMatrix(): void;
  30931. protected _updateWebVRCameraRotationMatrix(): void;
  30932. /**
  30933. * This function MUST be overwritten by the different WebVR cameras available.
  30934. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30935. * @hidden
  30936. */
  30937. _getWebVRProjectionMatrix(): Matrix;
  30938. /**
  30939. * This function MUST be overwritten by the different WebVR cameras available.
  30940. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30941. * @hidden
  30942. */
  30943. _getWebVRViewMatrix(): Matrix;
  30944. /** @hidden */
  30945. setCameraRigParameter(name: string, value: any): void;
  30946. /**
  30947. * needs to be overridden by children so sub has required properties to be copied
  30948. * @hidden
  30949. */
  30950. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30951. /**
  30952. * May need to be overridden by children
  30953. * @hidden
  30954. */
  30955. _updateRigCameras(): void;
  30956. /** @hidden */
  30957. _setupInputs(): void;
  30958. /**
  30959. * Serialiaze the camera setup to a json represention
  30960. * @returns the JSON representation
  30961. */
  30962. serialize(): any;
  30963. /**
  30964. * Clones the current camera.
  30965. * @param name The cloned camera name
  30966. * @returns the cloned camera
  30967. */
  30968. clone(name: string): Camera;
  30969. /**
  30970. * Gets the direction of the camera relative to a given local axis.
  30971. * @param localAxis Defines the reference axis to provide a relative direction.
  30972. * @return the direction
  30973. */
  30974. getDirection(localAxis: Vector3): Vector3;
  30975. /**
  30976. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30977. * @param localAxis Defines the reference axis to provide a relative direction.
  30978. * @param result Defines the vector to store the result in
  30979. */
  30980. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30981. /**
  30982. * Gets a camera constructor for a given camera type
  30983. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30984. * @param name The name of the camera the result will be able to instantiate
  30985. * @param scene The scene the result will construct the camera in
  30986. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30987. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30988. * @returns a factory method to construc the camera
  30989. */
  30990. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30991. /**
  30992. * Compute the world matrix of the camera.
  30993. * @returns the camera workd matrix
  30994. */
  30995. computeWorldMatrix(): Matrix;
  30996. /**
  30997. * Parse a JSON and creates the camera from the parsed information
  30998. * @param parsedCamera The JSON to parse
  30999. * @param scene The scene to instantiate the camera in
  31000. * @returns the newly constructed camera
  31001. */
  31002. static Parse(parsedCamera: any, scene: Scene): Camera;
  31003. }
  31004. }
  31005. declare module BABYLON {
  31006. /**
  31007. * Interface for any object that can request an animation frame
  31008. */
  31009. export interface ICustomAnimationFrameRequester {
  31010. /**
  31011. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31012. */
  31013. renderFunction?: Function;
  31014. /**
  31015. * Called to request the next frame to render to
  31016. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31017. */
  31018. requestAnimationFrame: Function;
  31019. /**
  31020. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31021. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31022. */
  31023. requestID?: number;
  31024. }
  31025. /**
  31026. * Interface containing an array of animations
  31027. */
  31028. export interface IAnimatable {
  31029. /**
  31030. * Array of animations
  31031. */
  31032. animations: Nullable<Array<Animation>>;
  31033. }
  31034. /** Interface used by value gradients (color, factor, ...) */
  31035. export interface IValueGradient {
  31036. /**
  31037. * Gets or sets the gradient value (between 0 and 1)
  31038. */
  31039. gradient: number;
  31040. }
  31041. /** Class used to store color4 gradient */
  31042. export class ColorGradient implements IValueGradient {
  31043. /**
  31044. * Gets or sets the gradient value (between 0 and 1)
  31045. */
  31046. gradient: number;
  31047. /**
  31048. * Gets or sets first associated color
  31049. */
  31050. color1: Color4;
  31051. /**
  31052. * Gets or sets second associated color
  31053. */
  31054. color2?: Color4;
  31055. /**
  31056. * Will get a color picked randomly between color1 and color2.
  31057. * If color2 is undefined then color1 will be used
  31058. * @param result defines the target Color4 to store the result in
  31059. */
  31060. getColorToRef(result: Color4): void;
  31061. }
  31062. /** Class used to store color 3 gradient */
  31063. export class Color3Gradient implements IValueGradient {
  31064. /**
  31065. * Gets or sets the gradient value (between 0 and 1)
  31066. */
  31067. gradient: number;
  31068. /**
  31069. * Gets or sets the associated color
  31070. */
  31071. color: Color3;
  31072. }
  31073. /** Class used to store factor gradient */
  31074. export class FactorGradient implements IValueGradient {
  31075. /**
  31076. * Gets or sets the gradient value (between 0 and 1)
  31077. */
  31078. gradient: number;
  31079. /**
  31080. * Gets or sets first associated factor
  31081. */
  31082. factor1: number;
  31083. /**
  31084. * Gets or sets second associated factor
  31085. */
  31086. factor2?: number;
  31087. /**
  31088. * Will get a number picked randomly between factor1 and factor2.
  31089. * If factor2 is undefined then factor1 will be used
  31090. * @returns the picked number
  31091. */
  31092. getFactor(): number;
  31093. }
  31094. /**
  31095. * @ignore
  31096. * Application error to support additional information when loading a file
  31097. */
  31098. export class LoadFileError extends Error {
  31099. /** defines the optional web request */
  31100. request?: WebRequest | undefined;
  31101. private static _setPrototypeOf;
  31102. /**
  31103. * Creates a new LoadFileError
  31104. * @param message defines the message of the error
  31105. * @param request defines the optional web request
  31106. */
  31107. constructor(message: string,
  31108. /** defines the optional web request */
  31109. request?: WebRequest | undefined);
  31110. }
  31111. /**
  31112. * Class used to define a retry strategy when error happens while loading assets
  31113. */
  31114. export class RetryStrategy {
  31115. /**
  31116. * Function used to defines an exponential back off strategy
  31117. * @param maxRetries defines the maximum number of retries (3 by default)
  31118. * @param baseInterval defines the interval between retries
  31119. * @returns the strategy function to use
  31120. */
  31121. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31122. }
  31123. /**
  31124. * File request interface
  31125. */
  31126. export interface IFileRequest {
  31127. /**
  31128. * Raised when the request is complete (success or error).
  31129. */
  31130. onCompleteObservable: Observable<IFileRequest>;
  31131. /**
  31132. * Aborts the request for a file.
  31133. */
  31134. abort: () => void;
  31135. }
  31136. /**
  31137. * Class containing a set of static utilities functions
  31138. */
  31139. export class Tools {
  31140. /**
  31141. * Gets or sets the base URL to use to load assets
  31142. */
  31143. static BaseUrl: string;
  31144. /**
  31145. * Enable/Disable Custom HTTP Request Headers globally.
  31146. * default = false
  31147. * @see CustomRequestHeaders
  31148. */
  31149. static UseCustomRequestHeaders: boolean;
  31150. /**
  31151. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31152. * i.e. when loading files, where the server/service expects an Authorization header
  31153. */
  31154. static CustomRequestHeaders: {
  31155. [key: string]: string;
  31156. };
  31157. /**
  31158. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31159. */
  31160. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31161. /**
  31162. * Default behaviour for cors in the application.
  31163. * It can be a string if the expected behavior is identical in the entire app.
  31164. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31165. */
  31166. static CorsBehavior: string | ((url: string | string[]) => string);
  31167. /**
  31168. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31169. * @ignorenaming
  31170. */
  31171. static UseFallbackTexture: boolean;
  31172. /**
  31173. * Use this object to register external classes like custom textures or material
  31174. * to allow the laoders to instantiate them
  31175. */
  31176. static RegisteredExternalClasses: {
  31177. [key: string]: Object;
  31178. };
  31179. /**
  31180. * Texture content used if a texture cannot loaded
  31181. * @ignorenaming
  31182. */
  31183. static fallbackTexture: string;
  31184. /**
  31185. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31186. * @param u defines the coordinate on X axis
  31187. * @param v defines the coordinate on Y axis
  31188. * @param width defines the width of the source data
  31189. * @param height defines the height of the source data
  31190. * @param pixels defines the source byte array
  31191. * @param color defines the output color
  31192. */
  31193. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31194. /**
  31195. * Interpolates between a and b via alpha
  31196. * @param a The lower value (returned when alpha = 0)
  31197. * @param b The upper value (returned when alpha = 1)
  31198. * @param alpha The interpolation-factor
  31199. * @return The mixed value
  31200. */
  31201. static Mix(a: number, b: number, alpha: number): number;
  31202. /**
  31203. * Tries to instantiate a new object from a given class name
  31204. * @param className defines the class name to instantiate
  31205. * @returns the new object or null if the system was not able to do the instantiation
  31206. */
  31207. static Instantiate(className: string): any;
  31208. /**
  31209. * Provides a slice function that will work even on IE
  31210. * @param data defines the array to slice
  31211. * @param start defines the start of the data (optional)
  31212. * @param end defines the end of the data (optional)
  31213. * @returns the new sliced array
  31214. */
  31215. static Slice<T>(data: T, start?: number, end?: number): T;
  31216. /**
  31217. * Polyfill for setImmediate
  31218. * @param action defines the action to execute after the current execution block
  31219. */
  31220. static SetImmediate(action: () => void): void;
  31221. /**
  31222. * Function indicating if a number is an exponent of 2
  31223. * @param value defines the value to test
  31224. * @returns true if the value is an exponent of 2
  31225. */
  31226. static IsExponentOfTwo(value: number): boolean;
  31227. private static _tmpFloatArray;
  31228. /**
  31229. * Returns the nearest 32-bit single precision float representation of a Number
  31230. * @param value A Number. If the parameter is of a different type, it will get converted
  31231. * to a number or to NaN if it cannot be converted
  31232. * @returns number
  31233. */
  31234. static FloatRound(value: number): number;
  31235. /**
  31236. * Find the next highest power of two.
  31237. * @param x Number to start search from.
  31238. * @return Next highest power of two.
  31239. */
  31240. static CeilingPOT(x: number): number;
  31241. /**
  31242. * Find the next lowest power of two.
  31243. * @param x Number to start search from.
  31244. * @return Next lowest power of two.
  31245. */
  31246. static FloorPOT(x: number): number;
  31247. /**
  31248. * Find the nearest power of two.
  31249. * @param x Number to start search from.
  31250. * @return Next nearest power of two.
  31251. */
  31252. static NearestPOT(x: number): number;
  31253. /**
  31254. * Get the closest exponent of two
  31255. * @param value defines the value to approximate
  31256. * @param max defines the maximum value to return
  31257. * @param mode defines how to define the closest value
  31258. * @returns closest exponent of two of the given value
  31259. */
  31260. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31261. /**
  31262. * Extracts the filename from a path
  31263. * @param path defines the path to use
  31264. * @returns the filename
  31265. */
  31266. static GetFilename(path: string): string;
  31267. /**
  31268. * Extracts the "folder" part of a path (everything before the filename).
  31269. * @param uri The URI to extract the info from
  31270. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31271. * @returns The "folder" part of the path
  31272. */
  31273. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31274. /**
  31275. * Extracts text content from a DOM element hierarchy
  31276. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31277. */
  31278. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31279. /**
  31280. * Convert an angle in radians to degrees
  31281. * @param angle defines the angle to convert
  31282. * @returns the angle in degrees
  31283. */
  31284. static ToDegrees(angle: number): number;
  31285. /**
  31286. * Convert an angle in degrees to radians
  31287. * @param angle defines the angle to convert
  31288. * @returns the angle in radians
  31289. */
  31290. static ToRadians(angle: number): number;
  31291. /**
  31292. * Encode a buffer to a base64 string
  31293. * @param buffer defines the buffer to encode
  31294. * @returns the encoded string
  31295. */
  31296. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31297. /**
  31298. * Extracts minimum and maximum values from a list of indexed positions
  31299. * @param positions defines the positions to use
  31300. * @param indices defines the indices to the positions
  31301. * @param indexStart defines the start index
  31302. * @param indexCount defines the end index
  31303. * @param bias defines bias value to add to the result
  31304. * @return minimum and maximum values
  31305. */
  31306. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31307. minimum: Vector3;
  31308. maximum: Vector3;
  31309. };
  31310. /**
  31311. * Extracts minimum and maximum values from a list of positions
  31312. * @param positions defines the positions to use
  31313. * @param start defines the start index in the positions array
  31314. * @param count defines the number of positions to handle
  31315. * @param bias defines bias value to add to the result
  31316. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31317. * @return minimum and maximum values
  31318. */
  31319. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31320. minimum: Vector3;
  31321. maximum: Vector3;
  31322. };
  31323. /**
  31324. * Returns an array if obj is not an array
  31325. * @param obj defines the object to evaluate as an array
  31326. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31327. * @returns either obj directly if obj is an array or a new array containing obj
  31328. */
  31329. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31330. /**
  31331. * Gets the pointer prefix to use
  31332. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31333. */
  31334. static GetPointerPrefix(): string;
  31335. /**
  31336. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31337. * @param func - the function to be called
  31338. * @param requester - the object that will request the next frame. Falls back to window.
  31339. * @returns frame number
  31340. */
  31341. static QueueNewFrame(func: () => void, requester?: any): number;
  31342. /**
  31343. * Ask the browser to promote the current element to fullscreen rendering mode
  31344. * @param element defines the DOM element to promote
  31345. */
  31346. static RequestFullscreen(element: HTMLElement): void;
  31347. /**
  31348. * Asks the browser to exit fullscreen mode
  31349. */
  31350. static ExitFullscreen(): void;
  31351. /**
  31352. * Ask the browser to promote the current element to pointerlock mode
  31353. * @param element defines the DOM element to promote
  31354. */
  31355. static RequestPointerlock(element: HTMLElement): void;
  31356. /**
  31357. * Asks the browser to exit pointerlock mode
  31358. */
  31359. static ExitPointerlock(): void;
  31360. /**
  31361. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31362. * @param url define the url we are trying
  31363. * @param element define the dom element where to configure the cors policy
  31364. */
  31365. static SetCorsBehavior(url: string | string[], element: {
  31366. crossOrigin: string | null;
  31367. }): void;
  31368. /**
  31369. * Removes unwanted characters from an url
  31370. * @param url defines the url to clean
  31371. * @returns the cleaned url
  31372. */
  31373. static CleanUrl(url: string): string;
  31374. /**
  31375. * Gets or sets a function used to pre-process url before using them to load assets
  31376. */
  31377. static PreprocessUrl: (url: string) => string;
  31378. /**
  31379. * Loads an image as an HTMLImageElement.
  31380. * @param input url string, ArrayBuffer, or Blob to load
  31381. * @param onLoad callback called when the image successfully loads
  31382. * @param onError callback called when the image fails to load
  31383. * @param offlineProvider offline provider for caching
  31384. * @returns the HTMLImageElement of the loaded image
  31385. */
  31386. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31387. /**
  31388. * Loads a file
  31389. * @param url url string, ArrayBuffer, or Blob to load
  31390. * @param onSuccess callback called when the file successfully loads
  31391. * @param onProgress callback called while file is loading (if the server supports this mode)
  31392. * @param offlineProvider defines the offline provider for caching
  31393. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31394. * @param onError callback called when the file fails to load
  31395. * @returns a file request object
  31396. */
  31397. 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;
  31398. /**
  31399. * Loads a file from a url
  31400. * @param url the file url to load
  31401. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31402. */
  31403. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31404. /**
  31405. * Load a script (identified by an url). When the url returns, the
  31406. * content of this file is added into a new script element, attached to the DOM (body element)
  31407. * @param scriptUrl defines the url of the script to laod
  31408. * @param onSuccess defines the callback called when the script is loaded
  31409. * @param onError defines the callback to call if an error occurs
  31410. * @param scriptId defines the id of the script element
  31411. */
  31412. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31413. /**
  31414. * Load an asynchronous script (identified by an url). When the url returns, the
  31415. * content of this file is added into a new script element, attached to the DOM (body element)
  31416. * @param scriptUrl defines the url of the script to laod
  31417. * @param scriptId defines the id of the script element
  31418. * @returns a promise request object
  31419. */
  31420. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31421. /**
  31422. * Loads a file from a blob
  31423. * @param fileToLoad defines the blob to use
  31424. * @param callback defines the callback to call when data is loaded
  31425. * @param progressCallback defines the callback to call during loading process
  31426. * @returns a file request object
  31427. */
  31428. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31429. /**
  31430. * Loads a file
  31431. * @param fileToLoad defines the file to load
  31432. * @param callback defines the callback to call when data is loaded
  31433. * @param progressCallBack defines the callback to call during loading process
  31434. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31435. * @returns a file request object
  31436. */
  31437. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31438. /**
  31439. * Creates a data url from a given string content
  31440. * @param content defines the content to convert
  31441. * @returns the new data url link
  31442. */
  31443. static FileAsURL(content: string): string;
  31444. /**
  31445. * Format the given number to a specific decimal format
  31446. * @param value defines the number to format
  31447. * @param decimals defines the number of decimals to use
  31448. * @returns the formatted string
  31449. */
  31450. static Format(value: number, decimals?: number): string;
  31451. /**
  31452. * Checks if a given vector is inside a specific range
  31453. * @param v defines the vector to test
  31454. * @param min defines the minimum range
  31455. * @param max defines the maximum range
  31456. */
  31457. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31458. /**
  31459. * Tries to copy an object by duplicating every property
  31460. * @param source defines the source object
  31461. * @param destination defines the target object
  31462. * @param doNotCopyList defines a list of properties to avoid
  31463. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31464. */
  31465. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31466. /**
  31467. * Gets a boolean indicating if the given object has no own property
  31468. * @param obj defines the object to test
  31469. * @returns true if object has no own property
  31470. */
  31471. static IsEmpty(obj: any): boolean;
  31472. /**
  31473. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31474. * @param str Source string
  31475. * @param suffix Suffix to search for in the source string
  31476. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31477. */
  31478. static EndsWith(str: string, suffix: string): boolean;
  31479. /**
  31480. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31481. * @param str Source string
  31482. * @param suffix Suffix to search for in the source string
  31483. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31484. */
  31485. static StartsWith(str: string, suffix: string): boolean;
  31486. /**
  31487. * Function used to register events at window level
  31488. * @param events defines the events to register
  31489. */
  31490. static RegisterTopRootEvents(events: {
  31491. name: string;
  31492. handler: Nullable<(e: FocusEvent) => any>;
  31493. }[]): void;
  31494. /**
  31495. * Function used to unregister events from window level
  31496. * @param events defines the events to unregister
  31497. */
  31498. static UnregisterTopRootEvents(events: {
  31499. name: string;
  31500. handler: Nullable<(e: FocusEvent) => any>;
  31501. }[]): void;
  31502. /**
  31503. * @ignore
  31504. */
  31505. static _ScreenshotCanvas: HTMLCanvasElement;
  31506. /**
  31507. * Dumps the current bound framebuffer
  31508. * @param width defines the rendering width
  31509. * @param height defines the rendering height
  31510. * @param engine defines the hosting engine
  31511. * @param successCallback defines the callback triggered once the data are available
  31512. * @param mimeType defines the mime type of the result
  31513. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31514. */
  31515. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31516. /**
  31517. * Converts the canvas data to blob.
  31518. * This acts as a polyfill for browsers not supporting the to blob function.
  31519. * @param canvas Defines the canvas to extract the data from
  31520. * @param successCallback Defines the callback triggered once the data are available
  31521. * @param mimeType Defines the mime type of the result
  31522. */
  31523. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31524. /**
  31525. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31526. * @param successCallback defines the callback triggered once the data are available
  31527. * @param mimeType defines the mime type of the result
  31528. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31529. */
  31530. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31531. /**
  31532. * Downloads a blob in the browser
  31533. * @param blob defines the blob to download
  31534. * @param fileName defines the name of the downloaded file
  31535. */
  31536. static Download(blob: Blob, fileName: string): void;
  31537. /**
  31538. * Captures a screenshot of the current rendering
  31539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31540. * @param engine defines the rendering engine
  31541. * @param camera defines the source camera
  31542. * @param size This parameter can be set to a single number or to an object with the
  31543. * following (optional) properties: precision, width, height. If a single number is passed,
  31544. * it will be used for both width and height. If an object is passed, the screenshot size
  31545. * will be derived from the parameters. The precision property is a multiplier allowing
  31546. * rendering at a higher or lower resolution
  31547. * @param successCallback defines the callback receives a single parameter which contains the
  31548. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31549. * src parameter of an <img> to display it
  31550. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31551. * Check your browser for supported MIME types
  31552. */
  31553. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31554. /**
  31555. * Generates an image screenshot from the specified camera.
  31556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31557. * @param engine The engine to use for rendering
  31558. * @param camera The camera to use for rendering
  31559. * @param size This parameter can be set to a single number or to an object with the
  31560. * following (optional) properties: precision, width, height. If a single number is passed,
  31561. * it will be used for both width and height. If an object is passed, the screenshot size
  31562. * will be derived from the parameters. The precision property is a multiplier allowing
  31563. * rendering at a higher or lower resolution
  31564. * @param successCallback The callback receives a single parameter which contains the
  31565. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31566. * src parameter of an <img> to display it
  31567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31568. * Check your browser for supported MIME types
  31569. * @param samples Texture samples (default: 1)
  31570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31571. * @param fileName A name for for the downloaded file.
  31572. */
  31573. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31574. /**
  31575. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31576. * Be aware Math.random() could cause collisions, but:
  31577. * "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"
  31578. * @returns a pseudo random id
  31579. */
  31580. static RandomId(): string;
  31581. /**
  31582. * Test if the given uri is a base64 string
  31583. * @param uri The uri to test
  31584. * @return True if the uri is a base64 string or false otherwise
  31585. */
  31586. static IsBase64(uri: string): boolean;
  31587. /**
  31588. * Decode the given base64 uri.
  31589. * @param uri The uri to decode
  31590. * @return The decoded base64 data.
  31591. */
  31592. static DecodeBase64(uri: string): ArrayBuffer;
  31593. /**
  31594. * Gets the absolute url.
  31595. * @param url the input url
  31596. * @return the absolute url
  31597. */
  31598. static GetAbsoluteUrl(url: string): string;
  31599. /**
  31600. * No log
  31601. */
  31602. static readonly NoneLogLevel: number;
  31603. /**
  31604. * Only message logs
  31605. */
  31606. static readonly MessageLogLevel: number;
  31607. /**
  31608. * Only warning logs
  31609. */
  31610. static readonly WarningLogLevel: number;
  31611. /**
  31612. * Only error logs
  31613. */
  31614. static readonly ErrorLogLevel: number;
  31615. /**
  31616. * All logs
  31617. */
  31618. static readonly AllLogLevel: number;
  31619. /**
  31620. * Gets a value indicating the number of loading errors
  31621. * @ignorenaming
  31622. */
  31623. static readonly errorsCount: number;
  31624. /**
  31625. * Callback called when a new log is added
  31626. */
  31627. static OnNewCacheEntry: (entry: string) => void;
  31628. /**
  31629. * Log a message to the console
  31630. * @param message defines the message to log
  31631. */
  31632. static Log(message: string): void;
  31633. /**
  31634. * Write a warning message to the console
  31635. * @param message defines the message to log
  31636. */
  31637. static Warn(message: string): void;
  31638. /**
  31639. * Write an error message to the console
  31640. * @param message defines the message to log
  31641. */
  31642. static Error(message: string): void;
  31643. /**
  31644. * Gets current log cache (list of logs)
  31645. */
  31646. static readonly LogCache: string;
  31647. /**
  31648. * Clears the log cache
  31649. */
  31650. static ClearLogCache(): void;
  31651. /**
  31652. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31653. */
  31654. static LogLevels: number;
  31655. /**
  31656. * Checks if the loaded document was accessed via `file:`-Protocol.
  31657. * @returns boolean
  31658. */
  31659. static IsFileURL(): boolean;
  31660. /**
  31661. * Checks if the window object exists
  31662. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31663. */
  31664. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31665. /**
  31666. * No performance log
  31667. */
  31668. static readonly PerformanceNoneLogLevel: number;
  31669. /**
  31670. * Use user marks to log performance
  31671. */
  31672. static readonly PerformanceUserMarkLogLevel: number;
  31673. /**
  31674. * Log performance to the console
  31675. */
  31676. static readonly PerformanceConsoleLogLevel: number;
  31677. private static _performance;
  31678. /**
  31679. * Sets the current performance log level
  31680. */
  31681. static PerformanceLogLevel: number;
  31682. private static _StartPerformanceCounterDisabled;
  31683. private static _EndPerformanceCounterDisabled;
  31684. private static _StartUserMark;
  31685. private static _EndUserMark;
  31686. private static _StartPerformanceConsole;
  31687. private static _EndPerformanceConsole;
  31688. /**
  31689. * Starts a performance counter
  31690. */
  31691. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31692. /**
  31693. * Ends a specific performance coutner
  31694. */
  31695. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31696. /**
  31697. * Gets either window.performance.now() if supported or Date.now() else
  31698. */
  31699. static readonly Now: number;
  31700. /**
  31701. * This method will return the name of the class used to create the instance of the given object.
  31702. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31703. * @param object the object to get the class name from
  31704. * @param isType defines if the object is actually a type
  31705. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31706. */
  31707. static GetClassName(object: any, isType?: boolean): string;
  31708. /**
  31709. * Gets the first element of an array satisfying a given predicate
  31710. * @param array defines the array to browse
  31711. * @param predicate defines the predicate to use
  31712. * @returns null if not found or the element
  31713. */
  31714. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31715. /**
  31716. * This method will return the name of the full name of the class, including its owning module (if any).
  31717. * 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).
  31718. * @param object the object to get the class name from
  31719. * @param isType defines if the object is actually a type
  31720. * @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.
  31721. * @ignorenaming
  31722. */
  31723. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31724. /**
  31725. * Returns a promise that resolves after the given amount of time.
  31726. * @param delay Number of milliseconds to delay
  31727. * @returns Promise that resolves after the given amount of time
  31728. */
  31729. static DelayAsync(delay: number): Promise<void>;
  31730. /**
  31731. * Gets the current gradient from an array of IValueGradient
  31732. * @param ratio defines the current ratio to get
  31733. * @param gradients defines the array of IValueGradient
  31734. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31735. */
  31736. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31737. }
  31738. /**
  31739. * This class is used to track a performance counter which is number based.
  31740. * The user has access to many properties which give statistics of different nature.
  31741. *
  31742. * The implementer can track two kinds of Performance Counter: time and count.
  31743. * 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.
  31744. * 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.
  31745. */
  31746. export class PerfCounter {
  31747. /**
  31748. * Gets or sets a global boolean to turn on and off all the counters
  31749. */
  31750. static Enabled: boolean;
  31751. /**
  31752. * Returns the smallest value ever
  31753. */
  31754. readonly min: number;
  31755. /**
  31756. * Returns the biggest value ever
  31757. */
  31758. readonly max: number;
  31759. /**
  31760. * Returns the average value since the performance counter is running
  31761. */
  31762. readonly average: number;
  31763. /**
  31764. * Returns the average value of the last second the counter was monitored
  31765. */
  31766. readonly lastSecAverage: number;
  31767. /**
  31768. * Returns the current value
  31769. */
  31770. readonly current: number;
  31771. /**
  31772. * Gets the accumulated total
  31773. */
  31774. readonly total: number;
  31775. /**
  31776. * Gets the total value count
  31777. */
  31778. readonly count: number;
  31779. /**
  31780. * Creates a new counter
  31781. */
  31782. constructor();
  31783. /**
  31784. * Call this method to start monitoring a new frame.
  31785. * 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.
  31786. */
  31787. fetchNewFrame(): void;
  31788. /**
  31789. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31790. * @param newCount the count value to add to the monitored count
  31791. * @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.
  31792. */
  31793. addCount(newCount: number, fetchResult: boolean): void;
  31794. /**
  31795. * Start monitoring this performance counter
  31796. */
  31797. beginMonitoring(): void;
  31798. /**
  31799. * Compute the time lapsed since the previous beginMonitoring() call.
  31800. * @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
  31801. */
  31802. endMonitoring(newFrame?: boolean): void;
  31803. private _fetchResult;
  31804. private _startMonitoringTime;
  31805. private _min;
  31806. private _max;
  31807. private _average;
  31808. private _current;
  31809. private _totalValueCount;
  31810. private _totalAccumulated;
  31811. private _lastSecAverage;
  31812. private _lastSecAccumulated;
  31813. private _lastSecTime;
  31814. private _lastSecValueCount;
  31815. }
  31816. /**
  31817. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31818. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31819. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31820. * @param name The name of the class, case should be preserved
  31821. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31822. */
  31823. export function className(name: string, module?: string): (target: Object) => void;
  31824. /**
  31825. * An implementation of a loop for asynchronous functions.
  31826. */
  31827. export class AsyncLoop {
  31828. /**
  31829. * Defines the number of iterations for the loop
  31830. */
  31831. iterations: number;
  31832. /**
  31833. * Defines the current index of the loop.
  31834. */
  31835. index: number;
  31836. private _done;
  31837. private _fn;
  31838. private _successCallback;
  31839. /**
  31840. * Constructor.
  31841. * @param iterations the number of iterations.
  31842. * @param func the function to run each iteration
  31843. * @param successCallback the callback that will be called upon succesful execution
  31844. * @param offset starting offset.
  31845. */
  31846. constructor(
  31847. /**
  31848. * Defines the number of iterations for the loop
  31849. */
  31850. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31851. /**
  31852. * Execute the next iteration. Must be called after the last iteration was finished.
  31853. */
  31854. executeNext(): void;
  31855. /**
  31856. * Break the loop and run the success callback.
  31857. */
  31858. breakLoop(): void;
  31859. /**
  31860. * Create and run an async loop.
  31861. * @param iterations the number of iterations.
  31862. * @param fn the function to run each iteration
  31863. * @param successCallback the callback that will be called upon succesful execution
  31864. * @param offset starting offset.
  31865. * @returns the created async loop object
  31866. */
  31867. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31868. /**
  31869. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31870. * @param iterations total number of iterations
  31871. * @param syncedIterations number of synchronous iterations in each async iteration.
  31872. * @param fn the function to call each iteration.
  31873. * @param callback a success call back that will be called when iterating stops.
  31874. * @param breakFunction a break condition (optional)
  31875. * @param timeout timeout settings for the setTimeout function. default - 0.
  31876. * @returns the created async loop object
  31877. */
  31878. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31879. }
  31880. }
  31881. declare module BABYLON {
  31882. /** @hidden */
  31883. export interface ICollisionCoordinator {
  31884. createCollider(): Collider;
  31885. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31886. init(scene: Scene): void;
  31887. }
  31888. /** @hidden */
  31889. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31890. private _scene;
  31891. private _scaledPosition;
  31892. private _scaledVelocity;
  31893. private _finalPosition;
  31894. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31895. createCollider(): Collider;
  31896. init(scene: Scene): void;
  31897. private _collideWithWorld;
  31898. }
  31899. }
  31900. declare module BABYLON {
  31901. /**
  31902. * Class used to manage all inputs for the scene.
  31903. */
  31904. export class InputManager {
  31905. /** The distance in pixel that you have to move to prevent some events */
  31906. static DragMovementThreshold: number;
  31907. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31908. static LongPressDelay: number;
  31909. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31910. static DoubleClickDelay: number;
  31911. /** If you need to check double click without raising a single click at first click, enable this flag */
  31912. static ExclusiveDoubleClickMode: boolean;
  31913. private _wheelEventName;
  31914. private _onPointerMove;
  31915. private _onPointerDown;
  31916. private _onPointerUp;
  31917. private _initClickEvent;
  31918. private _initActionManager;
  31919. private _delayedSimpleClick;
  31920. private _delayedSimpleClickTimeout;
  31921. private _previousDelayedSimpleClickTimeout;
  31922. private _meshPickProceed;
  31923. private _previousButtonPressed;
  31924. private _currentPickResult;
  31925. private _previousPickResult;
  31926. private _totalPointersPressed;
  31927. private _doubleClickOccured;
  31928. private _pointerOverMesh;
  31929. private _pickedDownMesh;
  31930. private _pickedUpMesh;
  31931. private _pointerX;
  31932. private _pointerY;
  31933. private _unTranslatedPointerX;
  31934. private _unTranslatedPointerY;
  31935. private _startingPointerPosition;
  31936. private _previousStartingPointerPosition;
  31937. private _startingPointerTime;
  31938. private _previousStartingPointerTime;
  31939. private _pointerCaptures;
  31940. private _onKeyDown;
  31941. private _onKeyUp;
  31942. private _onCanvasFocusObserver;
  31943. private _onCanvasBlurObserver;
  31944. private _scene;
  31945. /**
  31946. * Creates a new InputManager
  31947. * @param scene defines the hosting scene
  31948. */
  31949. constructor(scene: Scene);
  31950. /**
  31951. * Gets the mesh that is currently under the pointer
  31952. */
  31953. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31954. /**
  31955. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31956. */
  31957. readonly unTranslatedPointer: Vector2;
  31958. /**
  31959. * Gets or sets the current on-screen X position of the pointer
  31960. */
  31961. pointerX: number;
  31962. /**
  31963. * Gets or sets the current on-screen Y position of the pointer
  31964. */
  31965. pointerY: number;
  31966. private _updatePointerPosition;
  31967. private _processPointerMove;
  31968. private _setRayOnPointerInfo;
  31969. private _checkPrePointerObservable;
  31970. /**
  31971. * Use this method to simulate a pointer move on a mesh
  31972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31975. */
  31976. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31977. /**
  31978. * Use this method to simulate a pointer down on a mesh
  31979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31982. */
  31983. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31984. private _processPointerDown;
  31985. /** @hidden */
  31986. _isPointerSwiping(): boolean;
  31987. /**
  31988. * Use this method to simulate a pointer up on a mesh
  31989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31992. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31993. */
  31994. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31995. private _processPointerUp;
  31996. /**
  31997. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31998. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31999. * @returns true if the pointer was captured
  32000. */
  32001. isPointerCaptured(pointerId?: number): boolean;
  32002. /**
  32003. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32004. * @param attachUp defines if you want to attach events to pointerup
  32005. * @param attachDown defines if you want to attach events to pointerdown
  32006. * @param attachMove defines if you want to attach events to pointermove
  32007. */
  32008. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32009. /**
  32010. * Detaches all event handlers
  32011. */
  32012. detachControl(): void;
  32013. /**
  32014. * Force the value of meshUnderPointer
  32015. * @param mesh defines the mesh to use
  32016. */
  32017. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32018. /**
  32019. * Gets the mesh under the pointer
  32020. * @returns a Mesh or null if no mesh is under the pointer
  32021. */
  32022. getPointerOverMesh(): Nullable<AbstractMesh>;
  32023. }
  32024. }
  32025. declare module BABYLON {
  32026. /**
  32027. * This class defines the direct association between an animation and a target
  32028. */
  32029. export class TargetedAnimation {
  32030. /**
  32031. * Animation to perform
  32032. */
  32033. animation: Animation;
  32034. /**
  32035. * Target to animate
  32036. */
  32037. target: any;
  32038. /**
  32039. * Serialize the object
  32040. * @returns the JSON object representing the current entity
  32041. */
  32042. serialize(): any;
  32043. }
  32044. /**
  32045. * Use this class to create coordinated animations on multiple targets
  32046. */
  32047. export class AnimationGroup implements IDisposable {
  32048. /** The name of the animation group */
  32049. name: string;
  32050. private _scene;
  32051. private _targetedAnimations;
  32052. private _animatables;
  32053. private _from;
  32054. private _to;
  32055. private _isStarted;
  32056. private _isPaused;
  32057. private _speedRatio;
  32058. private _loopAnimation;
  32059. /**
  32060. * Gets or sets the unique id of the node
  32061. */
  32062. uniqueId: number;
  32063. /**
  32064. * This observable will notify when one animation have ended
  32065. */
  32066. onAnimationEndObservable: Observable<TargetedAnimation>;
  32067. /**
  32068. * Observer raised when one animation loops
  32069. */
  32070. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32071. /**
  32072. * This observable will notify when all animations have ended.
  32073. */
  32074. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32075. /**
  32076. * This observable will notify when all animations have paused.
  32077. */
  32078. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32079. /**
  32080. * This observable will notify when all animations are playing.
  32081. */
  32082. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32083. /**
  32084. * Gets the first frame
  32085. */
  32086. readonly from: number;
  32087. /**
  32088. * Gets the last frame
  32089. */
  32090. readonly to: number;
  32091. /**
  32092. * Define if the animations are started
  32093. */
  32094. readonly isStarted: boolean;
  32095. /**
  32096. * Gets a value indicating that the current group is playing
  32097. */
  32098. readonly isPlaying: boolean;
  32099. /**
  32100. * Gets or sets the speed ratio to use for all animations
  32101. */
  32102. /**
  32103. * Gets or sets the speed ratio to use for all animations
  32104. */
  32105. speedRatio: number;
  32106. /**
  32107. * Gets or sets if all animations should loop or not
  32108. */
  32109. loopAnimation: boolean;
  32110. /**
  32111. * Gets the targeted animations for this animation group
  32112. */
  32113. readonly targetedAnimations: Array<TargetedAnimation>;
  32114. /**
  32115. * returning the list of animatables controlled by this animation group.
  32116. */
  32117. readonly animatables: Array<Animatable>;
  32118. /**
  32119. * Instantiates a new Animation Group.
  32120. * This helps managing several animations at once.
  32121. * @see http://doc.babylonjs.com/how_to/group
  32122. * @param name Defines the name of the group
  32123. * @param scene Defines the scene the group belongs to
  32124. */
  32125. constructor(
  32126. /** The name of the animation group */
  32127. name: string, scene?: Nullable<Scene>);
  32128. /**
  32129. * Add an animation (with its target) in the group
  32130. * @param animation defines the animation we want to add
  32131. * @param target defines the target of the animation
  32132. * @returns the TargetedAnimation object
  32133. */
  32134. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32135. /**
  32136. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32137. * It can add constant keys at begin or end
  32138. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32139. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32140. * @returns the animation group
  32141. */
  32142. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32143. /**
  32144. * Start all animations on given targets
  32145. * @param loop defines if animations must loop
  32146. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32147. * @param from defines the from key (optional)
  32148. * @param to defines the to key (optional)
  32149. * @returns the current animation group
  32150. */
  32151. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32152. /**
  32153. * Pause all animations
  32154. * @returns the animation group
  32155. */
  32156. pause(): AnimationGroup;
  32157. /**
  32158. * Play all animations to initial state
  32159. * This function will start() the animations if they were not started or will restart() them if they were paused
  32160. * @param loop defines if animations must loop
  32161. * @returns the animation group
  32162. */
  32163. play(loop?: boolean): AnimationGroup;
  32164. /**
  32165. * Reset all animations to initial state
  32166. * @returns the animation group
  32167. */
  32168. reset(): AnimationGroup;
  32169. /**
  32170. * Restart animations from key 0
  32171. * @returns the animation group
  32172. */
  32173. restart(): AnimationGroup;
  32174. /**
  32175. * Stop all animations
  32176. * @returns the animation group
  32177. */
  32178. stop(): AnimationGroup;
  32179. /**
  32180. * Set animation weight for all animatables
  32181. * @param weight defines the weight to use
  32182. * @return the animationGroup
  32183. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32184. */
  32185. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32186. /**
  32187. * Synchronize and normalize all animatables with a source animatable
  32188. * @param root defines the root animatable to synchronize with
  32189. * @return the animationGroup
  32190. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32191. */
  32192. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32193. /**
  32194. * Goes to a specific frame in this animation group
  32195. * @param frame the frame number to go to
  32196. * @return the animationGroup
  32197. */
  32198. goToFrame(frame: number): AnimationGroup;
  32199. /**
  32200. * Dispose all associated resources
  32201. */
  32202. dispose(): void;
  32203. private _checkAnimationGroupEnded;
  32204. /**
  32205. * Clone the current animation group and returns a copy
  32206. * @param newName defines the name of the new group
  32207. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32208. * @returns the new aniamtion group
  32209. */
  32210. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32211. /**
  32212. * Serializes the animationGroup to an object
  32213. * @returns Serialized object
  32214. */
  32215. serialize(): any;
  32216. /**
  32217. * Returns a new AnimationGroup object parsed from the source provided.
  32218. * @param parsedAnimationGroup defines the source
  32219. * @param scene defines the scene that will receive the animationGroup
  32220. * @returns a new AnimationGroup
  32221. */
  32222. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32223. /**
  32224. * Returns the string "AnimationGroup"
  32225. * @returns "AnimationGroup"
  32226. */
  32227. getClassName(): string;
  32228. /**
  32229. * Creates a detailled string about the object
  32230. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32231. * @returns a string representing the object
  32232. */
  32233. toString(fullDetails?: boolean): string;
  32234. }
  32235. }
  32236. declare module BABYLON {
  32237. /**
  32238. * Define an interface for all classes that will hold resources
  32239. */
  32240. export interface IDisposable {
  32241. /**
  32242. * Releases all held resources
  32243. */
  32244. dispose(): void;
  32245. }
  32246. /** Interface defining initialization parameters for Scene class */
  32247. export interface SceneOptions {
  32248. /**
  32249. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32250. * It will improve performance when the number of geometries becomes important.
  32251. */
  32252. useGeometryUniqueIdsMap?: boolean;
  32253. /**
  32254. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32256. */
  32257. useMaterialMeshMap?: boolean;
  32258. /**
  32259. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32260. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32261. */
  32262. useClonedMeshhMap?: boolean;
  32263. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32264. virtual?: boolean;
  32265. }
  32266. /**
  32267. * Represents a scene to be rendered by the engine.
  32268. * @see http://doc.babylonjs.com/features/scene
  32269. */
  32270. export class Scene extends AbstractScene implements IAnimatable {
  32271. private static _uniqueIdCounter;
  32272. /** The fog is deactivated */
  32273. static readonly FOGMODE_NONE: number;
  32274. /** The fog density is following an exponential function */
  32275. static readonly FOGMODE_EXP: number;
  32276. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32277. static readonly FOGMODE_EXP2: number;
  32278. /** The fog density is following a linear function. */
  32279. static readonly FOGMODE_LINEAR: number;
  32280. /**
  32281. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32282. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32283. */
  32284. static MinDeltaTime: number;
  32285. /**
  32286. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32287. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32288. */
  32289. static MaxDeltaTime: number;
  32290. /**
  32291. * Factory used to create the default material.
  32292. * @param name The name of the material to create
  32293. * @param scene The scene to create the material for
  32294. * @returns The default material
  32295. */
  32296. static DefaultMaterialFactory(scene: Scene): Material;
  32297. /**
  32298. * Factory used to create the a collision coordinator.
  32299. * @returns The collision coordinator
  32300. */
  32301. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32302. /** @hidden */
  32303. _inputManager: InputManager;
  32304. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32305. cameraToUseForPointers: Nullable<Camera>;
  32306. /** @hidden */
  32307. readonly _isScene: boolean;
  32308. /**
  32309. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32310. */
  32311. autoClear: boolean;
  32312. /**
  32313. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32314. */
  32315. autoClearDepthAndStencil: boolean;
  32316. /**
  32317. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32318. */
  32319. clearColor: Color4;
  32320. /**
  32321. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32322. */
  32323. ambientColor: Color3;
  32324. /**
  32325. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32326. * It should only be one of the following (if not the default embedded one):
  32327. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32328. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32329. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32330. * The material properties need to be setup according to the type of texture in use.
  32331. */
  32332. environmentBRDFTexture: BaseTexture;
  32333. /** @hidden */
  32334. protected _environmentTexture: Nullable<BaseTexture>;
  32335. /**
  32336. * Texture used in all pbr material as the reflection texture.
  32337. * As in the majority of the scene they are the same (exception for multi room and so on),
  32338. * this is easier to reference from here than from all the materials.
  32339. */
  32340. /**
  32341. * Texture used in all pbr material as the reflection texture.
  32342. * As in the majority of the scene they are the same (exception for multi room and so on),
  32343. * this is easier to set here than in all the materials.
  32344. */
  32345. environmentTexture: Nullable<BaseTexture>;
  32346. /** @hidden */
  32347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32348. /**
  32349. * Default image processing configuration used either in the rendering
  32350. * Forward main pass or through the imageProcessingPostProcess if present.
  32351. * As in the majority of the scene they are the same (exception for multi camera),
  32352. * this is easier to reference from here than from all the materials and post process.
  32353. *
  32354. * No setter as we it is a shared configuration, you can set the values instead.
  32355. */
  32356. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32357. private _forceWireframe;
  32358. /**
  32359. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32360. */
  32361. forceWireframe: boolean;
  32362. private _forcePointsCloud;
  32363. /**
  32364. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32365. */
  32366. forcePointsCloud: boolean;
  32367. /**
  32368. * Gets or sets the active clipplane 1
  32369. */
  32370. clipPlane: Nullable<Plane>;
  32371. /**
  32372. * Gets or sets the active clipplane 2
  32373. */
  32374. clipPlane2: Nullable<Plane>;
  32375. /**
  32376. * Gets or sets the active clipplane 3
  32377. */
  32378. clipPlane3: Nullable<Plane>;
  32379. /**
  32380. * Gets or sets the active clipplane 4
  32381. */
  32382. clipPlane4: Nullable<Plane>;
  32383. /**
  32384. * Gets or sets a boolean indicating if animations are enabled
  32385. */
  32386. animationsEnabled: boolean;
  32387. private _animationPropertiesOverride;
  32388. /**
  32389. * Gets or sets the animation properties override
  32390. */
  32391. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32392. /**
  32393. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32394. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32395. */
  32396. useConstantAnimationDeltaTime: boolean;
  32397. /**
  32398. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32399. * Please note that it requires to run a ray cast through the scene on every frame
  32400. */
  32401. constantlyUpdateMeshUnderPointer: boolean;
  32402. /**
  32403. * Defines the HTML cursor to use when hovering over interactive elements
  32404. */
  32405. hoverCursor: string;
  32406. /**
  32407. * Defines the HTML default cursor to use (empty by default)
  32408. */
  32409. defaultCursor: string;
  32410. /**
  32411. * This is used to call preventDefault() on pointer down
  32412. * in order to block unwanted artifacts like system double clicks
  32413. */
  32414. preventDefaultOnPointerDown: boolean;
  32415. /**
  32416. * This is used to call preventDefault() on pointer up
  32417. * in order to block unwanted artifacts like system double clicks
  32418. */
  32419. preventDefaultOnPointerUp: boolean;
  32420. /**
  32421. * Gets or sets user defined metadata
  32422. */
  32423. metadata: any;
  32424. /**
  32425. * For internal use only. Please do not use.
  32426. */
  32427. reservedDataStore: any;
  32428. /**
  32429. * Gets the name of the plugin used to load this scene (null by default)
  32430. */
  32431. loadingPluginName: string;
  32432. /**
  32433. * Use this array to add regular expressions used to disable offline support for specific urls
  32434. */
  32435. disableOfflineSupportExceptionRules: RegExp[];
  32436. /**
  32437. * An event triggered when the scene is disposed.
  32438. */
  32439. onDisposeObservable: Observable<Scene>;
  32440. private _onDisposeObserver;
  32441. /** Sets a function to be executed when this scene is disposed. */
  32442. onDispose: () => void;
  32443. /**
  32444. * An event triggered before rendering the scene (right after animations and physics)
  32445. */
  32446. onBeforeRenderObservable: Observable<Scene>;
  32447. private _onBeforeRenderObserver;
  32448. /** Sets a function to be executed before rendering this scene */
  32449. beforeRender: Nullable<() => void>;
  32450. /**
  32451. * An event triggered after rendering the scene
  32452. */
  32453. onAfterRenderObservable: Observable<Scene>;
  32454. /**
  32455. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32456. */
  32457. onAfterRenderCameraObservable: Observable<Camera>;
  32458. private _onAfterRenderObserver;
  32459. /** Sets a function to be executed after rendering this scene */
  32460. afterRender: Nullable<() => void>;
  32461. /**
  32462. * An event triggered before animating the scene
  32463. */
  32464. onBeforeAnimationsObservable: Observable<Scene>;
  32465. /**
  32466. * An event triggered after animations processing
  32467. */
  32468. onAfterAnimationsObservable: Observable<Scene>;
  32469. /**
  32470. * An event triggered before draw calls are ready to be sent
  32471. */
  32472. onBeforeDrawPhaseObservable: Observable<Scene>;
  32473. /**
  32474. * An event triggered after draw calls have been sent
  32475. */
  32476. onAfterDrawPhaseObservable: Observable<Scene>;
  32477. /**
  32478. * An event triggered when the scene is ready
  32479. */
  32480. onReadyObservable: Observable<Scene>;
  32481. /**
  32482. * An event triggered before rendering a camera
  32483. */
  32484. onBeforeCameraRenderObservable: Observable<Camera>;
  32485. private _onBeforeCameraRenderObserver;
  32486. /** Sets a function to be executed before rendering a camera*/
  32487. beforeCameraRender: () => void;
  32488. /**
  32489. * An event triggered after rendering a camera
  32490. */
  32491. onAfterCameraRenderObservable: Observable<Camera>;
  32492. private _onAfterCameraRenderObserver;
  32493. /** Sets a function to be executed after rendering a camera*/
  32494. afterCameraRender: () => void;
  32495. /**
  32496. * An event triggered when active meshes evaluation is about to start
  32497. */
  32498. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32499. /**
  32500. * An event triggered when active meshes evaluation is done
  32501. */
  32502. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32503. /**
  32504. * An event triggered when particles rendering is about to start
  32505. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32506. */
  32507. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32508. /**
  32509. * An event triggered when particles rendering is done
  32510. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32511. */
  32512. onAfterParticlesRenderingObservable: Observable<Scene>;
  32513. /**
  32514. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32515. */
  32516. onDataLoadedObservable: Observable<Scene>;
  32517. /**
  32518. * An event triggered when a camera is created
  32519. */
  32520. onNewCameraAddedObservable: Observable<Camera>;
  32521. /**
  32522. * An event triggered when a camera is removed
  32523. */
  32524. onCameraRemovedObservable: Observable<Camera>;
  32525. /**
  32526. * An event triggered when a light is created
  32527. */
  32528. onNewLightAddedObservable: Observable<Light>;
  32529. /**
  32530. * An event triggered when a light is removed
  32531. */
  32532. onLightRemovedObservable: Observable<Light>;
  32533. /**
  32534. * An event triggered when a geometry is created
  32535. */
  32536. onNewGeometryAddedObservable: Observable<Geometry>;
  32537. /**
  32538. * An event triggered when a geometry is removed
  32539. */
  32540. onGeometryRemovedObservable: Observable<Geometry>;
  32541. /**
  32542. * An event triggered when a transform node is created
  32543. */
  32544. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32545. /**
  32546. * An event triggered when a transform node is removed
  32547. */
  32548. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32549. /**
  32550. * An event triggered when a mesh is created
  32551. */
  32552. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32553. /**
  32554. * An event triggered when a mesh is removed
  32555. */
  32556. onMeshRemovedObservable: Observable<AbstractMesh>;
  32557. /**
  32558. * An event triggered when a skeleton is created
  32559. */
  32560. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32561. /**
  32562. * An event triggered when a skeleton is removed
  32563. */
  32564. onSkeletonRemovedObservable: Observable<Skeleton>;
  32565. /**
  32566. * An event triggered when a material is created
  32567. */
  32568. onNewMaterialAddedObservable: Observable<Material>;
  32569. /**
  32570. * An event triggered when a material is removed
  32571. */
  32572. onMaterialRemovedObservable: Observable<Material>;
  32573. /**
  32574. * An event triggered when a texture is created
  32575. */
  32576. onNewTextureAddedObservable: Observable<BaseTexture>;
  32577. /**
  32578. * An event triggered when a texture is removed
  32579. */
  32580. onTextureRemovedObservable: Observable<BaseTexture>;
  32581. /**
  32582. * An event triggered when render targets are about to be rendered
  32583. * Can happen multiple times per frame.
  32584. */
  32585. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32586. /**
  32587. * An event triggered when render targets were rendered.
  32588. * Can happen multiple times per frame.
  32589. */
  32590. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32591. /**
  32592. * An event triggered before calculating deterministic simulation step
  32593. */
  32594. onBeforeStepObservable: Observable<Scene>;
  32595. /**
  32596. * An event triggered after calculating deterministic simulation step
  32597. */
  32598. onAfterStepObservable: Observable<Scene>;
  32599. /**
  32600. * An event triggered when the activeCamera property is updated
  32601. */
  32602. onActiveCameraChanged: Observable<Scene>;
  32603. /**
  32604. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32605. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32606. * 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)
  32607. */
  32608. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32609. /**
  32610. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32611. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32612. * 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)
  32613. */
  32614. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32615. /**
  32616. * This Observable will when a mesh has been imported into the scene.
  32617. */
  32618. onMeshImportedObservable: Observable<AbstractMesh>;
  32619. /**
  32620. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32621. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32622. */
  32623. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32624. /** @hidden */
  32625. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32626. /**
  32627. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32628. */
  32629. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32630. /**
  32631. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32632. */
  32633. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32634. /**
  32635. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32636. */
  32637. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32638. /** Callback called when a pointer move is detected */
  32639. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32640. /** Callback called when a pointer down is detected */
  32641. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32642. /** Callback called when a pointer up is detected */
  32643. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32644. /** Callback called when a pointer pick is detected */
  32645. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32646. /**
  32647. * 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).
  32648. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32649. */
  32650. onPrePointerObservable: Observable<PointerInfoPre>;
  32651. /**
  32652. * Observable event triggered each time an input event is received from the rendering canvas
  32653. */
  32654. onPointerObservable: Observable<PointerInfo>;
  32655. /**
  32656. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32657. */
  32658. readonly unTranslatedPointer: Vector2;
  32659. /**
  32660. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32661. */
  32662. static DragMovementThreshold: number;
  32663. /**
  32664. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32665. */
  32666. static LongPressDelay: number;
  32667. /**
  32668. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32669. */
  32670. static DoubleClickDelay: number;
  32671. /** If you need to check double click without raising a single click at first click, enable this flag */
  32672. static ExclusiveDoubleClickMode: boolean;
  32673. /** @hidden */
  32674. _mirroredCameraPosition: Nullable<Vector3>;
  32675. /**
  32676. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32677. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32678. */
  32679. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32680. /**
  32681. * Observable event triggered each time an keyboard event is received from the hosting window
  32682. */
  32683. onKeyboardObservable: Observable<KeyboardInfo>;
  32684. private _useRightHandedSystem;
  32685. /**
  32686. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32687. */
  32688. useRightHandedSystem: boolean;
  32689. private _timeAccumulator;
  32690. private _currentStepId;
  32691. private _currentInternalStep;
  32692. /**
  32693. * Sets the step Id used by deterministic lock step
  32694. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32695. * @param newStepId defines the step Id
  32696. */
  32697. setStepId(newStepId: number): void;
  32698. /**
  32699. * Gets the step Id used by deterministic lock step
  32700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32701. * @returns the step Id
  32702. */
  32703. getStepId(): number;
  32704. /**
  32705. * Gets the internal step used by deterministic lock step
  32706. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32707. * @returns the internal step
  32708. */
  32709. getInternalStep(): number;
  32710. private _fogEnabled;
  32711. /**
  32712. * Gets or sets a boolean indicating if fog is enabled on this scene
  32713. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32714. * (Default is true)
  32715. */
  32716. fogEnabled: boolean;
  32717. private _fogMode;
  32718. /**
  32719. * Gets or sets the fog mode to use
  32720. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32721. * | mode | value |
  32722. * | --- | --- |
  32723. * | FOGMODE_NONE | 0 |
  32724. * | FOGMODE_EXP | 1 |
  32725. * | FOGMODE_EXP2 | 2 |
  32726. * | FOGMODE_LINEAR | 3 |
  32727. */
  32728. fogMode: number;
  32729. /**
  32730. * Gets or sets the fog color to use
  32731. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32732. * (Default is Color3(0.2, 0.2, 0.3))
  32733. */
  32734. fogColor: Color3;
  32735. /**
  32736. * Gets or sets the fog density to use
  32737. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32738. * (Default is 0.1)
  32739. */
  32740. fogDensity: number;
  32741. /**
  32742. * Gets or sets the fog start distance to use
  32743. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32744. * (Default is 0)
  32745. */
  32746. fogStart: number;
  32747. /**
  32748. * Gets or sets the fog end distance to use
  32749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32750. * (Default is 1000)
  32751. */
  32752. fogEnd: number;
  32753. private _shadowsEnabled;
  32754. /**
  32755. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32756. */
  32757. shadowsEnabled: boolean;
  32758. private _lightsEnabled;
  32759. /**
  32760. * Gets or sets a boolean indicating if lights are enabled on this scene
  32761. */
  32762. lightsEnabled: boolean;
  32763. /** All of the active cameras added to this scene. */
  32764. activeCameras: Camera[];
  32765. /** @hidden */
  32766. _activeCamera: Nullable<Camera>;
  32767. /** Gets or sets the current active camera */
  32768. activeCamera: Nullable<Camera>;
  32769. private _defaultMaterial;
  32770. /** The default material used on meshes when no material is affected */
  32771. /** The default material used on meshes when no material is affected */
  32772. defaultMaterial: Material;
  32773. private _texturesEnabled;
  32774. /**
  32775. * Gets or sets a boolean indicating if textures are enabled on this scene
  32776. */
  32777. texturesEnabled: boolean;
  32778. /**
  32779. * Gets or sets a boolean indicating if particles are enabled on this scene
  32780. */
  32781. particlesEnabled: boolean;
  32782. /**
  32783. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32784. */
  32785. spritesEnabled: boolean;
  32786. private _skeletonsEnabled;
  32787. /**
  32788. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32789. */
  32790. skeletonsEnabled: boolean;
  32791. /**
  32792. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32793. */
  32794. lensFlaresEnabled: boolean;
  32795. /**
  32796. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32798. */
  32799. collisionsEnabled: boolean;
  32800. private _collisionCoordinator;
  32801. /** @hidden */
  32802. readonly collisionCoordinator: ICollisionCoordinator;
  32803. /**
  32804. * Defines the gravity applied to this scene (used only for collisions)
  32805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32806. */
  32807. gravity: Vector3;
  32808. /**
  32809. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32810. */
  32811. postProcessesEnabled: boolean;
  32812. /**
  32813. * The list of postprocesses added to the scene
  32814. */
  32815. postProcesses: PostProcess[];
  32816. /**
  32817. * Gets the current postprocess manager
  32818. */
  32819. postProcessManager: PostProcessManager;
  32820. /**
  32821. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32822. */
  32823. renderTargetsEnabled: boolean;
  32824. /**
  32825. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32826. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32827. */
  32828. dumpNextRenderTargets: boolean;
  32829. /**
  32830. * The list of user defined render targets added to the scene
  32831. */
  32832. customRenderTargets: RenderTargetTexture[];
  32833. /**
  32834. * Defines if texture loading must be delayed
  32835. * If true, textures will only be loaded when they need to be rendered
  32836. */
  32837. useDelayedTextureLoading: boolean;
  32838. /**
  32839. * Gets the list of meshes imported to the scene through SceneLoader
  32840. */
  32841. importedMeshesFiles: String[];
  32842. /**
  32843. * Gets or sets a boolean indicating if probes are enabled on this scene
  32844. */
  32845. probesEnabled: boolean;
  32846. /**
  32847. * Gets or sets the current offline provider to use to store scene data
  32848. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32849. */
  32850. offlineProvider: IOfflineProvider;
  32851. /**
  32852. * Gets or sets the action manager associated with the scene
  32853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32854. */
  32855. actionManager: AbstractActionManager;
  32856. private _meshesForIntersections;
  32857. /**
  32858. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32859. */
  32860. proceduralTexturesEnabled: boolean;
  32861. private _engine;
  32862. private _totalVertices;
  32863. /** @hidden */
  32864. _activeIndices: PerfCounter;
  32865. /** @hidden */
  32866. _activeParticles: PerfCounter;
  32867. /** @hidden */
  32868. _activeBones: PerfCounter;
  32869. private _animationRatio;
  32870. /** @hidden */
  32871. _animationTimeLast: number;
  32872. /** @hidden */
  32873. _animationTime: number;
  32874. /**
  32875. * Gets or sets a general scale for animation speed
  32876. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32877. */
  32878. animationTimeScale: number;
  32879. /** @hidden */
  32880. _cachedMaterial: Nullable<Material>;
  32881. /** @hidden */
  32882. _cachedEffect: Nullable<Effect>;
  32883. /** @hidden */
  32884. _cachedVisibility: Nullable<number>;
  32885. private _renderId;
  32886. private _frameId;
  32887. private _executeWhenReadyTimeoutId;
  32888. private _intermediateRendering;
  32889. private _viewUpdateFlag;
  32890. private _projectionUpdateFlag;
  32891. /** @hidden */
  32892. _toBeDisposed: Nullable<IDisposable>[];
  32893. private _activeRequests;
  32894. /** @hidden */
  32895. _pendingData: any[];
  32896. private _isDisposed;
  32897. /**
  32898. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32899. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32900. */
  32901. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32902. private _activeMeshes;
  32903. private _processedMaterials;
  32904. private _renderTargets;
  32905. /** @hidden */
  32906. _activeParticleSystems: SmartArray<IParticleSystem>;
  32907. private _activeSkeletons;
  32908. private _softwareSkinnedMeshes;
  32909. private _renderingManager;
  32910. /** @hidden */
  32911. _activeAnimatables: Animatable[];
  32912. private _transformMatrix;
  32913. private _sceneUbo;
  32914. /** @hidden */
  32915. _viewMatrix: Matrix;
  32916. private _projectionMatrix;
  32917. /** @hidden */
  32918. _forcedViewPosition: Nullable<Vector3>;
  32919. /** @hidden */
  32920. _frustumPlanes: Plane[];
  32921. /**
  32922. * Gets the list of frustum planes (built from the active camera)
  32923. */
  32924. readonly frustumPlanes: Plane[];
  32925. /**
  32926. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32927. * This is useful if there are more lights that the maximum simulteanous authorized
  32928. */
  32929. requireLightSorting: boolean;
  32930. /** @hidden */
  32931. readonly useMaterialMeshMap: boolean;
  32932. /** @hidden */
  32933. readonly useClonedMeshhMap: boolean;
  32934. private _externalData;
  32935. private _uid;
  32936. /**
  32937. * @hidden
  32938. * Backing store of defined scene components.
  32939. */
  32940. _components: ISceneComponent[];
  32941. /**
  32942. * @hidden
  32943. * Backing store of defined scene components.
  32944. */
  32945. _serializableComponents: ISceneSerializableComponent[];
  32946. /**
  32947. * List of components to register on the next registration step.
  32948. */
  32949. private _transientComponents;
  32950. /**
  32951. * Registers the transient components if needed.
  32952. */
  32953. private _registerTransientComponents;
  32954. /**
  32955. * @hidden
  32956. * Add a component to the scene.
  32957. * Note that the ccomponent could be registered on th next frame if this is called after
  32958. * the register component stage.
  32959. * @param component Defines the component to add to the scene
  32960. */
  32961. _addComponent(component: ISceneComponent): void;
  32962. /**
  32963. * @hidden
  32964. * Gets a component from the scene.
  32965. * @param name defines the name of the component to retrieve
  32966. * @returns the component or null if not present
  32967. */
  32968. _getComponent(name: string): Nullable<ISceneComponent>;
  32969. /**
  32970. * @hidden
  32971. * Defines the actions happening before camera updates.
  32972. */
  32973. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32974. /**
  32975. * @hidden
  32976. * Defines the actions happening before clear the canvas.
  32977. */
  32978. _beforeClearStage: Stage<SimpleStageAction>;
  32979. /**
  32980. * @hidden
  32981. * Defines the actions when collecting render targets for the frame.
  32982. */
  32983. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32984. /**
  32985. * @hidden
  32986. * Defines the actions happening for one camera in the frame.
  32987. */
  32988. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32989. /**
  32990. * @hidden
  32991. * Defines the actions happening during the per mesh ready checks.
  32992. */
  32993. _isReadyForMeshStage: Stage<MeshStageAction>;
  32994. /**
  32995. * @hidden
  32996. * Defines the actions happening before evaluate active mesh checks.
  32997. */
  32998. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32999. /**
  33000. * @hidden
  33001. * Defines the actions happening during the evaluate sub mesh checks.
  33002. */
  33003. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33004. /**
  33005. * @hidden
  33006. * Defines the actions happening during the active mesh stage.
  33007. */
  33008. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33009. /**
  33010. * @hidden
  33011. * Defines the actions happening during the per camera render target step.
  33012. */
  33013. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33014. /**
  33015. * @hidden
  33016. * Defines the actions happening just before the active camera is drawing.
  33017. */
  33018. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33019. /**
  33020. * @hidden
  33021. * Defines the actions happening just before a render target is drawing.
  33022. */
  33023. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33024. /**
  33025. * @hidden
  33026. * Defines the actions happening just before a rendering group is drawing.
  33027. */
  33028. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33029. /**
  33030. * @hidden
  33031. * Defines the actions happening just before a mesh is drawing.
  33032. */
  33033. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33034. /**
  33035. * @hidden
  33036. * Defines the actions happening just after a mesh has been drawn.
  33037. */
  33038. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33039. /**
  33040. * @hidden
  33041. * Defines the actions happening just after a rendering group has been drawn.
  33042. */
  33043. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33044. /**
  33045. * @hidden
  33046. * Defines the actions happening just after the active camera has been drawn.
  33047. */
  33048. _afterCameraDrawStage: Stage<CameraStageAction>;
  33049. /**
  33050. * @hidden
  33051. * Defines the actions happening just after a render target has been drawn.
  33052. */
  33053. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33054. /**
  33055. * @hidden
  33056. * Defines the actions happening just after rendering all cameras and computing intersections.
  33057. */
  33058. _afterRenderStage: Stage<SimpleStageAction>;
  33059. /**
  33060. * @hidden
  33061. * Defines the actions happening when a pointer move event happens.
  33062. */
  33063. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33064. /**
  33065. * @hidden
  33066. * Defines the actions happening when a pointer down event happens.
  33067. */
  33068. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33069. /**
  33070. * @hidden
  33071. * Defines the actions happening when a pointer up event happens.
  33072. */
  33073. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33074. /**
  33075. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33076. */
  33077. private geometriesByUniqueId;
  33078. /**
  33079. * Creates a new Scene
  33080. * @param engine defines the engine to use to render this scene
  33081. * @param options defines the scene options
  33082. */
  33083. constructor(engine: Engine, options?: SceneOptions);
  33084. /**
  33085. * Gets a string idenfifying the name of the class
  33086. * @returns "Scene" string
  33087. */
  33088. getClassName(): string;
  33089. private _defaultMeshCandidates;
  33090. /**
  33091. * @hidden
  33092. */
  33093. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33094. private _defaultSubMeshCandidates;
  33095. /**
  33096. * @hidden
  33097. */
  33098. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33099. /**
  33100. * Sets the default candidate providers for the scene.
  33101. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33102. * and getCollidingSubMeshCandidates to their default function
  33103. */
  33104. setDefaultCandidateProviders(): void;
  33105. /**
  33106. * Gets the mesh that is currently under the pointer
  33107. */
  33108. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33109. /**
  33110. * Gets or sets the current on-screen X position of the pointer
  33111. */
  33112. pointerX: number;
  33113. /**
  33114. * Gets or sets the current on-screen Y position of the pointer
  33115. */
  33116. pointerY: number;
  33117. /**
  33118. * Gets the cached material (ie. the latest rendered one)
  33119. * @returns the cached material
  33120. */
  33121. getCachedMaterial(): Nullable<Material>;
  33122. /**
  33123. * Gets the cached effect (ie. the latest rendered one)
  33124. * @returns the cached effect
  33125. */
  33126. getCachedEffect(): Nullable<Effect>;
  33127. /**
  33128. * Gets the cached visibility state (ie. the latest rendered one)
  33129. * @returns the cached visibility state
  33130. */
  33131. getCachedVisibility(): Nullable<number>;
  33132. /**
  33133. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33134. * @param material defines the current material
  33135. * @param effect defines the current effect
  33136. * @param visibility defines the current visibility state
  33137. * @returns true if one parameter is not cached
  33138. */
  33139. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33140. /**
  33141. * Gets the engine associated with the scene
  33142. * @returns an Engine
  33143. */
  33144. getEngine(): Engine;
  33145. /**
  33146. * Gets the total number of vertices rendered per frame
  33147. * @returns the total number of vertices rendered per frame
  33148. */
  33149. getTotalVertices(): number;
  33150. /**
  33151. * Gets the performance counter for total vertices
  33152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33153. */
  33154. readonly totalVerticesPerfCounter: PerfCounter;
  33155. /**
  33156. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33157. * @returns the total number of active indices rendered per frame
  33158. */
  33159. getActiveIndices(): number;
  33160. /**
  33161. * Gets the performance counter for active indices
  33162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33163. */
  33164. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33165. /**
  33166. * Gets the total number of active particles rendered per frame
  33167. * @returns the total number of active particles rendered per frame
  33168. */
  33169. getActiveParticles(): number;
  33170. /**
  33171. * Gets the performance counter for active particles
  33172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33173. */
  33174. readonly activeParticlesPerfCounter: PerfCounter;
  33175. /**
  33176. * Gets the total number of active bones rendered per frame
  33177. * @returns the total number of active bones rendered per frame
  33178. */
  33179. getActiveBones(): number;
  33180. /**
  33181. * Gets the performance counter for active bones
  33182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33183. */
  33184. readonly activeBonesPerfCounter: PerfCounter;
  33185. /**
  33186. * Gets the array of active meshes
  33187. * @returns an array of AbstractMesh
  33188. */
  33189. getActiveMeshes(): SmartArray<AbstractMesh>;
  33190. /**
  33191. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33192. * @returns a number
  33193. */
  33194. getAnimationRatio(): number;
  33195. /**
  33196. * Gets an unique Id for the current render phase
  33197. * @returns a number
  33198. */
  33199. getRenderId(): number;
  33200. /**
  33201. * Gets an unique Id for the current frame
  33202. * @returns a number
  33203. */
  33204. getFrameId(): number;
  33205. /** Call this function if you want to manually increment the render Id*/
  33206. incrementRenderId(): void;
  33207. private _createUbo;
  33208. /**
  33209. * Use this method to simulate a pointer move on a mesh
  33210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33213. * @returns the current scene
  33214. */
  33215. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33216. /**
  33217. * Use this method to simulate a pointer down on a mesh
  33218. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33219. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33220. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33221. * @returns the current scene
  33222. */
  33223. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33224. /**
  33225. * Use this method to simulate a pointer up on a mesh
  33226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33229. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33230. * @returns the current scene
  33231. */
  33232. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33233. /**
  33234. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33235. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33236. * @returns true if the pointer was captured
  33237. */
  33238. isPointerCaptured(pointerId?: number): boolean;
  33239. /**
  33240. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33241. * @param attachUp defines if you want to attach events to pointerup
  33242. * @param attachDown defines if you want to attach events to pointerdown
  33243. * @param attachMove defines if you want to attach events to pointermove
  33244. */
  33245. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33246. /** Detaches all event handlers*/
  33247. detachControl(): void;
  33248. /**
  33249. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33250. * Delay loaded resources are not taking in account
  33251. * @return true if all required resources are ready
  33252. */
  33253. isReady(): boolean;
  33254. /** Resets all cached information relative to material (including effect and visibility) */
  33255. resetCachedMaterial(): void;
  33256. /**
  33257. * Registers a function to be called before every frame render
  33258. * @param func defines the function to register
  33259. */
  33260. registerBeforeRender(func: () => void): void;
  33261. /**
  33262. * Unregisters a function called before every frame render
  33263. * @param func defines the function to unregister
  33264. */
  33265. unregisterBeforeRender(func: () => void): void;
  33266. /**
  33267. * Registers a function to be called after every frame render
  33268. * @param func defines the function to register
  33269. */
  33270. registerAfterRender(func: () => void): void;
  33271. /**
  33272. * Unregisters a function called after every frame render
  33273. * @param func defines the function to unregister
  33274. */
  33275. unregisterAfterRender(func: () => void): void;
  33276. private _executeOnceBeforeRender;
  33277. /**
  33278. * The provided function will run before render once and will be disposed afterwards.
  33279. * A timeout delay can be provided so that the function will be executed in N ms.
  33280. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33281. * @param func The function to be executed.
  33282. * @param timeout optional delay in ms
  33283. */
  33284. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33285. /** @hidden */
  33286. _addPendingData(data: any): void;
  33287. /** @hidden */
  33288. _removePendingData(data: any): void;
  33289. /**
  33290. * Returns the number of items waiting to be loaded
  33291. * @returns the number of items waiting to be loaded
  33292. */
  33293. getWaitingItemsCount(): number;
  33294. /**
  33295. * Returns a boolean indicating if the scene is still loading data
  33296. */
  33297. readonly isLoading: boolean;
  33298. /**
  33299. * Registers a function to be executed when the scene is ready
  33300. * @param {Function} func - the function to be executed
  33301. */
  33302. executeWhenReady(func: () => void): void;
  33303. /**
  33304. * Returns a promise that resolves when the scene is ready
  33305. * @returns A promise that resolves when the scene is ready
  33306. */
  33307. whenReadyAsync(): Promise<void>;
  33308. /** @hidden */
  33309. _checkIsReady(): void;
  33310. /**
  33311. * Gets all animatable attached to the scene
  33312. */
  33313. readonly animatables: Animatable[];
  33314. /**
  33315. * Resets the last animation time frame.
  33316. * Useful to override when animations start running when loading a scene for the first time.
  33317. */
  33318. resetLastAnimationTimeFrame(): void;
  33319. /**
  33320. * Gets the current view matrix
  33321. * @returns a Matrix
  33322. */
  33323. getViewMatrix(): Matrix;
  33324. /**
  33325. * Gets the current projection matrix
  33326. * @returns a Matrix
  33327. */
  33328. getProjectionMatrix(): Matrix;
  33329. /**
  33330. * Gets the current transform matrix
  33331. * @returns a Matrix made of View * Projection
  33332. */
  33333. getTransformMatrix(): Matrix;
  33334. /**
  33335. * Sets the current transform matrix
  33336. * @param viewL defines the View matrix to use
  33337. * @param projectionL defines the Projection matrix to use
  33338. * @param viewR defines the right View matrix to use (if provided)
  33339. * @param projectionR defines the right Projection matrix to use (if provided)
  33340. */
  33341. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33342. /**
  33343. * Gets the uniform buffer used to store scene data
  33344. * @returns a UniformBuffer
  33345. */
  33346. getSceneUniformBuffer(): UniformBuffer;
  33347. /**
  33348. * Gets an unique (relatively to the current scene) Id
  33349. * @returns an unique number for the scene
  33350. */
  33351. getUniqueId(): number;
  33352. /**
  33353. * Add a mesh to the list of scene's meshes
  33354. * @param newMesh defines the mesh to add
  33355. * @param recursive if all child meshes should also be added to the scene
  33356. */
  33357. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33358. /**
  33359. * Remove a mesh for the list of scene's meshes
  33360. * @param toRemove defines the mesh to remove
  33361. * @param recursive if all child meshes should also be removed from the scene
  33362. * @returns the index where the mesh was in the mesh list
  33363. */
  33364. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33365. /**
  33366. * Add a transform node to the list of scene's transform nodes
  33367. * @param newTransformNode defines the transform node to add
  33368. */
  33369. addTransformNode(newTransformNode: TransformNode): void;
  33370. /**
  33371. * Remove a transform node for the list of scene's transform nodes
  33372. * @param toRemove defines the transform node to remove
  33373. * @returns the index where the transform node was in the transform node list
  33374. */
  33375. removeTransformNode(toRemove: TransformNode): number;
  33376. /**
  33377. * Remove a skeleton for the list of scene's skeletons
  33378. * @param toRemove defines the skeleton to remove
  33379. * @returns the index where the skeleton was in the skeleton list
  33380. */
  33381. removeSkeleton(toRemove: Skeleton): number;
  33382. /**
  33383. * Remove a morph target for the list of scene's morph targets
  33384. * @param toRemove defines the morph target to remove
  33385. * @returns the index where the morph target was in the morph target list
  33386. */
  33387. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33388. /**
  33389. * Remove a light for the list of scene's lights
  33390. * @param toRemove defines the light to remove
  33391. * @returns the index where the light was in the light list
  33392. */
  33393. removeLight(toRemove: Light): number;
  33394. /**
  33395. * Remove a camera for the list of scene's cameras
  33396. * @param toRemove defines the camera to remove
  33397. * @returns the index where the camera was in the camera list
  33398. */
  33399. removeCamera(toRemove: Camera): number;
  33400. /**
  33401. * Remove a particle system for the list of scene's particle systems
  33402. * @param toRemove defines the particle system to remove
  33403. * @returns the index where the particle system was in the particle system list
  33404. */
  33405. removeParticleSystem(toRemove: IParticleSystem): number;
  33406. /**
  33407. * Remove a animation for the list of scene's animations
  33408. * @param toRemove defines the animation to remove
  33409. * @returns the index where the animation was in the animation list
  33410. */
  33411. removeAnimation(toRemove: Animation): number;
  33412. /**
  33413. * Will stop the animation of the given target
  33414. * @param target - the target
  33415. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33416. * @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)
  33417. */
  33418. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33419. /**
  33420. * Removes the given animation group from this scene.
  33421. * @param toRemove The animation group to remove
  33422. * @returns The index of the removed animation group
  33423. */
  33424. removeAnimationGroup(toRemove: AnimationGroup): number;
  33425. /**
  33426. * Removes the given multi-material from this scene.
  33427. * @param toRemove The multi-material to remove
  33428. * @returns The index of the removed multi-material
  33429. */
  33430. removeMultiMaterial(toRemove: MultiMaterial): number;
  33431. /**
  33432. * Removes the given material from this scene.
  33433. * @param toRemove The material to remove
  33434. * @returns The index of the removed material
  33435. */
  33436. removeMaterial(toRemove: Material): number;
  33437. /**
  33438. * Removes the given action manager from this scene.
  33439. * @param toRemove The action manager to remove
  33440. * @returns The index of the removed action manager
  33441. */
  33442. removeActionManager(toRemove: AbstractActionManager): number;
  33443. /**
  33444. * Removes the given texture from this scene.
  33445. * @param toRemove The texture to remove
  33446. * @returns The index of the removed texture
  33447. */
  33448. removeTexture(toRemove: BaseTexture): number;
  33449. /**
  33450. * Adds the given light to this scene
  33451. * @param newLight The light to add
  33452. */
  33453. addLight(newLight: Light): void;
  33454. /**
  33455. * Sorts the list list based on light priorities
  33456. */
  33457. sortLightsByPriority(): void;
  33458. /**
  33459. * Adds the given camera to this scene
  33460. * @param newCamera The camera to add
  33461. */
  33462. addCamera(newCamera: Camera): void;
  33463. /**
  33464. * Adds the given skeleton to this scene
  33465. * @param newSkeleton The skeleton to add
  33466. */
  33467. addSkeleton(newSkeleton: Skeleton): void;
  33468. /**
  33469. * Adds the given particle system to this scene
  33470. * @param newParticleSystem The particle system to add
  33471. */
  33472. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33473. /**
  33474. * Adds the given animation to this scene
  33475. * @param newAnimation The animation to add
  33476. */
  33477. addAnimation(newAnimation: Animation): void;
  33478. /**
  33479. * Adds the given animation group to this scene.
  33480. * @param newAnimationGroup The animation group to add
  33481. */
  33482. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33483. /**
  33484. * Adds the given multi-material to this scene
  33485. * @param newMultiMaterial The multi-material to add
  33486. */
  33487. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33488. /**
  33489. * Adds the given material to this scene
  33490. * @param newMaterial The material to add
  33491. */
  33492. addMaterial(newMaterial: Material): void;
  33493. /**
  33494. * Adds the given morph target to this scene
  33495. * @param newMorphTargetManager The morph target to add
  33496. */
  33497. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33498. /**
  33499. * Adds the given geometry to this scene
  33500. * @param newGeometry The geometry to add
  33501. */
  33502. addGeometry(newGeometry: Geometry): void;
  33503. /**
  33504. * Adds the given action manager to this scene
  33505. * @param newActionManager The action manager to add
  33506. */
  33507. addActionManager(newActionManager: AbstractActionManager): void;
  33508. /**
  33509. * Adds the given texture to this scene.
  33510. * @param newTexture The texture to add
  33511. */
  33512. addTexture(newTexture: BaseTexture): void;
  33513. /**
  33514. * Switch active camera
  33515. * @param newCamera defines the new active camera
  33516. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33517. */
  33518. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33519. /**
  33520. * sets the active camera of the scene using its ID
  33521. * @param id defines the camera's ID
  33522. * @return the new active camera or null if none found.
  33523. */
  33524. setActiveCameraByID(id: string): Nullable<Camera>;
  33525. /**
  33526. * sets the active camera of the scene using its name
  33527. * @param name defines the camera's name
  33528. * @returns the new active camera or null if none found.
  33529. */
  33530. setActiveCameraByName(name: string): Nullable<Camera>;
  33531. /**
  33532. * get an animation group using its name
  33533. * @param name defines the material's name
  33534. * @return the animation group or null if none found.
  33535. */
  33536. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33537. /**
  33538. * Get a material using its unique id
  33539. * @param uniqueId defines the material's unique id
  33540. * @return the material or null if none found.
  33541. */
  33542. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33543. /**
  33544. * get a material using its id
  33545. * @param id defines the material's ID
  33546. * @return the material or null if none found.
  33547. */
  33548. getMaterialByID(id: string): Nullable<Material>;
  33549. /**
  33550. * Gets a material using its name
  33551. * @param name defines the material's name
  33552. * @return the material or null if none found.
  33553. */
  33554. getMaterialByName(name: string): Nullable<Material>;
  33555. /**
  33556. * Gets a camera using its id
  33557. * @param id defines the id to look for
  33558. * @returns the camera or null if not found
  33559. */
  33560. getCameraByID(id: string): Nullable<Camera>;
  33561. /**
  33562. * Gets a camera using its unique id
  33563. * @param uniqueId defines the unique id to look for
  33564. * @returns the camera or null if not found
  33565. */
  33566. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33567. /**
  33568. * Gets a camera using its name
  33569. * @param name defines the camera's name
  33570. * @return the camera or null if none found.
  33571. */
  33572. getCameraByName(name: string): Nullable<Camera>;
  33573. /**
  33574. * Gets a bone using its id
  33575. * @param id defines the bone's id
  33576. * @return the bone or null if not found
  33577. */
  33578. getBoneByID(id: string): Nullable<Bone>;
  33579. /**
  33580. * Gets a bone using its id
  33581. * @param name defines the bone's name
  33582. * @return the bone or null if not found
  33583. */
  33584. getBoneByName(name: string): Nullable<Bone>;
  33585. /**
  33586. * Gets a light node using its name
  33587. * @param name defines the the light's name
  33588. * @return the light or null if none found.
  33589. */
  33590. getLightByName(name: string): Nullable<Light>;
  33591. /**
  33592. * Gets a light node using its id
  33593. * @param id defines the light's id
  33594. * @return the light or null if none found.
  33595. */
  33596. getLightByID(id: string): Nullable<Light>;
  33597. /**
  33598. * Gets a light node using its scene-generated unique ID
  33599. * @param uniqueId defines the light's unique id
  33600. * @return the light or null if none found.
  33601. */
  33602. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33603. /**
  33604. * Gets a particle system by id
  33605. * @param id defines the particle system id
  33606. * @return the corresponding system or null if none found
  33607. */
  33608. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33609. /**
  33610. * Gets a geometry using its ID
  33611. * @param id defines the geometry's id
  33612. * @return the geometry or null if none found.
  33613. */
  33614. getGeometryByID(id: string): Nullable<Geometry>;
  33615. private _getGeometryByUniqueID;
  33616. /**
  33617. * Add a new geometry to this scene
  33618. * @param geometry defines the geometry to be added to the scene.
  33619. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33620. * @return a boolean defining if the geometry was added or not
  33621. */
  33622. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33623. /**
  33624. * Removes an existing geometry
  33625. * @param geometry defines the geometry to be removed from the scene
  33626. * @return a boolean defining if the geometry was removed or not
  33627. */
  33628. removeGeometry(geometry: Geometry): boolean;
  33629. /**
  33630. * Gets the list of geometries attached to the scene
  33631. * @returns an array of Geometry
  33632. */
  33633. getGeometries(): Geometry[];
  33634. /**
  33635. * Gets the first added mesh found of a given ID
  33636. * @param id defines the id to search for
  33637. * @return the mesh found or null if not found at all
  33638. */
  33639. getMeshByID(id: string): Nullable<AbstractMesh>;
  33640. /**
  33641. * Gets a list of meshes using their id
  33642. * @param id defines the id to search for
  33643. * @returns a list of meshes
  33644. */
  33645. getMeshesByID(id: string): Array<AbstractMesh>;
  33646. /**
  33647. * Gets the first added transform node found of a given ID
  33648. * @param id defines the id to search for
  33649. * @return the found transform node or null if not found at all.
  33650. */
  33651. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33652. /**
  33653. * Gets a transform node with its auto-generated unique id
  33654. * @param uniqueId efines the unique id to search for
  33655. * @return the found transform node or null if not found at all.
  33656. */
  33657. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33658. /**
  33659. * Gets a list of transform nodes using their id
  33660. * @param id defines the id to search for
  33661. * @returns a list of transform nodes
  33662. */
  33663. getTransformNodesByID(id: string): Array<TransformNode>;
  33664. /**
  33665. * Gets a mesh with its auto-generated unique id
  33666. * @param uniqueId defines the unique id to search for
  33667. * @return the found mesh or null if not found at all.
  33668. */
  33669. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33670. /**
  33671. * Gets a the last added mesh using a given id
  33672. * @param id defines the id to search for
  33673. * @return the found mesh or null if not found at all.
  33674. */
  33675. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33676. /**
  33677. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33678. * @param id defines the id to search for
  33679. * @return the found node or null if not found at all
  33680. */
  33681. getLastEntryByID(id: string): Nullable<Node>;
  33682. /**
  33683. * Gets a node (Mesh, Camera, Light) using a given id
  33684. * @param id defines the id to search for
  33685. * @return the found node or null if not found at all
  33686. */
  33687. getNodeByID(id: string): Nullable<Node>;
  33688. /**
  33689. * Gets a node (Mesh, Camera, Light) using a given name
  33690. * @param name defines the name to search for
  33691. * @return the found node or null if not found at all.
  33692. */
  33693. getNodeByName(name: string): Nullable<Node>;
  33694. /**
  33695. * Gets a mesh using a given name
  33696. * @param name defines the name to search for
  33697. * @return the found mesh or null if not found at all.
  33698. */
  33699. getMeshByName(name: string): Nullable<AbstractMesh>;
  33700. /**
  33701. * Gets a transform node using a given name
  33702. * @param name defines the name to search for
  33703. * @return the found transform node or null if not found at all.
  33704. */
  33705. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33706. /**
  33707. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33708. * @param id defines the id to search for
  33709. * @return the found skeleton or null if not found at all.
  33710. */
  33711. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33712. /**
  33713. * Gets a skeleton using a given auto generated unique id
  33714. * @param uniqueId defines the unique id to search for
  33715. * @return the found skeleton or null if not found at all.
  33716. */
  33717. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33718. /**
  33719. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33720. * @param id defines the id to search for
  33721. * @return the found skeleton or null if not found at all.
  33722. */
  33723. getSkeletonById(id: string): Nullable<Skeleton>;
  33724. /**
  33725. * Gets a skeleton using a given name
  33726. * @param name defines the name to search for
  33727. * @return the found skeleton or null if not found at all.
  33728. */
  33729. getSkeletonByName(name: string): Nullable<Skeleton>;
  33730. /**
  33731. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33732. * @param id defines the id to search for
  33733. * @return the found morph target manager or null if not found at all.
  33734. */
  33735. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33736. /**
  33737. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33738. * @param id defines the id to search for
  33739. * @return the found morph target or null if not found at all.
  33740. */
  33741. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33742. /**
  33743. * Gets a boolean indicating if the given mesh is active
  33744. * @param mesh defines the mesh to look for
  33745. * @returns true if the mesh is in the active list
  33746. */
  33747. isActiveMesh(mesh: AbstractMesh): boolean;
  33748. /**
  33749. * Return a unique id as a string which can serve as an identifier for the scene
  33750. */
  33751. readonly uid: string;
  33752. /**
  33753. * Add an externaly attached data from its key.
  33754. * This method call will fail and return false, if such key already exists.
  33755. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33756. * @param key the unique key that identifies the data
  33757. * @param data the data object to associate to the key for this Engine instance
  33758. * @return true if no such key were already present and the data was added successfully, false otherwise
  33759. */
  33760. addExternalData<T>(key: string, data: T): boolean;
  33761. /**
  33762. * Get an externaly attached data from its key
  33763. * @param key the unique key that identifies the data
  33764. * @return the associated data, if present (can be null), or undefined if not present
  33765. */
  33766. getExternalData<T>(key: string): Nullable<T>;
  33767. /**
  33768. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33769. * @param key the unique key that identifies the data
  33770. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33771. * @return the associated data, can be null if the factory returned null.
  33772. */
  33773. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33774. /**
  33775. * Remove an externaly attached data from the Engine instance
  33776. * @param key the unique key that identifies the data
  33777. * @return true if the data was successfully removed, false if it doesn't exist
  33778. */
  33779. removeExternalData(key: string): boolean;
  33780. private _evaluateSubMesh;
  33781. /**
  33782. * Clear the processed materials smart array preventing retention point in material dispose.
  33783. */
  33784. freeProcessedMaterials(): void;
  33785. private _preventFreeActiveMeshesAndRenderingGroups;
  33786. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33787. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33788. * when disposing several meshes in a row or a hierarchy of meshes.
  33789. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33790. */
  33791. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33792. /**
  33793. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33794. */
  33795. freeActiveMeshes(): void;
  33796. /**
  33797. * Clear the info related to rendering groups preventing retention points during dispose.
  33798. */
  33799. freeRenderingGroups(): void;
  33800. /** @hidden */
  33801. _isInIntermediateRendering(): boolean;
  33802. /**
  33803. * Lambda returning the list of potentially active meshes.
  33804. */
  33805. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33806. /**
  33807. * Lambda returning the list of potentially active sub meshes.
  33808. */
  33809. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33810. /**
  33811. * Lambda returning the list of potentially intersecting sub meshes.
  33812. */
  33813. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33814. /**
  33815. * Lambda returning the list of potentially colliding sub meshes.
  33816. */
  33817. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33818. private _activeMeshesFrozen;
  33819. /**
  33820. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33821. * @returns the current scene
  33822. */
  33823. freezeActiveMeshes(): Scene;
  33824. /**
  33825. * Use this function to restart evaluating active meshes on every frame
  33826. * @returns the current scene
  33827. */
  33828. unfreezeActiveMeshes(): Scene;
  33829. private _evaluateActiveMeshes;
  33830. private _activeMesh;
  33831. /**
  33832. * Update the transform matrix to update from the current active camera
  33833. * @param force defines a boolean used to force the update even if cache is up to date
  33834. */
  33835. updateTransformMatrix(force?: boolean): void;
  33836. private _bindFrameBuffer;
  33837. /** @hidden */
  33838. _allowPostProcessClearColor: boolean;
  33839. /** @hidden */
  33840. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33841. private _processSubCameras;
  33842. private _checkIntersections;
  33843. /** @hidden */
  33844. _advancePhysicsEngineStep(step: number): void;
  33845. /**
  33846. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33847. */
  33848. getDeterministicFrameTime: () => number;
  33849. /** @hidden */
  33850. _animate(): void;
  33851. /** Execute all animations (for a frame) */
  33852. animate(): void;
  33853. /**
  33854. * Render the scene
  33855. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33856. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33857. */
  33858. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33859. /**
  33860. * Freeze all materials
  33861. * A frozen material will not be updatable but should be faster to render
  33862. */
  33863. freezeMaterials(): void;
  33864. /**
  33865. * Unfreeze all materials
  33866. * A frozen material will not be updatable but should be faster to render
  33867. */
  33868. unfreezeMaterials(): void;
  33869. /**
  33870. * Releases all held ressources
  33871. */
  33872. dispose(): void;
  33873. /**
  33874. * Gets if the scene is already disposed
  33875. */
  33876. readonly isDisposed: boolean;
  33877. /**
  33878. * Call this function to reduce memory footprint of the scene.
  33879. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33880. */
  33881. clearCachedVertexData(): void;
  33882. /**
  33883. * This function will remove the local cached buffer data from texture.
  33884. * It will save memory but will prevent the texture from being rebuilt
  33885. */
  33886. cleanCachedTextureBuffer(): void;
  33887. /**
  33888. * Get the world extend vectors with an optional filter
  33889. *
  33890. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33891. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33892. */
  33893. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33894. min: Vector3;
  33895. max: Vector3;
  33896. };
  33897. /**
  33898. * Creates a ray that can be used to pick in the scene
  33899. * @param x defines the x coordinate of the origin (on-screen)
  33900. * @param y defines the y coordinate of the origin (on-screen)
  33901. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33902. * @param camera defines the camera to use for the picking
  33903. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33904. * @returns a Ray
  33905. */
  33906. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33907. /**
  33908. * Creates a ray that can be used to pick in the scene
  33909. * @param x defines the x coordinate of the origin (on-screen)
  33910. * @param y defines the y coordinate of the origin (on-screen)
  33911. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33912. * @param result defines the ray where to store the picking ray
  33913. * @param camera defines the camera to use for the picking
  33914. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33915. * @returns the current scene
  33916. */
  33917. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33918. /**
  33919. * Creates a ray that can be used to pick in the scene
  33920. * @param x defines the x coordinate of the origin (on-screen)
  33921. * @param y defines the y coordinate of the origin (on-screen)
  33922. * @param camera defines the camera to use for the picking
  33923. * @returns a Ray
  33924. */
  33925. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33926. /**
  33927. * Creates a ray that can be used to pick in the scene
  33928. * @param x defines the x coordinate of the origin (on-screen)
  33929. * @param y defines the y coordinate of the origin (on-screen)
  33930. * @param result defines the ray where to store the picking ray
  33931. * @param camera defines the camera to use for the picking
  33932. * @returns the current scene
  33933. */
  33934. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33935. /** Launch a ray to try to pick a mesh in the scene
  33936. * @param x position on screen
  33937. * @param y position on screen
  33938. * @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
  33939. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33940. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33942. * @returns a PickingInfo
  33943. */
  33944. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33945. /** Use the given ray to pick a mesh in the scene
  33946. * @param ray The ray to use to pick meshes
  33947. * @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
  33948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33949. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33950. * @returns a PickingInfo
  33951. */
  33952. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33953. /**
  33954. * Launch a ray to try to pick a mesh in the scene
  33955. * @param x X position on screen
  33956. * @param y Y position on screen
  33957. * @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
  33958. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33959. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33960. * @returns an array of PickingInfo
  33961. */
  33962. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33963. /**
  33964. * Launch a ray to try to pick a mesh in the scene
  33965. * @param ray Ray to use
  33966. * @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
  33967. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33968. * @returns an array of PickingInfo
  33969. */
  33970. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33971. /**
  33972. * Force the value of meshUnderPointer
  33973. * @param mesh defines the mesh to use
  33974. */
  33975. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33976. /**
  33977. * Gets the mesh under the pointer
  33978. * @returns a Mesh or null if no mesh is under the pointer
  33979. */
  33980. getPointerOverMesh(): Nullable<AbstractMesh>;
  33981. /** @hidden */
  33982. _rebuildGeometries(): void;
  33983. /** @hidden */
  33984. _rebuildTextures(): void;
  33985. private _getByTags;
  33986. /**
  33987. * Get a list of meshes by tags
  33988. * @param tagsQuery defines the tags query to use
  33989. * @param forEach defines a predicate used to filter results
  33990. * @returns an array of Mesh
  33991. */
  33992. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33993. /**
  33994. * Get a list of cameras by tags
  33995. * @param tagsQuery defines the tags query to use
  33996. * @param forEach defines a predicate used to filter results
  33997. * @returns an array of Camera
  33998. */
  33999. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34000. /**
  34001. * Get a list of lights by tags
  34002. * @param tagsQuery defines the tags query to use
  34003. * @param forEach defines a predicate used to filter results
  34004. * @returns an array of Light
  34005. */
  34006. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34007. /**
  34008. * Get a list of materials by tags
  34009. * @param tagsQuery defines the tags query to use
  34010. * @param forEach defines a predicate used to filter results
  34011. * @returns an array of Material
  34012. */
  34013. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34014. /**
  34015. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34016. * This allowed control for front to back rendering or reversly depending of the special needs.
  34017. *
  34018. * @param renderingGroupId The rendering group id corresponding to its index
  34019. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34020. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34021. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34022. */
  34023. 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;
  34024. /**
  34025. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34026. *
  34027. * @param renderingGroupId The rendering group id corresponding to its index
  34028. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34029. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34030. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34031. */
  34032. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34033. /**
  34034. * Gets the current auto clear configuration for one rendering group of the rendering
  34035. * manager.
  34036. * @param index the rendering group index to get the information for
  34037. * @returns The auto clear setup for the requested rendering group
  34038. */
  34039. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34040. private _blockMaterialDirtyMechanism;
  34041. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34042. blockMaterialDirtyMechanism: boolean;
  34043. /**
  34044. * Will flag all materials as dirty to trigger new shader compilation
  34045. * @param flag defines the flag used to specify which material part must be marked as dirty
  34046. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34047. */
  34048. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34049. /** @hidden */
  34050. _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;
  34051. /** @hidden */
  34052. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * Set of assets to keep when moving a scene into an asset container.
  34058. */
  34059. export class KeepAssets extends AbstractScene {
  34060. }
  34061. /**
  34062. * Container with a set of assets that can be added or removed from a scene.
  34063. */
  34064. export class AssetContainer extends AbstractScene {
  34065. /**
  34066. * The scene the AssetContainer belongs to.
  34067. */
  34068. scene: Scene;
  34069. /**
  34070. * Instantiates an AssetContainer.
  34071. * @param scene The scene the AssetContainer belongs to.
  34072. */
  34073. constructor(scene: Scene);
  34074. /**
  34075. * Adds all the assets from the container to the scene.
  34076. */
  34077. addAllToScene(): void;
  34078. /**
  34079. * Removes all the assets in the container from the scene
  34080. */
  34081. removeAllFromScene(): void;
  34082. /**
  34083. * Disposes all the assets in the container
  34084. */
  34085. dispose(): void;
  34086. private _moveAssets;
  34087. /**
  34088. * Removes all the assets contained in the scene and adds them to the container.
  34089. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34090. */
  34091. moveAllFromScene(keepAssets?: KeepAssets): void;
  34092. /**
  34093. * 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.
  34094. * @returns the root mesh
  34095. */
  34096. createRootMesh(): Mesh;
  34097. }
  34098. }
  34099. declare module BABYLON {
  34100. /**
  34101. * Defines how the parser contract is defined.
  34102. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34103. */
  34104. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34105. /**
  34106. * Defines how the individual parser contract is defined.
  34107. * These parser can parse an individual asset
  34108. */
  34109. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34110. /**
  34111. * Base class of the scene acting as a container for the different elements composing a scene.
  34112. * This class is dynamically extended by the different components of the scene increasing
  34113. * flexibility and reducing coupling
  34114. */
  34115. export abstract class AbstractScene {
  34116. /**
  34117. * Stores the list of available parsers in the application.
  34118. */
  34119. private static _BabylonFileParsers;
  34120. /**
  34121. * Stores the list of available individual parsers in the application.
  34122. */
  34123. private static _IndividualBabylonFileParsers;
  34124. /**
  34125. * Adds a parser in the list of available ones
  34126. * @param name Defines the name of the parser
  34127. * @param parser Defines the parser to add
  34128. */
  34129. static AddParser(name: string, parser: BabylonFileParser): void;
  34130. /**
  34131. * Gets a general parser from the list of avaialble ones
  34132. * @param name Defines the name of the parser
  34133. * @returns the requested parser or null
  34134. */
  34135. static GetParser(name: string): Nullable<BabylonFileParser>;
  34136. /**
  34137. * Adds n individual parser in the list of available ones
  34138. * @param name Defines the name of the parser
  34139. * @param parser Defines the parser to add
  34140. */
  34141. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34142. /**
  34143. * Gets an individual parser from the list of avaialble ones
  34144. * @param name Defines the name of the parser
  34145. * @returns the requested parser or null
  34146. */
  34147. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34148. /**
  34149. * Parser json data and populate both a scene and its associated container object
  34150. * @param jsonData Defines the data to parse
  34151. * @param scene Defines the scene to parse the data for
  34152. * @param container Defines the container attached to the parsing sequence
  34153. * @param rootUrl Defines the root url of the data
  34154. */
  34155. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34156. /**
  34157. * Gets the list of root nodes (ie. nodes with no parent)
  34158. */
  34159. rootNodes: Node[];
  34160. /** All of the cameras added to this scene
  34161. * @see http://doc.babylonjs.com/babylon101/cameras
  34162. */
  34163. cameras: Camera[];
  34164. /**
  34165. * All of the lights added to this scene
  34166. * @see http://doc.babylonjs.com/babylon101/lights
  34167. */
  34168. lights: Light[];
  34169. /**
  34170. * All of the (abstract) meshes added to this scene
  34171. */
  34172. meshes: AbstractMesh[];
  34173. /**
  34174. * The list of skeletons added to the scene
  34175. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34176. */
  34177. skeletons: Skeleton[];
  34178. /**
  34179. * All of the particle systems added to this scene
  34180. * @see http://doc.babylonjs.com/babylon101/particles
  34181. */
  34182. particleSystems: IParticleSystem[];
  34183. /**
  34184. * Gets a list of Animations associated with the scene
  34185. */
  34186. animations: Animation[];
  34187. /**
  34188. * All of the animation groups added to this scene
  34189. * @see http://doc.babylonjs.com/how_to/group
  34190. */
  34191. animationGroups: AnimationGroup[];
  34192. /**
  34193. * All of the multi-materials added to this scene
  34194. * @see http://doc.babylonjs.com/how_to/multi_materials
  34195. */
  34196. multiMaterials: MultiMaterial[];
  34197. /**
  34198. * All of the materials added to this scene
  34199. * In the context of a Scene, it is not supposed to be modified manually.
  34200. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34201. * Note also that the order of the Material wihin the array is not significant and might change.
  34202. * @see http://doc.babylonjs.com/babylon101/materials
  34203. */
  34204. materials: Material[];
  34205. /**
  34206. * The list of morph target managers added to the scene
  34207. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34208. */
  34209. morphTargetManagers: MorphTargetManager[];
  34210. /**
  34211. * The list of geometries used in the scene.
  34212. */
  34213. geometries: Geometry[];
  34214. /**
  34215. * All of the tranform nodes added to this scene
  34216. * In the context of a Scene, it is not supposed to be modified manually.
  34217. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34218. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34219. * @see http://doc.babylonjs.com/how_to/transformnode
  34220. */
  34221. transformNodes: TransformNode[];
  34222. /**
  34223. * ActionManagers available on the scene.
  34224. */
  34225. actionManagers: AbstractActionManager[];
  34226. /**
  34227. * Textures to keep.
  34228. */
  34229. textures: BaseTexture[];
  34230. /**
  34231. * Environment texture for the scene
  34232. */
  34233. environmentTexture: Nullable<BaseTexture>;
  34234. }
  34235. }
  34236. declare module BABYLON {
  34237. /**
  34238. * Interface used to define options for Sound class
  34239. */
  34240. export interface ISoundOptions {
  34241. /**
  34242. * Does the sound autoplay once loaded.
  34243. */
  34244. autoplay?: boolean;
  34245. /**
  34246. * Does the sound loop after it finishes playing once.
  34247. */
  34248. loop?: boolean;
  34249. /**
  34250. * Sound's volume
  34251. */
  34252. volume?: number;
  34253. /**
  34254. * Is it a spatial sound?
  34255. */
  34256. spatialSound?: boolean;
  34257. /**
  34258. * Maximum distance to hear that sound
  34259. */
  34260. maxDistance?: number;
  34261. /**
  34262. * Uses user defined attenuation function
  34263. */
  34264. useCustomAttenuation?: boolean;
  34265. /**
  34266. * Define the roll off factor of spatial sounds.
  34267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34268. */
  34269. rolloffFactor?: number;
  34270. /**
  34271. * Define the reference distance the sound should be heard perfectly.
  34272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34273. */
  34274. refDistance?: number;
  34275. /**
  34276. * Define the distance attenuation model the sound will follow.
  34277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34278. */
  34279. distanceModel?: string;
  34280. /**
  34281. * Defines the playback speed (1 by default)
  34282. */
  34283. playbackRate?: number;
  34284. /**
  34285. * Defines if the sound is from a streaming source
  34286. */
  34287. streaming?: boolean;
  34288. /**
  34289. * Defines an optional length (in seconds) inside the sound file
  34290. */
  34291. length?: number;
  34292. /**
  34293. * Defines an optional offset (in seconds) inside the sound file
  34294. */
  34295. offset?: number;
  34296. }
  34297. /**
  34298. * Defines a sound that can be played in the application.
  34299. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34301. */
  34302. export class Sound {
  34303. /**
  34304. * The name of the sound in the scene.
  34305. */
  34306. name: string;
  34307. /**
  34308. * Does the sound autoplay once loaded.
  34309. */
  34310. autoplay: boolean;
  34311. /**
  34312. * Does the sound loop after it finishes playing once.
  34313. */
  34314. loop: boolean;
  34315. /**
  34316. * Does the sound use a custom attenuation curve to simulate the falloff
  34317. * happening when the source gets further away from the camera.
  34318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34319. */
  34320. useCustomAttenuation: boolean;
  34321. /**
  34322. * The sound track id this sound belongs to.
  34323. */
  34324. soundTrackId: number;
  34325. /**
  34326. * Is this sound currently played.
  34327. */
  34328. isPlaying: boolean;
  34329. /**
  34330. * Is this sound currently paused.
  34331. */
  34332. isPaused: boolean;
  34333. /**
  34334. * Does this sound enables spatial sound.
  34335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34336. */
  34337. spatialSound: boolean;
  34338. /**
  34339. * Define the reference distance the sound should be heard perfectly.
  34340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34341. */
  34342. refDistance: number;
  34343. /**
  34344. * Define the roll off factor of spatial sounds.
  34345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34346. */
  34347. rolloffFactor: number;
  34348. /**
  34349. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34351. */
  34352. maxDistance: number;
  34353. /**
  34354. * Define the distance attenuation model the sound will follow.
  34355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34356. */
  34357. distanceModel: string;
  34358. /**
  34359. * @hidden
  34360. * Back Compat
  34361. **/
  34362. onended: () => any;
  34363. /**
  34364. * Observable event when the current playing sound finishes.
  34365. */
  34366. onEndedObservable: Observable<Sound>;
  34367. private _panningModel;
  34368. private _playbackRate;
  34369. private _streaming;
  34370. private _startTime;
  34371. private _startOffset;
  34372. private _position;
  34373. /** @hidden */
  34374. _positionInEmitterSpace: boolean;
  34375. private _localDirection;
  34376. private _volume;
  34377. private _isReadyToPlay;
  34378. private _isDirectional;
  34379. private _readyToPlayCallback;
  34380. private _audioBuffer;
  34381. private _soundSource;
  34382. private _streamingSource;
  34383. private _soundPanner;
  34384. private _soundGain;
  34385. private _inputAudioNode;
  34386. private _outputAudioNode;
  34387. private _coneInnerAngle;
  34388. private _coneOuterAngle;
  34389. private _coneOuterGain;
  34390. private _scene;
  34391. private _connectedTransformNode;
  34392. private _customAttenuationFunction;
  34393. private _registerFunc;
  34394. private _isOutputConnected;
  34395. private _htmlAudioElement;
  34396. private _urlType;
  34397. private _length?;
  34398. private _offset?;
  34399. /** @hidden */
  34400. static _SceneComponentInitialization: (scene: Scene) => void;
  34401. /**
  34402. * Create a sound and attach it to a scene
  34403. * @param name Name of your sound
  34404. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34405. * @param scene defines the scene the sound belongs to
  34406. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34407. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34408. */
  34409. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34410. /**
  34411. * Release the sound and its associated resources
  34412. */
  34413. dispose(): void;
  34414. /**
  34415. * Gets if the sounds is ready to be played or not.
  34416. * @returns true if ready, otherwise false
  34417. */
  34418. isReady(): boolean;
  34419. private _soundLoaded;
  34420. /**
  34421. * Sets the data of the sound from an audiobuffer
  34422. * @param audioBuffer The audioBuffer containing the data
  34423. */
  34424. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34425. /**
  34426. * Updates the current sounds options such as maxdistance, loop...
  34427. * @param options A JSON object containing values named as the object properties
  34428. */
  34429. updateOptions(options: ISoundOptions): void;
  34430. private _createSpatialParameters;
  34431. private _updateSpatialParameters;
  34432. /**
  34433. * Switch the panning model to HRTF:
  34434. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34436. */
  34437. switchPanningModelToHRTF(): void;
  34438. /**
  34439. * Switch the panning model to Equal Power:
  34440. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34442. */
  34443. switchPanningModelToEqualPower(): void;
  34444. private _switchPanningModel;
  34445. /**
  34446. * Connect this sound to a sound track audio node like gain...
  34447. * @param soundTrackAudioNode the sound track audio node to connect to
  34448. */
  34449. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34450. /**
  34451. * Transform this sound into a directional source
  34452. * @param coneInnerAngle Size of the inner cone in degree
  34453. * @param coneOuterAngle Size of the outer cone in degree
  34454. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34455. */
  34456. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34457. /**
  34458. * Gets or sets the inner angle for the directional cone.
  34459. */
  34460. /**
  34461. * Gets or sets the inner angle for the directional cone.
  34462. */
  34463. directionalConeInnerAngle: number;
  34464. /**
  34465. * Gets or sets the outer angle for the directional cone.
  34466. */
  34467. /**
  34468. * Gets or sets the outer angle for the directional cone.
  34469. */
  34470. directionalConeOuterAngle: number;
  34471. /**
  34472. * Sets the position of the emitter if spatial sound is enabled
  34473. * @param newPosition Defines the new posisiton
  34474. */
  34475. setPosition(newPosition: Vector3): void;
  34476. /**
  34477. * Sets the local direction of the emitter if spatial sound is enabled
  34478. * @param newLocalDirection Defines the new local direction
  34479. */
  34480. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34481. private _updateDirection;
  34482. /** @hidden */
  34483. updateDistanceFromListener(): void;
  34484. /**
  34485. * Sets a new custom attenuation function for the sound.
  34486. * @param callback Defines the function used for the attenuation
  34487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34488. */
  34489. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34490. /**
  34491. * Play the sound
  34492. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34493. * @param offset (optional) Start the sound at a specific time in seconds
  34494. * @param length (optional) Sound duration (in seconds)
  34495. */
  34496. play(time?: number, offset?: number, length?: number): void;
  34497. private _onended;
  34498. /**
  34499. * Stop the sound
  34500. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34501. */
  34502. stop(time?: number): void;
  34503. /**
  34504. * Put the sound in pause
  34505. */
  34506. pause(): void;
  34507. /**
  34508. * Sets a dedicated volume for this sounds
  34509. * @param newVolume Define the new volume of the sound
  34510. * @param time Define time for gradual change to new volume
  34511. */
  34512. setVolume(newVolume: number, time?: number): void;
  34513. /**
  34514. * Set the sound play back rate
  34515. * @param newPlaybackRate Define the playback rate the sound should be played at
  34516. */
  34517. setPlaybackRate(newPlaybackRate: number): void;
  34518. /**
  34519. * Gets the volume of the sound.
  34520. * @returns the volume of the sound
  34521. */
  34522. getVolume(): number;
  34523. /**
  34524. * Attach the sound to a dedicated mesh
  34525. * @param transformNode The transform node to connect the sound with
  34526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34527. */
  34528. attachToMesh(transformNode: TransformNode): void;
  34529. /**
  34530. * Detach the sound from the previously attached mesh
  34531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34532. */
  34533. detachFromMesh(): void;
  34534. private _onRegisterAfterWorldMatrixUpdate;
  34535. /**
  34536. * Clone the current sound in the scene.
  34537. * @returns the new sound clone
  34538. */
  34539. clone(): Nullable<Sound>;
  34540. /**
  34541. * Gets the current underlying audio buffer containing the data
  34542. * @returns the audio buffer
  34543. */
  34544. getAudioBuffer(): Nullable<AudioBuffer>;
  34545. /**
  34546. * Serializes the Sound in a JSON representation
  34547. * @returns the JSON representation of the sound
  34548. */
  34549. serialize(): any;
  34550. /**
  34551. * Parse a JSON representation of a sound to innstantiate in a given scene
  34552. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34553. * @param scene Define the scene the new parsed sound should be created in
  34554. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34555. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34556. * @returns the newly parsed sound
  34557. */
  34558. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34559. }
  34560. }
  34561. declare module BABYLON {
  34562. /**
  34563. * This defines an action helpful to play a defined sound on a triggered action.
  34564. */
  34565. export class PlaySoundAction extends Action {
  34566. private _sound;
  34567. /**
  34568. * Instantiate the action
  34569. * @param triggerOptions defines the trigger options
  34570. * @param sound defines the sound to play
  34571. * @param condition defines the trigger related conditions
  34572. */
  34573. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34574. /** @hidden */
  34575. _prepare(): void;
  34576. /**
  34577. * Execute the action and play the sound.
  34578. */
  34579. execute(): void;
  34580. /**
  34581. * Serializes the actions and its related information.
  34582. * @param parent defines the object to serialize in
  34583. * @returns the serialized object
  34584. */
  34585. serialize(parent: any): any;
  34586. }
  34587. /**
  34588. * This defines an action helpful to stop a defined sound on a triggered action.
  34589. */
  34590. export class StopSoundAction extends Action {
  34591. private _sound;
  34592. /**
  34593. * Instantiate the action
  34594. * @param triggerOptions defines the trigger options
  34595. * @param sound defines the sound to stop
  34596. * @param condition defines the trigger related conditions
  34597. */
  34598. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34599. /** @hidden */
  34600. _prepare(): void;
  34601. /**
  34602. * Execute the action and stop the sound.
  34603. */
  34604. execute(): void;
  34605. /**
  34606. * Serializes the actions and its related information.
  34607. * @param parent defines the object to serialize in
  34608. * @returns the serialized object
  34609. */
  34610. serialize(parent: any): any;
  34611. }
  34612. }
  34613. declare module BABYLON {
  34614. /**
  34615. * This defines an action responsible to change the value of a property
  34616. * by interpolating between its current value and the newly set one once triggered.
  34617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34618. */
  34619. export class InterpolateValueAction extends Action {
  34620. /**
  34621. * Defines the path of the property where the value should be interpolated
  34622. */
  34623. propertyPath: string;
  34624. /**
  34625. * Defines the target value at the end of the interpolation.
  34626. */
  34627. value: any;
  34628. /**
  34629. * Defines the time it will take for the property to interpolate to the value.
  34630. */
  34631. duration: number;
  34632. /**
  34633. * Defines if the other scene animations should be stopped when the action has been triggered
  34634. */
  34635. stopOtherAnimations?: boolean;
  34636. /**
  34637. * Defines a callback raised once the interpolation animation has been done.
  34638. */
  34639. onInterpolationDone?: () => void;
  34640. /**
  34641. * Observable triggered once the interpolation animation has been done.
  34642. */
  34643. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34644. private _target;
  34645. private _effectiveTarget;
  34646. private _property;
  34647. /**
  34648. * Instantiate the action
  34649. * @param triggerOptions defines the trigger options
  34650. * @param target defines the object containing the value to interpolate
  34651. * @param propertyPath defines the path to the property in the target object
  34652. * @param value defines the target value at the end of the interpolation
  34653. * @param duration deines the time it will take for the property to interpolate to the value.
  34654. * @param condition defines the trigger related conditions
  34655. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34656. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34657. */
  34658. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34659. /** @hidden */
  34660. _prepare(): void;
  34661. /**
  34662. * Execute the action starts the value interpolation.
  34663. */
  34664. execute(): void;
  34665. /**
  34666. * Serializes the actions and its related information.
  34667. * @param parent defines the object to serialize in
  34668. * @returns the serialized object
  34669. */
  34670. serialize(parent: any): any;
  34671. }
  34672. }
  34673. declare module BABYLON {
  34674. /**
  34675. * Options allowed during the creation of a sound track.
  34676. */
  34677. export interface ISoundTrackOptions {
  34678. /**
  34679. * The volume the sound track should take during creation
  34680. */
  34681. volume?: number;
  34682. /**
  34683. * Define if the sound track is the main sound track of the scene
  34684. */
  34685. mainTrack?: boolean;
  34686. }
  34687. /**
  34688. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34689. * It will be also used in a future release to apply effects on a specific track.
  34690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34691. */
  34692. export class SoundTrack {
  34693. /**
  34694. * The unique identifier of the sound track in the scene.
  34695. */
  34696. id: number;
  34697. /**
  34698. * The list of sounds included in the sound track.
  34699. */
  34700. soundCollection: Array<Sound>;
  34701. private _outputAudioNode;
  34702. private _scene;
  34703. private _isMainTrack;
  34704. private _connectedAnalyser;
  34705. private _options;
  34706. private _isInitialized;
  34707. /**
  34708. * Creates a new sound track.
  34709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34710. * @param scene Define the scene the sound track belongs to
  34711. * @param options
  34712. */
  34713. constructor(scene: Scene, options?: ISoundTrackOptions);
  34714. private _initializeSoundTrackAudioGraph;
  34715. /**
  34716. * Release the sound track and its associated resources
  34717. */
  34718. dispose(): void;
  34719. /**
  34720. * Adds a sound to this sound track
  34721. * @param sound define the cound to add
  34722. * @ignoreNaming
  34723. */
  34724. AddSound(sound: Sound): void;
  34725. /**
  34726. * Removes a sound to this sound track
  34727. * @param sound define the cound to remove
  34728. * @ignoreNaming
  34729. */
  34730. RemoveSound(sound: Sound): void;
  34731. /**
  34732. * Set a global volume for the full sound track.
  34733. * @param newVolume Define the new volume of the sound track
  34734. */
  34735. setVolume(newVolume: number): void;
  34736. /**
  34737. * Switch the panning model to HRTF:
  34738. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34740. */
  34741. switchPanningModelToHRTF(): void;
  34742. /**
  34743. * Switch the panning model to Equal Power:
  34744. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34746. */
  34747. switchPanningModelToEqualPower(): void;
  34748. /**
  34749. * Connect the sound track to an audio analyser allowing some amazing
  34750. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34752. * @param analyser The analyser to connect to the engine
  34753. */
  34754. connectToAnalyser(analyser: Analyser): void;
  34755. }
  34756. }
  34757. declare module BABYLON {
  34758. interface AbstractScene {
  34759. /**
  34760. * The list of sounds used in the scene.
  34761. */
  34762. sounds: Nullable<Array<Sound>>;
  34763. }
  34764. interface Scene {
  34765. /**
  34766. * @hidden
  34767. * Backing field
  34768. */
  34769. _mainSoundTrack: SoundTrack;
  34770. /**
  34771. * The main sound track played by the scene.
  34772. * It cotains your primary collection of sounds.
  34773. */
  34774. mainSoundTrack: SoundTrack;
  34775. /**
  34776. * The list of sound tracks added to the scene
  34777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34778. */
  34779. soundTracks: Nullable<Array<SoundTrack>>;
  34780. /**
  34781. * Gets a sound using a given name
  34782. * @param name defines the name to search for
  34783. * @return the found sound or null if not found at all.
  34784. */
  34785. getSoundByName(name: string): Nullable<Sound>;
  34786. /**
  34787. * Gets or sets if audio support is enabled
  34788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34789. */
  34790. audioEnabled: boolean;
  34791. /**
  34792. * Gets or sets if audio will be output to headphones
  34793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34794. */
  34795. headphone: boolean;
  34796. }
  34797. /**
  34798. * Defines the sound scene component responsible to manage any sounds
  34799. * in a given scene.
  34800. */
  34801. export class AudioSceneComponent implements ISceneSerializableComponent {
  34802. /**
  34803. * The component name helpfull to identify the component in the list of scene components.
  34804. */
  34805. readonly name: string;
  34806. /**
  34807. * The scene the component belongs to.
  34808. */
  34809. scene: Scene;
  34810. private _audioEnabled;
  34811. /**
  34812. * Gets whether audio is enabled or not.
  34813. * Please use related enable/disable method to switch state.
  34814. */
  34815. readonly audioEnabled: boolean;
  34816. private _headphone;
  34817. /**
  34818. * Gets whether audio is outputing to headphone or not.
  34819. * Please use the according Switch methods to change output.
  34820. */
  34821. readonly headphone: boolean;
  34822. /**
  34823. * Creates a new instance of the component for the given scene
  34824. * @param scene Defines the scene to register the component in
  34825. */
  34826. constructor(scene: Scene);
  34827. /**
  34828. * Registers the component in a given scene
  34829. */
  34830. register(): void;
  34831. /**
  34832. * Rebuilds the elements related to this component in case of
  34833. * context lost for instance.
  34834. */
  34835. rebuild(): void;
  34836. /**
  34837. * Serializes the component data to the specified json object
  34838. * @param serializationObject The object to serialize to
  34839. */
  34840. serialize(serializationObject: any): void;
  34841. /**
  34842. * Adds all the elements from the container to the scene
  34843. * @param container the container holding the elements
  34844. */
  34845. addFromContainer(container: AbstractScene): void;
  34846. /**
  34847. * Removes all the elements in the container from the scene
  34848. * @param container contains the elements to remove
  34849. * @param dispose if the removed element should be disposed (default: false)
  34850. */
  34851. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34852. /**
  34853. * Disposes the component and the associated ressources.
  34854. */
  34855. dispose(): void;
  34856. /**
  34857. * Disables audio in the associated scene.
  34858. */
  34859. disableAudio(): void;
  34860. /**
  34861. * Enables audio in the associated scene.
  34862. */
  34863. enableAudio(): void;
  34864. /**
  34865. * Switch audio to headphone output.
  34866. */
  34867. switchAudioModeForHeadphones(): void;
  34868. /**
  34869. * Switch audio to normal speakers.
  34870. */
  34871. switchAudioModeForNormalSpeakers(): void;
  34872. private _afterRender;
  34873. }
  34874. }
  34875. declare module BABYLON {
  34876. /**
  34877. * Wraps one or more Sound objects and selects one with random weight for playback.
  34878. */
  34879. export class WeightedSound {
  34880. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34881. loop: boolean;
  34882. private _coneInnerAngle;
  34883. private _coneOuterAngle;
  34884. private _volume;
  34885. /** A Sound is currently playing. */
  34886. isPlaying: boolean;
  34887. /** A Sound is currently paused. */
  34888. isPaused: boolean;
  34889. private _sounds;
  34890. private _weights;
  34891. private _currentIndex?;
  34892. /**
  34893. * Creates a new WeightedSound from the list of sounds given.
  34894. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34895. * @param sounds Array of Sounds that will be selected from.
  34896. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34897. */
  34898. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34899. /**
  34900. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34901. */
  34902. /**
  34903. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34904. */
  34905. directionalConeInnerAngle: number;
  34906. /**
  34907. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34908. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34909. */
  34910. /**
  34911. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34912. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34913. */
  34914. directionalConeOuterAngle: number;
  34915. /**
  34916. * Playback volume.
  34917. */
  34918. /**
  34919. * Playback volume.
  34920. */
  34921. volume: number;
  34922. private _onended;
  34923. /**
  34924. * Suspend playback
  34925. */
  34926. pause(): void;
  34927. /**
  34928. * Stop playback
  34929. */
  34930. stop(): void;
  34931. /**
  34932. * Start playback.
  34933. * @param startOffset Position the clip head at a specific time in seconds.
  34934. */
  34935. play(startOffset?: number): void;
  34936. }
  34937. }
  34938. declare module BABYLON {
  34939. /**
  34940. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34942. */
  34943. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34944. /**
  34945. * Gets the name of the behavior.
  34946. */
  34947. readonly name: string;
  34948. /**
  34949. * The easing function used by animations
  34950. */
  34951. static EasingFunction: BackEase;
  34952. /**
  34953. * The easing mode used by animations
  34954. */
  34955. static EasingMode: number;
  34956. /**
  34957. * The duration of the animation, in milliseconds
  34958. */
  34959. transitionDuration: number;
  34960. /**
  34961. * Length of the distance animated by the transition when lower radius is reached
  34962. */
  34963. lowerRadiusTransitionRange: number;
  34964. /**
  34965. * Length of the distance animated by the transition when upper radius is reached
  34966. */
  34967. upperRadiusTransitionRange: number;
  34968. private _autoTransitionRange;
  34969. /**
  34970. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34971. */
  34972. /**
  34973. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34974. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34975. */
  34976. autoTransitionRange: boolean;
  34977. private _attachedCamera;
  34978. private _onAfterCheckInputsObserver;
  34979. private _onMeshTargetChangedObserver;
  34980. /**
  34981. * Initializes the behavior.
  34982. */
  34983. init(): void;
  34984. /**
  34985. * Attaches the behavior to its arc rotate camera.
  34986. * @param camera Defines the camera to attach the behavior to
  34987. */
  34988. attach(camera: ArcRotateCamera): void;
  34989. /**
  34990. * Detaches the behavior from its current arc rotate camera.
  34991. */
  34992. detach(): void;
  34993. private _radiusIsAnimating;
  34994. private _radiusBounceTransition;
  34995. private _animatables;
  34996. private _cachedWheelPrecision;
  34997. /**
  34998. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34999. * @param radiusLimit The limit to check against.
  35000. * @return Bool to indicate if at limit.
  35001. */
  35002. private _isRadiusAtLimit;
  35003. /**
  35004. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35005. * @param radiusDelta The delta by which to animate to. Can be negative.
  35006. */
  35007. private _applyBoundRadiusAnimation;
  35008. /**
  35009. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35010. */
  35011. protected _clearAnimationLocks(): void;
  35012. /**
  35013. * Stops and removes all animations that have been applied to the camera
  35014. */
  35015. stopAllAnimations(): void;
  35016. }
  35017. }
  35018. declare module BABYLON {
  35019. /**
  35020. * 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.
  35021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35022. */
  35023. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35024. /**
  35025. * Gets the name of the behavior.
  35026. */
  35027. readonly name: string;
  35028. private _mode;
  35029. private _radiusScale;
  35030. private _positionScale;
  35031. private _defaultElevation;
  35032. private _elevationReturnTime;
  35033. private _elevationReturnWaitTime;
  35034. private _zoomStopsAnimation;
  35035. private _framingTime;
  35036. /**
  35037. * The easing function used by animations
  35038. */
  35039. static EasingFunction: ExponentialEase;
  35040. /**
  35041. * The easing mode used by animations
  35042. */
  35043. static EasingMode: number;
  35044. /**
  35045. * Sets the current mode used by the behavior
  35046. */
  35047. /**
  35048. * Gets current mode used by the behavior.
  35049. */
  35050. mode: number;
  35051. /**
  35052. * Sets the scale applied to the radius (1 by default)
  35053. */
  35054. /**
  35055. * Gets the scale applied to the radius
  35056. */
  35057. radiusScale: number;
  35058. /**
  35059. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35060. */
  35061. /**
  35062. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35063. */
  35064. positionScale: number;
  35065. /**
  35066. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35067. * behaviour is triggered, in radians.
  35068. */
  35069. /**
  35070. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35071. * behaviour is triggered, in radians.
  35072. */
  35073. defaultElevation: number;
  35074. /**
  35075. * Sets the time (in milliseconds) taken to return to the default beta position.
  35076. * Negative value indicates camera should not return to default.
  35077. */
  35078. /**
  35079. * Gets the time (in milliseconds) taken to return to the default beta position.
  35080. * Negative value indicates camera should not return to default.
  35081. */
  35082. elevationReturnTime: number;
  35083. /**
  35084. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35085. */
  35086. /**
  35087. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35088. */
  35089. elevationReturnWaitTime: number;
  35090. /**
  35091. * Sets the flag that indicates if user zooming should stop animation.
  35092. */
  35093. /**
  35094. * Gets the flag that indicates if user zooming should stop animation.
  35095. */
  35096. zoomStopsAnimation: boolean;
  35097. /**
  35098. * Sets the transition time when framing the mesh, in milliseconds
  35099. */
  35100. /**
  35101. * Gets the transition time when framing the mesh, in milliseconds
  35102. */
  35103. framingTime: number;
  35104. /**
  35105. * Define if the behavior should automatically change the configured
  35106. * camera limits and sensibilities.
  35107. */
  35108. autoCorrectCameraLimitsAndSensibility: boolean;
  35109. private _onPrePointerObservableObserver;
  35110. private _onAfterCheckInputsObserver;
  35111. private _onMeshTargetChangedObserver;
  35112. private _attachedCamera;
  35113. private _isPointerDown;
  35114. private _lastInteractionTime;
  35115. /**
  35116. * Initializes the behavior.
  35117. */
  35118. init(): void;
  35119. /**
  35120. * Attaches the behavior to its arc rotate camera.
  35121. * @param camera Defines the camera to attach the behavior to
  35122. */
  35123. attach(camera: ArcRotateCamera): void;
  35124. /**
  35125. * Detaches the behavior from its current arc rotate camera.
  35126. */
  35127. detach(): void;
  35128. private _animatables;
  35129. private _betaIsAnimating;
  35130. private _betaTransition;
  35131. private _radiusTransition;
  35132. private _vectorTransition;
  35133. /**
  35134. * Targets the given mesh and updates zoom level accordingly.
  35135. * @param mesh The mesh to target.
  35136. * @param radius Optional. If a cached radius position already exists, overrides default.
  35137. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35138. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35139. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35140. */
  35141. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35142. /**
  35143. * Targets the given mesh with its children and updates zoom level accordingly.
  35144. * @param mesh The mesh to target.
  35145. * @param radius Optional. If a cached radius position already exists, overrides default.
  35146. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35147. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35148. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35149. */
  35150. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35151. /**
  35152. * Targets the given meshes with their children and updates zoom level accordingly.
  35153. * @param meshes The mesh to target.
  35154. * @param radius Optional. If a cached radius position already exists, overrides default.
  35155. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35158. */
  35159. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35160. /**
  35161. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35162. * @param minimumWorld Determines the smaller position of the bounding box extend
  35163. * @param maximumWorld Determines the bigger position of the bounding box extend
  35164. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35165. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35166. */
  35167. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35168. /**
  35169. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35170. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35171. * frustum width.
  35172. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35173. * to fully enclose the mesh in the viewing frustum.
  35174. */
  35175. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35176. /**
  35177. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35178. * is automatically returned to its default position (expected to be above ground plane).
  35179. */
  35180. private _maintainCameraAboveGround;
  35181. /**
  35182. * Returns the frustum slope based on the canvas ratio and camera FOV
  35183. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35184. */
  35185. private _getFrustumSlope;
  35186. /**
  35187. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35188. */
  35189. private _clearAnimationLocks;
  35190. /**
  35191. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35192. */
  35193. private _applyUserInteraction;
  35194. /**
  35195. * Stops and removes all animations that have been applied to the camera
  35196. */
  35197. stopAllAnimations(): void;
  35198. /**
  35199. * Gets a value indicating if the user is moving the camera
  35200. */
  35201. readonly isUserIsMoving: boolean;
  35202. /**
  35203. * The camera can move all the way towards the mesh.
  35204. */
  35205. static IgnoreBoundsSizeMode: number;
  35206. /**
  35207. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35208. */
  35209. static FitFrustumSidesMode: number;
  35210. }
  35211. }
  35212. declare module BABYLON {
  35213. /**
  35214. * Base class for Camera Pointer Inputs.
  35215. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35216. * for example usage.
  35217. */
  35218. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35219. /**
  35220. * Defines the camera the input is attached to.
  35221. */
  35222. abstract camera: Camera;
  35223. /**
  35224. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35225. */
  35226. protected _altKey: boolean;
  35227. protected _ctrlKey: boolean;
  35228. protected _metaKey: boolean;
  35229. protected _shiftKey: boolean;
  35230. /**
  35231. * Which mouse buttons were pressed at time of last mouse event.
  35232. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35233. */
  35234. protected _buttonsPressed: number;
  35235. /**
  35236. * Defines the buttons associated with the input to handle camera move.
  35237. */
  35238. buttons: number[];
  35239. /**
  35240. * Attach the input controls to a specific dom element to get the input from.
  35241. * @param element Defines the element the controls should be listened from
  35242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35243. */
  35244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35245. /**
  35246. * Detach the current controls from the specified dom element.
  35247. * @param element Defines the element to stop listening the inputs from
  35248. */
  35249. detachControl(element: Nullable<HTMLElement>): void;
  35250. /**
  35251. * Gets the class name of the current input.
  35252. * @returns the class name
  35253. */
  35254. getClassName(): string;
  35255. /**
  35256. * Get the friendly name associated with the input class.
  35257. * @returns the input friendly name
  35258. */
  35259. getSimpleName(): string;
  35260. /**
  35261. * Called on pointer POINTERDOUBLETAP event.
  35262. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35263. */
  35264. protected onDoubleTap(type: string): void;
  35265. /**
  35266. * Called on pointer POINTERMOVE event if only a single touch is active.
  35267. * Override this method to provide functionality.
  35268. */
  35269. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35270. /**
  35271. * Called on pointer POINTERMOVE event if multiple touches are active.
  35272. * Override this method to provide functionality.
  35273. */
  35274. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35275. /**
  35276. * Called on JS contextmenu event.
  35277. * Override this method to provide functionality.
  35278. */
  35279. protected onContextMenu(evt: PointerEvent): void;
  35280. /**
  35281. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35282. * press.
  35283. * Override this method to provide functionality.
  35284. */
  35285. protected onButtonDown(evt: PointerEvent): void;
  35286. /**
  35287. * Called each time a new POINTERUP event occurs. Ie, for each button
  35288. * release.
  35289. * Override this method to provide functionality.
  35290. */
  35291. protected onButtonUp(evt: PointerEvent): void;
  35292. /**
  35293. * Called when window becomes inactive.
  35294. * Override this method to provide functionality.
  35295. */
  35296. protected onLostFocus(): void;
  35297. private _pointerInput;
  35298. private _observer;
  35299. private _onLostFocus;
  35300. private pointA;
  35301. private pointB;
  35302. }
  35303. }
  35304. declare module BABYLON {
  35305. /**
  35306. * Manage the pointers inputs to control an arc rotate camera.
  35307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35308. */
  35309. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35310. /**
  35311. * Defines the camera the input is attached to.
  35312. */
  35313. camera: ArcRotateCamera;
  35314. /**
  35315. * Gets the class name of the current input.
  35316. * @returns the class name
  35317. */
  35318. getClassName(): string;
  35319. /**
  35320. * Defines the buttons associated with the input to handle camera move.
  35321. */
  35322. buttons: number[];
  35323. /**
  35324. * Defines the pointer angular sensibility along the X axis or how fast is
  35325. * the camera rotating.
  35326. */
  35327. angularSensibilityX: number;
  35328. /**
  35329. * Defines the pointer angular sensibility along the Y axis or how fast is
  35330. * the camera rotating.
  35331. */
  35332. angularSensibilityY: number;
  35333. /**
  35334. * Defines the pointer pinch precision or how fast is the camera zooming.
  35335. */
  35336. pinchPrecision: number;
  35337. /**
  35338. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35339. * from 0.
  35340. * It defines the percentage of current camera.radius to use as delta when
  35341. * pinch zoom is used.
  35342. */
  35343. pinchDeltaPercentage: number;
  35344. /**
  35345. * Defines the pointer panning sensibility or how fast is the camera moving.
  35346. */
  35347. panningSensibility: number;
  35348. /**
  35349. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35350. */
  35351. multiTouchPanning: boolean;
  35352. /**
  35353. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35354. * zoom (pinch) through multitouch.
  35355. */
  35356. multiTouchPanAndZoom: boolean;
  35357. /**
  35358. * Revers pinch action direction.
  35359. */
  35360. pinchInwards: boolean;
  35361. private _isPanClick;
  35362. private _twoFingerActivityCount;
  35363. private _isPinching;
  35364. /**
  35365. * Called on pointer POINTERMOVE event if only a single touch is active.
  35366. */
  35367. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35368. /**
  35369. * Called on pointer POINTERDOUBLETAP event.
  35370. */
  35371. protected onDoubleTap(type: string): void;
  35372. /**
  35373. * Called on pointer POINTERMOVE event if multiple touches are active.
  35374. */
  35375. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35376. /**
  35377. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35378. * press.
  35379. */
  35380. protected onButtonDown(evt: PointerEvent): void;
  35381. /**
  35382. * Called each time a new POINTERUP event occurs. Ie, for each button
  35383. * release.
  35384. */
  35385. protected onButtonUp(evt: PointerEvent): void;
  35386. /**
  35387. * Called when window becomes inactive.
  35388. */
  35389. protected onLostFocus(): void;
  35390. }
  35391. }
  35392. declare module BABYLON {
  35393. /**
  35394. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35396. */
  35397. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35398. /**
  35399. * Defines the camera the input is attached to.
  35400. */
  35401. camera: ArcRotateCamera;
  35402. /**
  35403. * Defines the list of key codes associated with the up action (increase alpha)
  35404. */
  35405. keysUp: number[];
  35406. /**
  35407. * Defines the list of key codes associated with the down action (decrease alpha)
  35408. */
  35409. keysDown: number[];
  35410. /**
  35411. * Defines the list of key codes associated with the left action (increase beta)
  35412. */
  35413. keysLeft: number[];
  35414. /**
  35415. * Defines the list of key codes associated with the right action (decrease beta)
  35416. */
  35417. keysRight: number[];
  35418. /**
  35419. * Defines the list of key codes associated with the reset action.
  35420. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35421. */
  35422. keysReset: number[];
  35423. /**
  35424. * Defines the panning sensibility of the inputs.
  35425. * (How fast is the camera paning)
  35426. */
  35427. panningSensibility: number;
  35428. /**
  35429. * Defines the zooming sensibility of the inputs.
  35430. * (How fast is the camera zooming)
  35431. */
  35432. zoomingSensibility: number;
  35433. /**
  35434. * Defines wether maintaining the alt key down switch the movement mode from
  35435. * orientation to zoom.
  35436. */
  35437. useAltToZoom: boolean;
  35438. /**
  35439. * Rotation speed of the camera
  35440. */
  35441. angularSpeed: number;
  35442. private _keys;
  35443. private _ctrlPressed;
  35444. private _altPressed;
  35445. private _onCanvasBlurObserver;
  35446. private _onKeyboardObserver;
  35447. private _engine;
  35448. private _scene;
  35449. /**
  35450. * Attach the input controls to a specific dom element to get the input from.
  35451. * @param element Defines the element the controls should be listened from
  35452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35453. */
  35454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35455. /**
  35456. * Detach the current controls from the specified dom element.
  35457. * @param element Defines the element to stop listening the inputs from
  35458. */
  35459. detachControl(element: Nullable<HTMLElement>): void;
  35460. /**
  35461. * Update the current camera state depending on the inputs that have been used this frame.
  35462. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35463. */
  35464. checkInputs(): void;
  35465. /**
  35466. * Gets the class name of the current intput.
  35467. * @returns the class name
  35468. */
  35469. getClassName(): string;
  35470. /**
  35471. * Get the friendly name associated with the input class.
  35472. * @returns the input friendly name
  35473. */
  35474. getSimpleName(): string;
  35475. }
  35476. }
  35477. declare module BABYLON {
  35478. /**
  35479. * Manage the mouse wheel inputs to control an arc rotate camera.
  35480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35481. */
  35482. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35483. /**
  35484. * Defines the camera the input is attached to.
  35485. */
  35486. camera: ArcRotateCamera;
  35487. /**
  35488. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35489. */
  35490. wheelPrecision: number;
  35491. /**
  35492. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35493. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35494. */
  35495. wheelDeltaPercentage: number;
  35496. private _wheel;
  35497. private _observer;
  35498. private computeDeltaFromMouseWheelLegacyEvent;
  35499. /**
  35500. * Attach the input controls to a specific dom element to get the input from.
  35501. * @param element Defines the element the controls should be listened from
  35502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35503. */
  35504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35505. /**
  35506. * Detach the current controls from the specified dom element.
  35507. * @param element Defines the element to stop listening the inputs from
  35508. */
  35509. detachControl(element: Nullable<HTMLElement>): void;
  35510. /**
  35511. * Gets the class name of the current intput.
  35512. * @returns the class name
  35513. */
  35514. getClassName(): string;
  35515. /**
  35516. * Get the friendly name associated with the input class.
  35517. * @returns the input friendly name
  35518. */
  35519. getSimpleName(): string;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * Default Inputs manager for the ArcRotateCamera.
  35525. * It groups all the default supported inputs for ease of use.
  35526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35527. */
  35528. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35529. /**
  35530. * Instantiates a new ArcRotateCameraInputsManager.
  35531. * @param camera Defines the camera the inputs belong to
  35532. */
  35533. constructor(camera: ArcRotateCamera);
  35534. /**
  35535. * Add mouse wheel input support to the input manager.
  35536. * @returns the current input manager
  35537. */
  35538. addMouseWheel(): ArcRotateCameraInputsManager;
  35539. /**
  35540. * Add pointers input support to the input manager.
  35541. * @returns the current input manager
  35542. */
  35543. addPointers(): ArcRotateCameraInputsManager;
  35544. /**
  35545. * Add keyboard input support to the input manager.
  35546. * @returns the current input manager
  35547. */
  35548. addKeyboard(): ArcRotateCameraInputsManager;
  35549. }
  35550. }
  35551. declare module BABYLON {
  35552. /**
  35553. * This represents an orbital type of camera.
  35554. *
  35555. * 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.
  35556. * 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.
  35557. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35558. */
  35559. export class ArcRotateCamera extends TargetCamera {
  35560. /**
  35561. * Defines the rotation angle of the camera along the longitudinal axis.
  35562. */
  35563. alpha: number;
  35564. /**
  35565. * Defines the rotation angle of the camera along the latitudinal axis.
  35566. */
  35567. beta: number;
  35568. /**
  35569. * Defines the radius of the camera from it s target point.
  35570. */
  35571. radius: number;
  35572. protected _target: Vector3;
  35573. protected _targetHost: Nullable<AbstractMesh>;
  35574. /**
  35575. * Defines the target point of the camera.
  35576. * The camera looks towards it form the radius distance.
  35577. */
  35578. target: Vector3;
  35579. /**
  35580. * Define the current local position of the camera in the scene
  35581. */
  35582. position: Vector3;
  35583. protected _upVector: Vector3;
  35584. protected _upToYMatrix: Matrix;
  35585. protected _YToUpMatrix: Matrix;
  35586. /**
  35587. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35588. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35589. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35590. */
  35591. upVector: Vector3;
  35592. /**
  35593. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35594. */
  35595. setMatUp(): void;
  35596. /**
  35597. * Current inertia value on the longitudinal axis.
  35598. * The bigger this number the longer it will take for the camera to stop.
  35599. */
  35600. inertialAlphaOffset: number;
  35601. /**
  35602. * Current inertia value on the latitudinal axis.
  35603. * The bigger this number the longer it will take for the camera to stop.
  35604. */
  35605. inertialBetaOffset: number;
  35606. /**
  35607. * Current inertia value on the radius axis.
  35608. * The bigger this number the longer it will take for the camera to stop.
  35609. */
  35610. inertialRadiusOffset: number;
  35611. /**
  35612. * Minimum allowed angle on the longitudinal axis.
  35613. * This can help limiting how the Camera is able to move in the scene.
  35614. */
  35615. lowerAlphaLimit: Nullable<number>;
  35616. /**
  35617. * Maximum allowed angle on the longitudinal axis.
  35618. * This can help limiting how the Camera is able to move in the scene.
  35619. */
  35620. upperAlphaLimit: Nullable<number>;
  35621. /**
  35622. * Minimum allowed angle on the latitudinal axis.
  35623. * This can help limiting how the Camera is able to move in the scene.
  35624. */
  35625. lowerBetaLimit: number;
  35626. /**
  35627. * Maximum allowed angle on the latitudinal axis.
  35628. * This can help limiting how the Camera is able to move in the scene.
  35629. */
  35630. upperBetaLimit: number;
  35631. /**
  35632. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35633. * This can help limiting how the Camera is able to move in the scene.
  35634. */
  35635. lowerRadiusLimit: Nullable<number>;
  35636. /**
  35637. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35638. * This can help limiting how the Camera is able to move in the scene.
  35639. */
  35640. upperRadiusLimit: Nullable<number>;
  35641. /**
  35642. * Defines the current inertia value used during panning of the camera along the X axis.
  35643. */
  35644. inertialPanningX: number;
  35645. /**
  35646. * Defines the current inertia value used during panning of the camera along the Y axis.
  35647. */
  35648. inertialPanningY: number;
  35649. /**
  35650. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35651. * Basically if your fingers moves away from more than this distance you will be considered
  35652. * in pinch mode.
  35653. */
  35654. pinchToPanMaxDistance: number;
  35655. /**
  35656. * Defines the maximum distance the camera can pan.
  35657. * This could help keeping the cammera always in your scene.
  35658. */
  35659. panningDistanceLimit: Nullable<number>;
  35660. /**
  35661. * Defines the target of the camera before paning.
  35662. */
  35663. panningOriginTarget: Vector3;
  35664. /**
  35665. * Defines the value of the inertia used during panning.
  35666. * 0 would mean stop inertia and one would mean no decelleration at all.
  35667. */
  35668. panningInertia: number;
  35669. /**
  35670. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35671. */
  35672. angularSensibilityX: number;
  35673. /**
  35674. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35675. */
  35676. angularSensibilityY: number;
  35677. /**
  35678. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35679. */
  35680. pinchPrecision: number;
  35681. /**
  35682. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35683. * It will be used instead of pinchDeltaPrecision if different from 0.
  35684. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35685. */
  35686. pinchDeltaPercentage: number;
  35687. /**
  35688. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35689. */
  35690. panningSensibility: number;
  35691. /**
  35692. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35693. */
  35694. keysUp: number[];
  35695. /**
  35696. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35697. */
  35698. keysDown: number[];
  35699. /**
  35700. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35701. */
  35702. keysLeft: number[];
  35703. /**
  35704. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35705. */
  35706. keysRight: number[];
  35707. /**
  35708. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35709. */
  35710. wheelPrecision: number;
  35711. /**
  35712. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35713. * It will be used instead of pinchDeltaPrecision if different from 0.
  35714. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35715. */
  35716. wheelDeltaPercentage: number;
  35717. /**
  35718. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35719. */
  35720. zoomOnFactor: number;
  35721. /**
  35722. * Defines a screen offset for the camera position.
  35723. */
  35724. targetScreenOffset: Vector2;
  35725. /**
  35726. * Allows the camera to be completely reversed.
  35727. * If false the camera can not arrive upside down.
  35728. */
  35729. allowUpsideDown: boolean;
  35730. /**
  35731. * Define if double tap/click is used to restore the previously saved state of the camera.
  35732. */
  35733. useInputToRestoreState: boolean;
  35734. /** @hidden */
  35735. _viewMatrix: Matrix;
  35736. /** @hidden */
  35737. _useCtrlForPanning: boolean;
  35738. /** @hidden */
  35739. _panningMouseButton: number;
  35740. /**
  35741. * Defines the input associated to the camera.
  35742. */
  35743. inputs: ArcRotateCameraInputsManager;
  35744. /** @hidden */
  35745. _reset: () => void;
  35746. /**
  35747. * Defines the allowed panning axis.
  35748. */
  35749. panningAxis: Vector3;
  35750. protected _localDirection: Vector3;
  35751. protected _transformedDirection: Vector3;
  35752. private _bouncingBehavior;
  35753. /**
  35754. * Gets the bouncing behavior of the camera if it has been enabled.
  35755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35756. */
  35757. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35758. /**
  35759. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35761. */
  35762. useBouncingBehavior: boolean;
  35763. private _framingBehavior;
  35764. /**
  35765. * Gets the framing behavior of the camera if it has been enabled.
  35766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35767. */
  35768. readonly framingBehavior: Nullable<FramingBehavior>;
  35769. /**
  35770. * Defines if the framing behavior of the camera is enabled on the camera.
  35771. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35772. */
  35773. useFramingBehavior: boolean;
  35774. private _autoRotationBehavior;
  35775. /**
  35776. * Gets the auto rotation behavior of the camera if it has been enabled.
  35777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35778. */
  35779. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35780. /**
  35781. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35782. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35783. */
  35784. useAutoRotationBehavior: boolean;
  35785. /**
  35786. * Observable triggered when the mesh target has been changed on the camera.
  35787. */
  35788. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35789. /**
  35790. * Event raised when the camera is colliding with a mesh.
  35791. */
  35792. onCollide: (collidedMesh: AbstractMesh) => void;
  35793. /**
  35794. * Defines whether the camera should check collision with the objects oh the scene.
  35795. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35796. */
  35797. checkCollisions: boolean;
  35798. /**
  35799. * Defines the collision radius of the camera.
  35800. * This simulates a sphere around the camera.
  35801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35802. */
  35803. collisionRadius: Vector3;
  35804. protected _collider: Collider;
  35805. protected _previousPosition: Vector3;
  35806. protected _collisionVelocity: Vector3;
  35807. protected _newPosition: Vector3;
  35808. protected _previousAlpha: number;
  35809. protected _previousBeta: number;
  35810. protected _previousRadius: number;
  35811. protected _collisionTriggered: boolean;
  35812. protected _targetBoundingCenter: Nullable<Vector3>;
  35813. private _computationVector;
  35814. /**
  35815. * Instantiates a new ArcRotateCamera in a given scene
  35816. * @param name Defines the name of the camera
  35817. * @param alpha Defines the camera rotation along the logitudinal axis
  35818. * @param beta Defines the camera rotation along the latitudinal axis
  35819. * @param radius Defines the camera distance from its target
  35820. * @param target Defines the camera target
  35821. * @param scene Defines the scene the camera belongs to
  35822. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35823. */
  35824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35825. /** @hidden */
  35826. _initCache(): void;
  35827. /** @hidden */
  35828. _updateCache(ignoreParentClass?: boolean): void;
  35829. protected _getTargetPosition(): Vector3;
  35830. private _storedAlpha;
  35831. private _storedBeta;
  35832. private _storedRadius;
  35833. private _storedTarget;
  35834. /**
  35835. * Stores the current state of the camera (alpha, beta, radius and target)
  35836. * @returns the camera itself
  35837. */
  35838. storeState(): Camera;
  35839. /**
  35840. * @hidden
  35841. * Restored camera state. You must call storeState() first
  35842. */
  35843. _restoreStateValues(): boolean;
  35844. /** @hidden */
  35845. _isSynchronizedViewMatrix(): boolean;
  35846. /**
  35847. * Attached controls to the current camera.
  35848. * @param element Defines the element the controls should be listened from
  35849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35850. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35851. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35852. */
  35853. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35854. /**
  35855. * Detach the current controls from the camera.
  35856. * The camera will stop reacting to inputs.
  35857. * @param element Defines the element to stop listening the inputs from
  35858. */
  35859. detachControl(element: HTMLElement): void;
  35860. /** @hidden */
  35861. _checkInputs(): void;
  35862. protected _checkLimits(): void;
  35863. /**
  35864. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35865. */
  35866. rebuildAnglesAndRadius(): void;
  35867. /**
  35868. * Use a position to define the current camera related information like aplha, beta and radius
  35869. * @param position Defines the position to set the camera at
  35870. */
  35871. setPosition(position: Vector3): void;
  35872. /**
  35873. * Defines the target the camera should look at.
  35874. * This will automatically adapt alpha beta and radius to fit within the new target.
  35875. * @param target Defines the new target as a Vector or a mesh
  35876. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35877. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35878. */
  35879. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35880. /** @hidden */
  35881. _getViewMatrix(): Matrix;
  35882. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35883. /**
  35884. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35885. * @param meshes Defines the mesh to zoom on
  35886. * @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)
  35887. */
  35888. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35889. /**
  35890. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35891. * The target will be changed but the radius
  35892. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35893. * @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)
  35894. */
  35895. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35896. min: Vector3;
  35897. max: Vector3;
  35898. distance: number;
  35899. }, doNotUpdateMaxZ?: boolean): void;
  35900. /**
  35901. * @override
  35902. * Override Camera.createRigCamera
  35903. */
  35904. createRigCamera(name: string, cameraIndex: number): Camera;
  35905. /**
  35906. * @hidden
  35907. * @override
  35908. * Override Camera._updateRigCameras
  35909. */
  35910. _updateRigCameras(): void;
  35911. /**
  35912. * Destroy the camera and release the current resources hold by it.
  35913. */
  35914. dispose(): void;
  35915. /**
  35916. * Gets the current object class name.
  35917. * @return the class name
  35918. */
  35919. getClassName(): string;
  35920. }
  35921. }
  35922. declare module BABYLON {
  35923. /**
  35924. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35925. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35926. */
  35927. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35928. /**
  35929. * Gets the name of the behavior.
  35930. */
  35931. readonly name: string;
  35932. private _zoomStopsAnimation;
  35933. private _idleRotationSpeed;
  35934. private _idleRotationWaitTime;
  35935. private _idleRotationSpinupTime;
  35936. /**
  35937. * Sets the flag that indicates if user zooming should stop animation.
  35938. */
  35939. /**
  35940. * Gets the flag that indicates if user zooming should stop animation.
  35941. */
  35942. zoomStopsAnimation: boolean;
  35943. /**
  35944. * Sets the default speed at which the camera rotates around the model.
  35945. */
  35946. /**
  35947. * Gets the default speed at which the camera rotates around the model.
  35948. */
  35949. idleRotationSpeed: number;
  35950. /**
  35951. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35952. */
  35953. /**
  35954. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35955. */
  35956. idleRotationWaitTime: number;
  35957. /**
  35958. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35959. */
  35960. /**
  35961. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35962. */
  35963. idleRotationSpinupTime: number;
  35964. /**
  35965. * Gets a value indicating if the camera is currently rotating because of this behavior
  35966. */
  35967. readonly rotationInProgress: boolean;
  35968. private _onPrePointerObservableObserver;
  35969. private _onAfterCheckInputsObserver;
  35970. private _attachedCamera;
  35971. private _isPointerDown;
  35972. private _lastFrameTime;
  35973. private _lastInteractionTime;
  35974. private _cameraRotationSpeed;
  35975. /**
  35976. * Initializes the behavior.
  35977. */
  35978. init(): void;
  35979. /**
  35980. * Attaches the behavior to its arc rotate camera.
  35981. * @param camera Defines the camera to attach the behavior to
  35982. */
  35983. attach(camera: ArcRotateCamera): void;
  35984. /**
  35985. * Detaches the behavior from its current arc rotate camera.
  35986. */
  35987. detach(): void;
  35988. /**
  35989. * Returns true if user is scrolling.
  35990. * @return true if user is scrolling.
  35991. */
  35992. private _userIsZooming;
  35993. private _lastFrameRadius;
  35994. private _shouldAnimationStopForInteraction;
  35995. /**
  35996. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35997. */
  35998. private _applyUserInteraction;
  35999. private _userIsMoving;
  36000. }
  36001. }
  36002. declare module BABYLON {
  36003. /**
  36004. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36005. */
  36006. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36007. private ui;
  36008. /**
  36009. * The name of the behavior
  36010. */
  36011. name: string;
  36012. /**
  36013. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36014. */
  36015. distanceAwayFromFace: number;
  36016. /**
  36017. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36018. */
  36019. distanceAwayFromBottomOfFace: number;
  36020. private _faceVectors;
  36021. private _target;
  36022. private _scene;
  36023. private _onRenderObserver;
  36024. private _tmpMatrix;
  36025. private _tmpVector;
  36026. /**
  36027. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36028. * @param ui The transform node that should be attched to the mesh
  36029. */
  36030. constructor(ui: TransformNode);
  36031. /**
  36032. * Initializes the behavior
  36033. */
  36034. init(): void;
  36035. private _closestFace;
  36036. private _zeroVector;
  36037. private _lookAtTmpMatrix;
  36038. private _lookAtToRef;
  36039. /**
  36040. * Attaches the AttachToBoxBehavior to the passed in mesh
  36041. * @param target The mesh that the specified node will be attached to
  36042. */
  36043. attach(target: Mesh): void;
  36044. /**
  36045. * Detaches the behavior from the mesh
  36046. */
  36047. detach(): void;
  36048. }
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36053. */
  36054. export class FadeInOutBehavior implements Behavior<Mesh> {
  36055. /**
  36056. * Time in milliseconds to delay before fading in (Default: 0)
  36057. */
  36058. delay: number;
  36059. /**
  36060. * Time in milliseconds for the mesh to fade in (Default: 300)
  36061. */
  36062. fadeInTime: number;
  36063. private _millisecondsPerFrame;
  36064. private _hovered;
  36065. private _hoverValue;
  36066. private _ownerNode;
  36067. /**
  36068. * Instatiates the FadeInOutBehavior
  36069. */
  36070. constructor();
  36071. /**
  36072. * The name of the behavior
  36073. */
  36074. readonly name: string;
  36075. /**
  36076. * Initializes the behavior
  36077. */
  36078. init(): void;
  36079. /**
  36080. * Attaches the fade behavior on the passed in mesh
  36081. * @param ownerNode The mesh that will be faded in/out once attached
  36082. */
  36083. attach(ownerNode: Mesh): void;
  36084. /**
  36085. * Detaches the behavior from the mesh
  36086. */
  36087. detach(): void;
  36088. /**
  36089. * Triggers the mesh to begin fading in or out
  36090. * @param value if the object should fade in or out (true to fade in)
  36091. */
  36092. fadeIn(value: boolean): void;
  36093. private _update;
  36094. private _setAllVisibility;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Class containing a set of static utilities functions for managing Pivots
  36100. * @hidden
  36101. */
  36102. export class PivotTools {
  36103. private static _PivotCached;
  36104. private static _OldPivotPoint;
  36105. private static _PivotTranslation;
  36106. private static _PivotTmpVector;
  36107. /** @hidden */
  36108. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36109. /** @hidden */
  36110. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36111. }
  36112. }
  36113. declare module BABYLON {
  36114. /**
  36115. * Class containing static functions to help procedurally build meshes
  36116. */
  36117. export class PlaneBuilder {
  36118. /**
  36119. * Creates a plane mesh
  36120. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36121. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36122. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36124. * * 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
  36125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36126. * @param name defines the name of the mesh
  36127. * @param options defines the options used to create the mesh
  36128. * @param scene defines the hosting scene
  36129. * @returns the plane mesh
  36130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36131. */
  36132. static CreatePlane(name: string, options: {
  36133. size?: number;
  36134. width?: number;
  36135. height?: number;
  36136. sideOrientation?: number;
  36137. frontUVs?: Vector4;
  36138. backUVs?: Vector4;
  36139. updatable?: boolean;
  36140. sourcePlane?: Plane;
  36141. }, scene?: Nullable<Scene>): Mesh;
  36142. }
  36143. }
  36144. declare module BABYLON {
  36145. /**
  36146. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36147. */
  36148. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36149. private static _AnyMouseID;
  36150. /**
  36151. * Abstract mesh the behavior is set on
  36152. */
  36153. attachedNode: AbstractMesh;
  36154. private _dragPlane;
  36155. private _scene;
  36156. private _pointerObserver;
  36157. private _beforeRenderObserver;
  36158. private static _planeScene;
  36159. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36160. /**
  36161. * 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)
  36162. */
  36163. maxDragAngle: number;
  36164. /**
  36165. * @hidden
  36166. */
  36167. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36168. /**
  36169. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36170. */
  36171. currentDraggingPointerID: number;
  36172. /**
  36173. * The last position where the pointer hit the drag plane in world space
  36174. */
  36175. lastDragPosition: Vector3;
  36176. /**
  36177. * If the behavior is currently in a dragging state
  36178. */
  36179. dragging: boolean;
  36180. /**
  36181. * 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)
  36182. */
  36183. dragDeltaRatio: number;
  36184. /**
  36185. * If the drag plane orientation should be updated during the dragging (Default: true)
  36186. */
  36187. updateDragPlane: boolean;
  36188. private _debugMode;
  36189. private _moving;
  36190. /**
  36191. * Fires each time the attached mesh is dragged with the pointer
  36192. * * delta between last drag position and current drag position in world space
  36193. * * dragDistance along the drag axis
  36194. * * dragPlaneNormal normal of the current drag plane used during the drag
  36195. * * dragPlanePoint in world space where the drag intersects the drag plane
  36196. */
  36197. onDragObservable: Observable<{
  36198. delta: Vector3;
  36199. dragPlanePoint: Vector3;
  36200. dragPlaneNormal: Vector3;
  36201. dragDistance: number;
  36202. pointerId: number;
  36203. }>;
  36204. /**
  36205. * Fires each time a drag begins (eg. mouse down on mesh)
  36206. */
  36207. onDragStartObservable: Observable<{
  36208. dragPlanePoint: Vector3;
  36209. pointerId: number;
  36210. }>;
  36211. /**
  36212. * Fires each time a drag ends (eg. mouse release after drag)
  36213. */
  36214. onDragEndObservable: Observable<{
  36215. dragPlanePoint: Vector3;
  36216. pointerId: number;
  36217. }>;
  36218. /**
  36219. * If the attached mesh should be moved when dragged
  36220. */
  36221. moveAttached: boolean;
  36222. /**
  36223. * If the drag behavior will react to drag events (Default: true)
  36224. */
  36225. enabled: boolean;
  36226. /**
  36227. * If camera controls should be detached during the drag
  36228. */
  36229. detachCameraControls: boolean;
  36230. /**
  36231. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36232. */
  36233. useObjectOrienationForDragging: boolean;
  36234. private _options;
  36235. /**
  36236. * Creates a pointer drag behavior that can be attached to a mesh
  36237. * @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)
  36238. */
  36239. constructor(options?: {
  36240. dragAxis?: Vector3;
  36241. dragPlaneNormal?: Vector3;
  36242. });
  36243. /**
  36244. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36245. */
  36246. validateDrag: (targetPosition: Vector3) => boolean;
  36247. /**
  36248. * The name of the behavior
  36249. */
  36250. readonly name: string;
  36251. /**
  36252. * Initializes the behavior
  36253. */
  36254. init(): void;
  36255. private _tmpVector;
  36256. private _alternatePickedPoint;
  36257. private _worldDragAxis;
  36258. private _targetPosition;
  36259. private _attachedElement;
  36260. /**
  36261. * Attaches the drag behavior the passed in mesh
  36262. * @param ownerNode The mesh that will be dragged around once attached
  36263. */
  36264. attach(ownerNode: AbstractMesh): void;
  36265. /**
  36266. * Force relase the drag action by code.
  36267. */
  36268. releaseDrag(): void;
  36269. private _startDragRay;
  36270. private _lastPointerRay;
  36271. /**
  36272. * Simulates the start of a pointer drag event on the behavior
  36273. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36274. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36275. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36276. */
  36277. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36278. private _startDrag;
  36279. private _dragDelta;
  36280. private _moveDrag;
  36281. private _pickWithRayOnDragPlane;
  36282. private _pointA;
  36283. private _pointB;
  36284. private _pointC;
  36285. private _lineA;
  36286. private _lineB;
  36287. private _localAxis;
  36288. private _lookAt;
  36289. private _updateDragPlanePosition;
  36290. /**
  36291. * Detaches the behavior from the mesh
  36292. */
  36293. detach(): void;
  36294. }
  36295. }
  36296. declare module BABYLON {
  36297. /**
  36298. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36299. */
  36300. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36301. private _dragBehaviorA;
  36302. private _dragBehaviorB;
  36303. private _startDistance;
  36304. private _initialScale;
  36305. private _targetScale;
  36306. private _ownerNode;
  36307. private _sceneRenderObserver;
  36308. /**
  36309. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36310. */
  36311. constructor();
  36312. /**
  36313. * The name of the behavior
  36314. */
  36315. readonly name: string;
  36316. /**
  36317. * Initializes the behavior
  36318. */
  36319. init(): void;
  36320. private _getCurrentDistance;
  36321. /**
  36322. * Attaches the scale behavior the passed in mesh
  36323. * @param ownerNode The mesh that will be scaled around once attached
  36324. */
  36325. attach(ownerNode: Mesh): void;
  36326. /**
  36327. * Detaches the behavior from the mesh
  36328. */
  36329. detach(): void;
  36330. }
  36331. }
  36332. declare module BABYLON {
  36333. /**
  36334. * 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
  36335. */
  36336. export class SixDofDragBehavior implements Behavior<Mesh> {
  36337. private static _virtualScene;
  36338. private _ownerNode;
  36339. private _sceneRenderObserver;
  36340. private _scene;
  36341. private _targetPosition;
  36342. private _virtualOriginMesh;
  36343. private _virtualDragMesh;
  36344. private _pointerObserver;
  36345. private _moving;
  36346. private _startingOrientation;
  36347. /**
  36348. * 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)
  36349. */
  36350. private zDragFactor;
  36351. /**
  36352. * If the object should rotate to face the drag origin
  36353. */
  36354. rotateDraggedObject: boolean;
  36355. /**
  36356. * If the behavior is currently in a dragging state
  36357. */
  36358. dragging: boolean;
  36359. /**
  36360. * 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)
  36361. */
  36362. dragDeltaRatio: number;
  36363. /**
  36364. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36365. */
  36366. currentDraggingPointerID: number;
  36367. /**
  36368. * If camera controls should be detached during the drag
  36369. */
  36370. detachCameraControls: boolean;
  36371. /**
  36372. * Fires each time a drag starts
  36373. */
  36374. onDragStartObservable: Observable<{}>;
  36375. /**
  36376. * Fires each time a drag ends (eg. mouse release after drag)
  36377. */
  36378. onDragEndObservable: Observable<{}>;
  36379. /**
  36380. * 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
  36381. */
  36382. constructor();
  36383. /**
  36384. * The name of the behavior
  36385. */
  36386. readonly name: string;
  36387. /**
  36388. * Initializes the behavior
  36389. */
  36390. init(): void;
  36391. /**
  36392. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36393. */
  36394. private readonly _pointerCamera;
  36395. /**
  36396. * Attaches the scale behavior the passed in mesh
  36397. * @param ownerNode The mesh that will be scaled around once attached
  36398. */
  36399. attach(ownerNode: Mesh): void;
  36400. /**
  36401. * Detaches the behavior from the mesh
  36402. */
  36403. detach(): void;
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. /**
  36408. * Class used to apply inverse kinematics to bones
  36409. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36410. */
  36411. export class BoneIKController {
  36412. private static _tmpVecs;
  36413. private static _tmpQuat;
  36414. private static _tmpMats;
  36415. /**
  36416. * Gets or sets the target mesh
  36417. */
  36418. targetMesh: AbstractMesh;
  36419. /** Gets or sets the mesh used as pole */
  36420. poleTargetMesh: AbstractMesh;
  36421. /**
  36422. * Gets or sets the bone used as pole
  36423. */
  36424. poleTargetBone: Nullable<Bone>;
  36425. /**
  36426. * Gets or sets the target position
  36427. */
  36428. targetPosition: Vector3;
  36429. /**
  36430. * Gets or sets the pole target position
  36431. */
  36432. poleTargetPosition: Vector3;
  36433. /**
  36434. * Gets or sets the pole target local offset
  36435. */
  36436. poleTargetLocalOffset: Vector3;
  36437. /**
  36438. * Gets or sets the pole angle
  36439. */
  36440. poleAngle: number;
  36441. /**
  36442. * Gets or sets the mesh associated with the controller
  36443. */
  36444. mesh: AbstractMesh;
  36445. /**
  36446. * 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)
  36447. */
  36448. slerpAmount: number;
  36449. private _bone1Quat;
  36450. private _bone1Mat;
  36451. private _bone2Ang;
  36452. private _bone1;
  36453. private _bone2;
  36454. private _bone1Length;
  36455. private _bone2Length;
  36456. private _maxAngle;
  36457. private _maxReach;
  36458. private _rightHandedSystem;
  36459. private _bendAxis;
  36460. private _slerping;
  36461. private _adjustRoll;
  36462. /**
  36463. * Gets or sets maximum allowed angle
  36464. */
  36465. maxAngle: number;
  36466. /**
  36467. * Creates a new BoneIKController
  36468. * @param mesh defines the mesh to control
  36469. * @param bone defines the bone to control
  36470. * @param options defines options to set up the controller
  36471. */
  36472. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36473. targetMesh?: AbstractMesh;
  36474. poleTargetMesh?: AbstractMesh;
  36475. poleTargetBone?: Bone;
  36476. poleTargetLocalOffset?: Vector3;
  36477. poleAngle?: number;
  36478. bendAxis?: Vector3;
  36479. maxAngle?: number;
  36480. slerpAmount?: number;
  36481. });
  36482. private _setMaxAngle;
  36483. /**
  36484. * Force the controller to update the bones
  36485. */
  36486. update(): void;
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. /**
  36491. * Class used to make a bone look toward a point in space
  36492. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36493. */
  36494. export class BoneLookController {
  36495. private static _tmpVecs;
  36496. private static _tmpQuat;
  36497. private static _tmpMats;
  36498. /**
  36499. * The target Vector3 that the bone will look at
  36500. */
  36501. target: Vector3;
  36502. /**
  36503. * The mesh that the bone is attached to
  36504. */
  36505. mesh: AbstractMesh;
  36506. /**
  36507. * The bone that will be looking to the target
  36508. */
  36509. bone: Bone;
  36510. /**
  36511. * The up axis of the coordinate system that is used when the bone is rotated
  36512. */
  36513. upAxis: Vector3;
  36514. /**
  36515. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36516. */
  36517. upAxisSpace: Space;
  36518. /**
  36519. * Used to make an adjustment to the yaw of the bone
  36520. */
  36521. adjustYaw: number;
  36522. /**
  36523. * Used to make an adjustment to the pitch of the bone
  36524. */
  36525. adjustPitch: number;
  36526. /**
  36527. * Used to make an adjustment to the roll of the bone
  36528. */
  36529. adjustRoll: number;
  36530. /**
  36531. * 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)
  36532. */
  36533. slerpAmount: number;
  36534. private _minYaw;
  36535. private _maxYaw;
  36536. private _minPitch;
  36537. private _maxPitch;
  36538. private _minYawSin;
  36539. private _minYawCos;
  36540. private _maxYawSin;
  36541. private _maxYawCos;
  36542. private _midYawConstraint;
  36543. private _minPitchTan;
  36544. private _maxPitchTan;
  36545. private _boneQuat;
  36546. private _slerping;
  36547. private _transformYawPitch;
  36548. private _transformYawPitchInv;
  36549. private _firstFrameSkipped;
  36550. private _yawRange;
  36551. private _fowardAxis;
  36552. /**
  36553. * Gets or sets the minimum yaw angle that the bone can look to
  36554. */
  36555. minYaw: number;
  36556. /**
  36557. * Gets or sets the maximum yaw angle that the bone can look to
  36558. */
  36559. maxYaw: number;
  36560. /**
  36561. * Gets or sets the minimum pitch angle that the bone can look to
  36562. */
  36563. minPitch: number;
  36564. /**
  36565. * Gets or sets the maximum pitch angle that the bone can look to
  36566. */
  36567. maxPitch: number;
  36568. /**
  36569. * Create a BoneLookController
  36570. * @param mesh the mesh that the bone belongs to
  36571. * @param bone the bone that will be looking to the target
  36572. * @param target the target Vector3 to look at
  36573. * @param options optional settings:
  36574. * * maxYaw: the maximum angle the bone will yaw to
  36575. * * minYaw: the minimum angle the bone will yaw to
  36576. * * maxPitch: the maximum angle the bone will pitch to
  36577. * * minPitch: the minimum angle the bone will yaw to
  36578. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36579. * * upAxis: the up axis of the coordinate system
  36580. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36581. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36582. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36583. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36584. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36585. * * adjustRoll: used to make an adjustment to the roll of the bone
  36586. **/
  36587. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36588. maxYaw?: number;
  36589. minYaw?: number;
  36590. maxPitch?: number;
  36591. minPitch?: number;
  36592. slerpAmount?: number;
  36593. upAxis?: Vector3;
  36594. upAxisSpace?: Space;
  36595. yawAxis?: Vector3;
  36596. pitchAxis?: Vector3;
  36597. adjustYaw?: number;
  36598. adjustPitch?: number;
  36599. adjustRoll?: number;
  36600. });
  36601. /**
  36602. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36603. */
  36604. update(): void;
  36605. private _getAngleDiff;
  36606. private _getAngleBetween;
  36607. private _isAngleBetween;
  36608. }
  36609. }
  36610. declare module BABYLON {
  36611. /**
  36612. * Manage the gamepad inputs to control an arc rotate camera.
  36613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36614. */
  36615. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36616. /**
  36617. * Defines the camera the input is attached to.
  36618. */
  36619. camera: ArcRotateCamera;
  36620. /**
  36621. * Defines the gamepad the input is gathering event from.
  36622. */
  36623. gamepad: Nullable<Gamepad>;
  36624. /**
  36625. * Defines the gamepad rotation sensiblity.
  36626. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36627. */
  36628. gamepadRotationSensibility: number;
  36629. /**
  36630. * Defines the gamepad move sensiblity.
  36631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36632. */
  36633. gamepadMoveSensibility: number;
  36634. private _onGamepadConnectedObserver;
  36635. private _onGamepadDisconnectedObserver;
  36636. /**
  36637. * Attach the input controls to a specific dom element to get the input from.
  36638. * @param element Defines the element the controls should be listened from
  36639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36640. */
  36641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36642. /**
  36643. * Detach the current controls from the specified dom element.
  36644. * @param element Defines the element to stop listening the inputs from
  36645. */
  36646. detachControl(element: Nullable<HTMLElement>): void;
  36647. /**
  36648. * Update the current camera state depending on the inputs that have been used this frame.
  36649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36650. */
  36651. checkInputs(): void;
  36652. /**
  36653. * Gets the class name of the current intput.
  36654. * @returns the class name
  36655. */
  36656. getClassName(): string;
  36657. /**
  36658. * Get the friendly name associated with the input class.
  36659. * @returns the input friendly name
  36660. */
  36661. getSimpleName(): string;
  36662. }
  36663. }
  36664. declare module BABYLON {
  36665. interface ArcRotateCameraInputsManager {
  36666. /**
  36667. * Add orientation input support to the input manager.
  36668. * @returns the current input manager
  36669. */
  36670. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36671. }
  36672. /**
  36673. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36675. */
  36676. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36677. /**
  36678. * Defines the camera the input is attached to.
  36679. */
  36680. camera: ArcRotateCamera;
  36681. /**
  36682. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36683. */
  36684. alphaCorrection: number;
  36685. /**
  36686. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36687. */
  36688. gammaCorrection: number;
  36689. private _alpha;
  36690. private _gamma;
  36691. private _dirty;
  36692. private _deviceOrientationHandler;
  36693. /**
  36694. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36695. */
  36696. constructor();
  36697. /**
  36698. * Attach the input controls to a specific dom element to get the input from.
  36699. * @param element Defines the element the controls should be listened from
  36700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36701. */
  36702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36703. /** @hidden */
  36704. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36705. /**
  36706. * Update the current camera state depending on the inputs that have been used this frame.
  36707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36708. */
  36709. checkInputs(): void;
  36710. /**
  36711. * Detach the current controls from the specified dom element.
  36712. * @param element Defines the element to stop listening the inputs from
  36713. */
  36714. detachControl(element: Nullable<HTMLElement>): void;
  36715. /**
  36716. * Gets the class name of the current intput.
  36717. * @returns the class name
  36718. */
  36719. getClassName(): string;
  36720. /**
  36721. * Get the friendly name associated with the input class.
  36722. * @returns the input friendly name
  36723. */
  36724. getSimpleName(): string;
  36725. }
  36726. }
  36727. declare module BABYLON {
  36728. /**
  36729. * Listen to mouse events to control the camera.
  36730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36731. */
  36732. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36733. /**
  36734. * Defines the camera the input is attached to.
  36735. */
  36736. camera: FlyCamera;
  36737. /**
  36738. * Defines if touch is enabled. (Default is true.)
  36739. */
  36740. touchEnabled: boolean;
  36741. /**
  36742. * Defines the buttons associated with the input to handle camera rotation.
  36743. */
  36744. buttons: number[];
  36745. /**
  36746. * Assign buttons for Yaw control.
  36747. */
  36748. buttonsYaw: number[];
  36749. /**
  36750. * Assign buttons for Pitch control.
  36751. */
  36752. buttonsPitch: number[];
  36753. /**
  36754. * Assign buttons for Roll control.
  36755. */
  36756. buttonsRoll: number[];
  36757. /**
  36758. * Detect if any button is being pressed while mouse is moved.
  36759. * -1 = Mouse locked.
  36760. * 0 = Left button.
  36761. * 1 = Middle Button.
  36762. * 2 = Right Button.
  36763. */
  36764. activeButton: number;
  36765. /**
  36766. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36767. * Higher values reduce its sensitivity.
  36768. */
  36769. angularSensibility: number;
  36770. private _mousemoveCallback;
  36771. private _observer;
  36772. private _rollObserver;
  36773. private previousPosition;
  36774. private noPreventDefault;
  36775. private element;
  36776. /**
  36777. * Listen to mouse events to control the camera.
  36778. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36780. */
  36781. constructor(touchEnabled?: boolean);
  36782. /**
  36783. * Attach the mouse control to the HTML DOM element.
  36784. * @param element Defines the element that listens to the input events.
  36785. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36786. */
  36787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36788. /**
  36789. * Detach the current controls from the specified dom element.
  36790. * @param element Defines the element to stop listening the inputs from
  36791. */
  36792. detachControl(element: Nullable<HTMLElement>): void;
  36793. /**
  36794. * Gets the class name of the current input.
  36795. * @returns the class name.
  36796. */
  36797. getClassName(): string;
  36798. /**
  36799. * Get the friendly name associated with the input class.
  36800. * @returns the input's friendly name.
  36801. */
  36802. getSimpleName(): string;
  36803. private _pointerInput;
  36804. private _onMouseMove;
  36805. /**
  36806. * Rotate camera by mouse offset.
  36807. */
  36808. private rotateCamera;
  36809. }
  36810. }
  36811. declare module BABYLON {
  36812. /**
  36813. * Default Inputs manager for the FlyCamera.
  36814. * It groups all the default supported inputs for ease of use.
  36815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36816. */
  36817. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36818. /**
  36819. * Instantiates a new FlyCameraInputsManager.
  36820. * @param camera Defines the camera the inputs belong to.
  36821. */
  36822. constructor(camera: FlyCamera);
  36823. /**
  36824. * Add keyboard input support to the input manager.
  36825. * @returns the new FlyCameraKeyboardMoveInput().
  36826. */
  36827. addKeyboard(): FlyCameraInputsManager;
  36828. /**
  36829. * Add mouse input support to the input manager.
  36830. * @param touchEnabled Enable touch screen support.
  36831. * @returns the new FlyCameraMouseInput().
  36832. */
  36833. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36834. }
  36835. }
  36836. declare module BABYLON {
  36837. /**
  36838. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36839. * such as in a 3D Space Shooter or a Flight Simulator.
  36840. */
  36841. export class FlyCamera extends TargetCamera {
  36842. /**
  36843. * Define the collision ellipsoid of the camera.
  36844. * This is helpful for simulating a camera body, like a player's body.
  36845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36846. */
  36847. ellipsoid: Vector3;
  36848. /**
  36849. * Define an offset for the position of the ellipsoid around the camera.
  36850. * This can be helpful if the camera is attached away from the player's body center,
  36851. * such as at its head.
  36852. */
  36853. ellipsoidOffset: Vector3;
  36854. /**
  36855. * Enable or disable collisions of the camera with the rest of the scene objects.
  36856. */
  36857. checkCollisions: boolean;
  36858. /**
  36859. * Enable or disable gravity on the camera.
  36860. */
  36861. applyGravity: boolean;
  36862. /**
  36863. * Define the current direction the camera is moving to.
  36864. */
  36865. cameraDirection: Vector3;
  36866. /**
  36867. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36868. * This overrides and empties cameraRotation.
  36869. */
  36870. rotationQuaternion: Quaternion;
  36871. /**
  36872. * Track Roll to maintain the wanted Rolling when looking around.
  36873. */
  36874. _trackRoll: number;
  36875. /**
  36876. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36877. */
  36878. rollCorrect: number;
  36879. /**
  36880. * Mimic a banked turn, Rolling the camera when Yawing.
  36881. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36882. */
  36883. bankedTurn: boolean;
  36884. /**
  36885. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36886. */
  36887. bankedTurnLimit: number;
  36888. /**
  36889. * Value of 0 disables the banked Roll.
  36890. * Value of 1 is equal to the Yaw angle in radians.
  36891. */
  36892. bankedTurnMultiplier: number;
  36893. /**
  36894. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36895. */
  36896. inputs: FlyCameraInputsManager;
  36897. /**
  36898. * Gets the input sensibility for mouse input.
  36899. * Higher values reduce sensitivity.
  36900. */
  36901. /**
  36902. * Sets the input sensibility for a mouse input.
  36903. * Higher values reduce sensitivity.
  36904. */
  36905. angularSensibility: number;
  36906. /**
  36907. * Get the keys for camera movement forward.
  36908. */
  36909. /**
  36910. * Set the keys for camera movement forward.
  36911. */
  36912. keysForward: number[];
  36913. /**
  36914. * Get the keys for camera movement backward.
  36915. */
  36916. keysBackward: number[];
  36917. /**
  36918. * Get the keys for camera movement up.
  36919. */
  36920. /**
  36921. * Set the keys for camera movement up.
  36922. */
  36923. keysUp: number[];
  36924. /**
  36925. * Get the keys for camera movement down.
  36926. */
  36927. /**
  36928. * Set the keys for camera movement down.
  36929. */
  36930. keysDown: number[];
  36931. /**
  36932. * Get the keys for camera movement left.
  36933. */
  36934. /**
  36935. * Set the keys for camera movement left.
  36936. */
  36937. keysLeft: number[];
  36938. /**
  36939. * Set the keys for camera movement right.
  36940. */
  36941. /**
  36942. * Set the keys for camera movement right.
  36943. */
  36944. keysRight: number[];
  36945. /**
  36946. * Event raised when the camera collides with a mesh in the scene.
  36947. */
  36948. onCollide: (collidedMesh: AbstractMesh) => void;
  36949. private _collider;
  36950. private _needMoveForGravity;
  36951. private _oldPosition;
  36952. private _diffPosition;
  36953. private _newPosition;
  36954. /** @hidden */
  36955. _localDirection: Vector3;
  36956. /** @hidden */
  36957. _transformedDirection: Vector3;
  36958. /**
  36959. * Instantiates a FlyCamera.
  36960. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36961. * such as in a 3D Space Shooter or a Flight Simulator.
  36962. * @param name Define the name of the camera in the scene.
  36963. * @param position Define the starting position of the camera in the scene.
  36964. * @param scene Define the scene the camera belongs to.
  36965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36966. */
  36967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36968. /**
  36969. * Attach a control to the HTML DOM element.
  36970. * @param element Defines the element that listens to the input events.
  36971. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36972. */
  36973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36974. /**
  36975. * Detach a control from the HTML DOM element.
  36976. * The camera will stop reacting to that input.
  36977. * @param element Defines the element that listens to the input events.
  36978. */
  36979. detachControl(element: HTMLElement): void;
  36980. private _collisionMask;
  36981. /**
  36982. * Get the mask that the camera ignores in collision events.
  36983. */
  36984. /**
  36985. * Set the mask that the camera ignores in collision events.
  36986. */
  36987. collisionMask: number;
  36988. /** @hidden */
  36989. _collideWithWorld(displacement: Vector3): void;
  36990. /** @hidden */
  36991. private _onCollisionPositionChange;
  36992. /** @hidden */
  36993. _checkInputs(): void;
  36994. /** @hidden */
  36995. _decideIfNeedsToMove(): boolean;
  36996. /** @hidden */
  36997. _updatePosition(): void;
  36998. /**
  36999. * Restore the Roll to its target value at the rate specified.
  37000. * @param rate - Higher means slower restoring.
  37001. * @hidden
  37002. */
  37003. restoreRoll(rate: number): void;
  37004. /**
  37005. * Destroy the camera and release the current resources held by it.
  37006. */
  37007. dispose(): void;
  37008. /**
  37009. * Get the current object class name.
  37010. * @returns the class name.
  37011. */
  37012. getClassName(): string;
  37013. }
  37014. }
  37015. declare module BABYLON {
  37016. /**
  37017. * Listen to keyboard events to control the camera.
  37018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37019. */
  37020. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37021. /**
  37022. * Defines the camera the input is attached to.
  37023. */
  37024. camera: FlyCamera;
  37025. /**
  37026. * The list of keyboard keys used to control the forward move of the camera.
  37027. */
  37028. keysForward: number[];
  37029. /**
  37030. * The list of keyboard keys used to control the backward move of the camera.
  37031. */
  37032. keysBackward: number[];
  37033. /**
  37034. * The list of keyboard keys used to control the forward move of the camera.
  37035. */
  37036. keysUp: number[];
  37037. /**
  37038. * The list of keyboard keys used to control the backward move of the camera.
  37039. */
  37040. keysDown: number[];
  37041. /**
  37042. * The list of keyboard keys used to control the right strafe move of the camera.
  37043. */
  37044. keysRight: number[];
  37045. /**
  37046. * The list of keyboard keys used to control the left strafe move of the camera.
  37047. */
  37048. keysLeft: number[];
  37049. private _keys;
  37050. private _onCanvasBlurObserver;
  37051. private _onKeyboardObserver;
  37052. private _engine;
  37053. private _scene;
  37054. /**
  37055. * Attach the input controls to a specific dom element to get the input from.
  37056. * @param element Defines the element the controls should be listened from
  37057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37058. */
  37059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37060. /**
  37061. * Detach the current controls from the specified dom element.
  37062. * @param element Defines the element to stop listening the inputs from
  37063. */
  37064. detachControl(element: Nullable<HTMLElement>): void;
  37065. /**
  37066. * Gets the class name of the current intput.
  37067. * @returns the class name
  37068. */
  37069. getClassName(): string;
  37070. /** @hidden */
  37071. _onLostFocus(e: FocusEvent): void;
  37072. /**
  37073. * Get the friendly name associated with the input class.
  37074. * @returns the input friendly name
  37075. */
  37076. getSimpleName(): string;
  37077. /**
  37078. * Update the current camera state depending on the inputs that have been used this frame.
  37079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37080. */
  37081. checkInputs(): void;
  37082. }
  37083. }
  37084. declare module BABYLON {
  37085. /**
  37086. * Manage the mouse wheel inputs to control a follow camera.
  37087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37088. */
  37089. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37090. /**
  37091. * Defines the camera the input is attached to.
  37092. */
  37093. camera: FollowCamera;
  37094. /**
  37095. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37096. */
  37097. axisControlRadius: boolean;
  37098. /**
  37099. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37100. */
  37101. axisControlHeight: boolean;
  37102. /**
  37103. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37104. */
  37105. axisControlRotation: boolean;
  37106. /**
  37107. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37108. * relation to mouseWheel events.
  37109. */
  37110. wheelPrecision: number;
  37111. /**
  37112. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37113. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37114. */
  37115. wheelDeltaPercentage: number;
  37116. private _wheel;
  37117. private _observer;
  37118. /**
  37119. * Attach the input controls to a specific dom element to get the input from.
  37120. * @param element Defines the element the controls should be listened from
  37121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37122. */
  37123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37124. /**
  37125. * Detach the current controls from the specified dom element.
  37126. * @param element Defines the element to stop listening the inputs from
  37127. */
  37128. detachControl(element: Nullable<HTMLElement>): void;
  37129. /**
  37130. * Gets the class name of the current intput.
  37131. * @returns the class name
  37132. */
  37133. getClassName(): string;
  37134. /**
  37135. * Get the friendly name associated with the input class.
  37136. * @returns the input friendly name
  37137. */
  37138. getSimpleName(): string;
  37139. }
  37140. }
  37141. declare module BABYLON {
  37142. /**
  37143. * Manage the pointers inputs to control an follow camera.
  37144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37145. */
  37146. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37147. /**
  37148. * Defines the camera the input is attached to.
  37149. */
  37150. camera: FollowCamera;
  37151. /**
  37152. * Gets the class name of the current input.
  37153. * @returns the class name
  37154. */
  37155. getClassName(): string;
  37156. /**
  37157. * Defines the pointer angular sensibility along the X axis or how fast is
  37158. * the camera rotating.
  37159. * A negative number will reverse the axis direction.
  37160. */
  37161. angularSensibilityX: number;
  37162. /**
  37163. * Defines the pointer angular sensibility along the Y axis or how fast is
  37164. * the camera rotating.
  37165. * A negative number will reverse the axis direction.
  37166. */
  37167. angularSensibilityY: number;
  37168. /**
  37169. * Defines the pointer pinch precision or how fast is the camera zooming.
  37170. * A negative number will reverse the axis direction.
  37171. */
  37172. pinchPrecision: number;
  37173. /**
  37174. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37175. * from 0.
  37176. * It defines the percentage of current camera.radius to use as delta when
  37177. * pinch zoom is used.
  37178. */
  37179. pinchDeltaPercentage: number;
  37180. /**
  37181. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37182. */
  37183. axisXControlRadius: boolean;
  37184. /**
  37185. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37186. */
  37187. axisXControlHeight: boolean;
  37188. /**
  37189. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37190. */
  37191. axisXControlRotation: boolean;
  37192. /**
  37193. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37194. */
  37195. axisYControlRadius: boolean;
  37196. /**
  37197. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37198. */
  37199. axisYControlHeight: boolean;
  37200. /**
  37201. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37202. */
  37203. axisYControlRotation: boolean;
  37204. /**
  37205. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37206. */
  37207. axisPinchControlRadius: boolean;
  37208. /**
  37209. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37210. */
  37211. axisPinchControlHeight: boolean;
  37212. /**
  37213. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37214. */
  37215. axisPinchControlRotation: boolean;
  37216. /**
  37217. * Log error messages if basic misconfiguration has occurred.
  37218. */
  37219. warningEnable: boolean;
  37220. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37221. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37222. private _warningCounter;
  37223. private _warning;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. /**
  37228. * Default Inputs manager for the FollowCamera.
  37229. * It groups all the default supported inputs for ease of use.
  37230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37231. */
  37232. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37233. /**
  37234. * Instantiates a new FollowCameraInputsManager.
  37235. * @param camera Defines the camera the inputs belong to
  37236. */
  37237. constructor(camera: FollowCamera);
  37238. /**
  37239. * Add keyboard input support to the input manager.
  37240. * @returns the current input manager
  37241. */
  37242. addKeyboard(): FollowCameraInputsManager;
  37243. /**
  37244. * Add mouse wheel input support to the input manager.
  37245. * @returns the current input manager
  37246. */
  37247. addMouseWheel(): FollowCameraInputsManager;
  37248. /**
  37249. * Add pointers input support to the input manager.
  37250. * @returns the current input manager
  37251. */
  37252. addPointers(): FollowCameraInputsManager;
  37253. /**
  37254. * Add orientation input support to the input manager.
  37255. * @returns the current input manager
  37256. */
  37257. addVRDeviceOrientation(): FollowCameraInputsManager;
  37258. }
  37259. }
  37260. declare module BABYLON {
  37261. /**
  37262. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37263. * an arc rotate version arcFollowCamera are available.
  37264. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37265. */
  37266. export class FollowCamera extends TargetCamera {
  37267. /**
  37268. * Distance the follow camera should follow an object at
  37269. */
  37270. radius: number;
  37271. /**
  37272. * Minimum allowed distance of the camera to the axis of rotation
  37273. * (The camera can not get closer).
  37274. * This can help limiting how the Camera is able to move in the scene.
  37275. */
  37276. lowerRadiusLimit: Nullable<number>;
  37277. /**
  37278. * Maximum allowed distance of the camera to the axis of rotation
  37279. * (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Define a rotation offset between the camera and the object it follows
  37285. */
  37286. rotationOffset: number;
  37287. /**
  37288. * Minimum allowed angle to camera position relative to target object.
  37289. * This can help limiting how the Camera is able to move in the scene.
  37290. */
  37291. lowerRotationOffsetLimit: Nullable<number>;
  37292. /**
  37293. * Maximum allowed angle to camera position relative to target object.
  37294. * This can help limiting how the Camera is able to move in the scene.
  37295. */
  37296. upperRotationOffsetLimit: Nullable<number>;
  37297. /**
  37298. * Define a height offset between the camera and the object it follows.
  37299. * It can help following an object from the top (like a car chaing a plane)
  37300. */
  37301. heightOffset: number;
  37302. /**
  37303. * Minimum allowed height of camera position relative to target object.
  37304. * This can help limiting how the Camera is able to move in the scene.
  37305. */
  37306. lowerHeightOffsetLimit: Nullable<number>;
  37307. /**
  37308. * Maximum allowed height of camera position relative to target object.
  37309. * This can help limiting how the Camera is able to move in the scene.
  37310. */
  37311. upperHeightOffsetLimit: Nullable<number>;
  37312. /**
  37313. * Define how fast the camera can accelerate to follow it s target.
  37314. */
  37315. cameraAcceleration: number;
  37316. /**
  37317. * Define the speed limit of the camera following an object.
  37318. */
  37319. maxCameraSpeed: number;
  37320. /**
  37321. * Define the target of the camera.
  37322. */
  37323. lockedTarget: Nullable<AbstractMesh>;
  37324. /**
  37325. * Defines the input associated with the camera.
  37326. */
  37327. inputs: FollowCameraInputsManager;
  37328. /**
  37329. * Instantiates the follow camera.
  37330. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37331. * @param name Define the name of the camera in the scene
  37332. * @param position Define the position of the camera
  37333. * @param scene Define the scene the camera belong to
  37334. * @param lockedTarget Define the target of the camera
  37335. */
  37336. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37337. private _follow;
  37338. /**
  37339. * Attached controls to the current camera.
  37340. * @param element Defines the element the controls should be listened from
  37341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37342. */
  37343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37344. /**
  37345. * Detach the current controls from the camera.
  37346. * The camera will stop reacting to inputs.
  37347. * @param element Defines the element to stop listening the inputs from
  37348. */
  37349. detachControl(element: HTMLElement): void;
  37350. /** @hidden */
  37351. _checkInputs(): void;
  37352. private _checkLimits;
  37353. /**
  37354. * Gets the camera class name.
  37355. * @returns the class name
  37356. */
  37357. getClassName(): string;
  37358. }
  37359. /**
  37360. * Arc Rotate version of the follow camera.
  37361. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37362. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37363. */
  37364. export class ArcFollowCamera extends TargetCamera {
  37365. /** The longitudinal angle of the camera */
  37366. alpha: number;
  37367. /** The latitudinal angle of the camera */
  37368. beta: number;
  37369. /** The radius of the camera from its target */
  37370. radius: number;
  37371. /** Define the camera target (the messh it should follow) */
  37372. target: Nullable<AbstractMesh>;
  37373. private _cartesianCoordinates;
  37374. /**
  37375. * Instantiates a new ArcFollowCamera
  37376. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37377. * @param name Define the name of the camera
  37378. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37379. * @param beta Define the rotation angle of the camera around the elevation axis
  37380. * @param radius Define the radius of the camera from its target point
  37381. * @param target Define the target of the camera
  37382. * @param scene Define the scene the camera belongs to
  37383. */
  37384. constructor(name: string,
  37385. /** The longitudinal angle of the camera */
  37386. alpha: number,
  37387. /** The latitudinal angle of the camera */
  37388. beta: number,
  37389. /** The radius of the camera from its target */
  37390. radius: number,
  37391. /** Define the camera target (the messh it should follow) */
  37392. target: Nullable<AbstractMesh>, scene: Scene);
  37393. private _follow;
  37394. /** @hidden */
  37395. _checkInputs(): void;
  37396. /**
  37397. * Returns the class name of the object.
  37398. * It is mostly used internally for serialization purposes.
  37399. */
  37400. getClassName(): string;
  37401. }
  37402. }
  37403. declare module BABYLON {
  37404. /**
  37405. * Manage the keyboard inputs to control the movement of a follow camera.
  37406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37407. */
  37408. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37409. /**
  37410. * Defines the camera the input is attached to.
  37411. */
  37412. camera: FollowCamera;
  37413. /**
  37414. * Defines the list of key codes associated with the up action (increase heightOffset)
  37415. */
  37416. keysHeightOffsetIncr: number[];
  37417. /**
  37418. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37419. */
  37420. keysHeightOffsetDecr: number[];
  37421. /**
  37422. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37423. */
  37424. keysHeightOffsetModifierAlt: boolean;
  37425. /**
  37426. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37427. */
  37428. keysHeightOffsetModifierCtrl: boolean;
  37429. /**
  37430. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37431. */
  37432. keysHeightOffsetModifierShift: boolean;
  37433. /**
  37434. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37435. */
  37436. keysRotationOffsetIncr: number[];
  37437. /**
  37438. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37439. */
  37440. keysRotationOffsetDecr: number[];
  37441. /**
  37442. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37443. */
  37444. keysRotationOffsetModifierAlt: boolean;
  37445. /**
  37446. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37447. */
  37448. keysRotationOffsetModifierCtrl: boolean;
  37449. /**
  37450. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37451. */
  37452. keysRotationOffsetModifierShift: boolean;
  37453. /**
  37454. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37455. */
  37456. keysRadiusIncr: number[];
  37457. /**
  37458. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37459. */
  37460. keysRadiusDecr: number[];
  37461. /**
  37462. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37463. */
  37464. keysRadiusModifierAlt: boolean;
  37465. /**
  37466. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37467. */
  37468. keysRadiusModifierCtrl: boolean;
  37469. /**
  37470. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37471. */
  37472. keysRadiusModifierShift: boolean;
  37473. /**
  37474. * Defines the rate of change of heightOffset.
  37475. */
  37476. heightSensibility: number;
  37477. /**
  37478. * Defines the rate of change of rotationOffset.
  37479. */
  37480. rotationSensibility: number;
  37481. /**
  37482. * Defines the rate of change of radius.
  37483. */
  37484. radiusSensibility: number;
  37485. private _keys;
  37486. private _ctrlPressed;
  37487. private _altPressed;
  37488. private _shiftPressed;
  37489. private _onCanvasBlurObserver;
  37490. private _onKeyboardObserver;
  37491. private _engine;
  37492. private _scene;
  37493. /**
  37494. * Attach the input controls to a specific dom element to get the input from.
  37495. * @param element Defines the element the controls should be listened from
  37496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37497. */
  37498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37499. /**
  37500. * Detach the current controls from the specified dom element.
  37501. * @param element Defines the element to stop listening the inputs from
  37502. */
  37503. detachControl(element: Nullable<HTMLElement>): void;
  37504. /**
  37505. * Update the current camera state depending on the inputs that have been used this frame.
  37506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37507. */
  37508. checkInputs(): void;
  37509. /**
  37510. * Gets the class name of the current input.
  37511. * @returns the class name
  37512. */
  37513. getClassName(): string;
  37514. /**
  37515. * Get the friendly name associated with the input class.
  37516. * @returns the input friendly name
  37517. */
  37518. getSimpleName(): string;
  37519. /**
  37520. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37521. * allow modification of the heightOffset value.
  37522. */
  37523. private _modifierHeightOffset;
  37524. /**
  37525. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37526. * allow modification of the rotationOffset value.
  37527. */
  37528. private _modifierRotationOffset;
  37529. /**
  37530. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37531. * allow modification of the radius value.
  37532. */
  37533. private _modifierRadius;
  37534. }
  37535. }
  37536. declare module BABYLON {
  37537. interface FreeCameraInputsManager {
  37538. /**
  37539. * @hidden
  37540. */
  37541. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37542. /**
  37543. * Add orientation input support to the input manager.
  37544. * @returns the current input manager
  37545. */
  37546. addDeviceOrientation(): FreeCameraInputsManager;
  37547. }
  37548. /**
  37549. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37550. * Screen rotation is taken into account.
  37551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37552. */
  37553. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37554. private _camera;
  37555. private _screenOrientationAngle;
  37556. private _constantTranform;
  37557. private _screenQuaternion;
  37558. private _alpha;
  37559. private _beta;
  37560. private _gamma;
  37561. /**
  37562. * Can be used to detect if a device orientation sensor is availible on a device
  37563. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37564. * @returns a promise that will resolve on orientation change
  37565. */
  37566. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37567. /**
  37568. * @hidden
  37569. */
  37570. _onDeviceOrientationChangedObservable: Observable<void>;
  37571. /**
  37572. * Instantiates a new input
  37573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37574. */
  37575. constructor();
  37576. /**
  37577. * Define the camera controlled by the input.
  37578. */
  37579. camera: FreeCamera;
  37580. /**
  37581. * Attach the input controls to a specific dom element to get the input from.
  37582. * @param element Defines the element the controls should be listened from
  37583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37584. */
  37585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37586. private _orientationChanged;
  37587. private _deviceOrientation;
  37588. /**
  37589. * Detach the current controls from the specified dom element.
  37590. * @param element Defines the element to stop listening the inputs from
  37591. */
  37592. detachControl(element: Nullable<HTMLElement>): void;
  37593. /**
  37594. * Update the current camera state depending on the inputs that have been used this frame.
  37595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37596. */
  37597. checkInputs(): void;
  37598. /**
  37599. * Gets the class name of the current intput.
  37600. * @returns the class name
  37601. */
  37602. getClassName(): string;
  37603. /**
  37604. * Get the friendly name associated with the input class.
  37605. * @returns the input friendly name
  37606. */
  37607. getSimpleName(): string;
  37608. }
  37609. }
  37610. declare module BABYLON {
  37611. /**
  37612. * Manage the gamepad inputs to control a free camera.
  37613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37614. */
  37615. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37616. /**
  37617. * Define the camera the input is attached to.
  37618. */
  37619. camera: FreeCamera;
  37620. /**
  37621. * Define the Gamepad controlling the input
  37622. */
  37623. gamepad: Nullable<Gamepad>;
  37624. /**
  37625. * Defines the gamepad rotation sensiblity.
  37626. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37627. */
  37628. gamepadAngularSensibility: number;
  37629. /**
  37630. * Defines the gamepad move sensiblity.
  37631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37632. */
  37633. gamepadMoveSensibility: number;
  37634. private _onGamepadConnectedObserver;
  37635. private _onGamepadDisconnectedObserver;
  37636. private _cameraTransform;
  37637. private _deltaTransform;
  37638. private _vector3;
  37639. private _vector2;
  37640. /**
  37641. * Attach the input controls to a specific dom element to get the input from.
  37642. * @param element Defines the element the controls should be listened from
  37643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37644. */
  37645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37646. /**
  37647. * Detach the current controls from the specified dom element.
  37648. * @param element Defines the element to stop listening the inputs from
  37649. */
  37650. detachControl(element: Nullable<HTMLElement>): void;
  37651. /**
  37652. * Update the current camera state depending on the inputs that have been used this frame.
  37653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37654. */
  37655. checkInputs(): void;
  37656. /**
  37657. * Gets the class name of the current intput.
  37658. * @returns the class name
  37659. */
  37660. getClassName(): string;
  37661. /**
  37662. * Get the friendly name associated with the input class.
  37663. * @returns the input friendly name
  37664. */
  37665. getSimpleName(): string;
  37666. }
  37667. }
  37668. declare module BABYLON {
  37669. /**
  37670. * Defines the potential axis of a Joystick
  37671. */
  37672. export enum JoystickAxis {
  37673. /** X axis */
  37674. X = 0,
  37675. /** Y axis */
  37676. Y = 1,
  37677. /** Z axis */
  37678. Z = 2
  37679. }
  37680. /**
  37681. * Class used to define virtual joystick (used in touch mode)
  37682. */
  37683. export class VirtualJoystick {
  37684. /**
  37685. * Gets or sets a boolean indicating that left and right values must be inverted
  37686. */
  37687. reverseLeftRight: boolean;
  37688. /**
  37689. * Gets or sets a boolean indicating that up and down values must be inverted
  37690. */
  37691. reverseUpDown: boolean;
  37692. /**
  37693. * Gets the offset value for the position (ie. the change of the position value)
  37694. */
  37695. deltaPosition: Vector3;
  37696. /**
  37697. * Gets a boolean indicating if the virtual joystick was pressed
  37698. */
  37699. pressed: boolean;
  37700. /**
  37701. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37702. */
  37703. static Canvas: Nullable<HTMLCanvasElement>;
  37704. private static _globalJoystickIndex;
  37705. private static vjCanvasContext;
  37706. private static vjCanvasWidth;
  37707. private static vjCanvasHeight;
  37708. private static halfWidth;
  37709. private _action;
  37710. private _axisTargetedByLeftAndRight;
  37711. private _axisTargetedByUpAndDown;
  37712. private _joystickSensibility;
  37713. private _inversedSensibility;
  37714. private _joystickPointerID;
  37715. private _joystickColor;
  37716. private _joystickPointerPos;
  37717. private _joystickPreviousPointerPos;
  37718. private _joystickPointerStartPos;
  37719. private _deltaJoystickVector;
  37720. private _leftJoystick;
  37721. private _touches;
  37722. private _onPointerDownHandlerRef;
  37723. private _onPointerMoveHandlerRef;
  37724. private _onPointerUpHandlerRef;
  37725. private _onResize;
  37726. /**
  37727. * Creates a new virtual joystick
  37728. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37729. */
  37730. constructor(leftJoystick?: boolean);
  37731. /**
  37732. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37733. * @param newJoystickSensibility defines the new sensibility
  37734. */
  37735. setJoystickSensibility(newJoystickSensibility: number): void;
  37736. private _onPointerDown;
  37737. private _onPointerMove;
  37738. private _onPointerUp;
  37739. /**
  37740. * Change the color of the virtual joystick
  37741. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37742. */
  37743. setJoystickColor(newColor: string): void;
  37744. /**
  37745. * Defines a callback to call when the joystick is touched
  37746. * @param action defines the callback
  37747. */
  37748. setActionOnTouch(action: () => any): void;
  37749. /**
  37750. * Defines which axis you'd like to control for left & right
  37751. * @param axis defines the axis to use
  37752. */
  37753. setAxisForLeftRight(axis: JoystickAxis): void;
  37754. /**
  37755. * Defines which axis you'd like to control for up & down
  37756. * @param axis defines the axis to use
  37757. */
  37758. setAxisForUpDown(axis: JoystickAxis): void;
  37759. private _drawVirtualJoystick;
  37760. /**
  37761. * Release internal HTML canvas
  37762. */
  37763. releaseCanvas(): void;
  37764. }
  37765. }
  37766. declare module BABYLON {
  37767. interface FreeCameraInputsManager {
  37768. /**
  37769. * Add virtual joystick input support to the input manager.
  37770. * @returns the current input manager
  37771. */
  37772. addVirtualJoystick(): FreeCameraInputsManager;
  37773. }
  37774. /**
  37775. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37777. */
  37778. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37779. /**
  37780. * Defines the camera the input is attached to.
  37781. */
  37782. camera: FreeCamera;
  37783. private _leftjoystick;
  37784. private _rightjoystick;
  37785. /**
  37786. * Gets the left stick of the virtual joystick.
  37787. * @returns The virtual Joystick
  37788. */
  37789. getLeftJoystick(): VirtualJoystick;
  37790. /**
  37791. * Gets the right stick of the virtual joystick.
  37792. * @returns The virtual Joystick
  37793. */
  37794. getRightJoystick(): VirtualJoystick;
  37795. /**
  37796. * Update the current camera state depending on the inputs that have been used this frame.
  37797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37798. */
  37799. checkInputs(): void;
  37800. /**
  37801. * Attach the input controls to a specific dom element to get the input from.
  37802. * @param element Defines the element the controls should be listened from
  37803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37804. */
  37805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37806. /**
  37807. * Detach the current controls from the specified dom element.
  37808. * @param element Defines the element to stop listening the inputs from
  37809. */
  37810. detachControl(element: Nullable<HTMLElement>): void;
  37811. /**
  37812. * Gets the class name of the current intput.
  37813. * @returns the class name
  37814. */
  37815. getClassName(): string;
  37816. /**
  37817. * Get the friendly name associated with the input class.
  37818. * @returns the input friendly name
  37819. */
  37820. getSimpleName(): string;
  37821. }
  37822. }
  37823. declare module BABYLON {
  37824. /**
  37825. * This represents a FPS type of camera controlled by touch.
  37826. * This is like a universal camera minus the Gamepad controls.
  37827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37828. */
  37829. export class TouchCamera extends FreeCamera {
  37830. /**
  37831. * Defines the touch sensibility for rotation.
  37832. * The higher the faster.
  37833. */
  37834. touchAngularSensibility: number;
  37835. /**
  37836. * Defines the touch sensibility for move.
  37837. * The higher the faster.
  37838. */
  37839. touchMoveSensibility: number;
  37840. /**
  37841. * Instantiates a new touch camera.
  37842. * This represents a FPS type of camera controlled by touch.
  37843. * This is like a universal camera minus the Gamepad controls.
  37844. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37845. * @param name Define the name of the camera in the scene
  37846. * @param position Define the start position of the camera in the scene
  37847. * @param scene Define the scene the camera belongs to
  37848. */
  37849. constructor(name: string, position: Vector3, scene: Scene);
  37850. /**
  37851. * Gets the current object class name.
  37852. * @return the class name
  37853. */
  37854. getClassName(): string;
  37855. /** @hidden */
  37856. _setupInputs(): void;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /**
  37861. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37862. * being tilted forward or back and left or right.
  37863. */
  37864. export class DeviceOrientationCamera extends FreeCamera {
  37865. private _initialQuaternion;
  37866. private _quaternionCache;
  37867. private _tmpDragQuaternion;
  37868. /**
  37869. * Creates a new device orientation camera
  37870. * @param name The name of the camera
  37871. * @param position The start position camera
  37872. * @param scene The scene the camera belongs to
  37873. */
  37874. constructor(name: string, position: Vector3, scene: Scene);
  37875. /**
  37876. * @hidden
  37877. * Disabled pointer input on first orientation sensor update (Default: true)
  37878. */
  37879. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37880. private _dragFactor;
  37881. /**
  37882. * Enabled turning on the y axis when the orientation sensor is active
  37883. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37884. */
  37885. enableHorizontalDragging(dragFactor?: number): void;
  37886. /**
  37887. * Gets the current instance class name ("DeviceOrientationCamera").
  37888. * This helps avoiding instanceof at run time.
  37889. * @returns the class name
  37890. */
  37891. getClassName(): string;
  37892. /**
  37893. * @hidden
  37894. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37895. */
  37896. _checkInputs(): void;
  37897. /**
  37898. * Reset the camera to its default orientation on the specified axis only.
  37899. * @param axis The axis to reset
  37900. */
  37901. resetToCurrentRotation(axis?: Axis): void;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. /**
  37906. * Defines supported buttons for XBox360 compatible gamepads
  37907. */
  37908. export enum Xbox360Button {
  37909. /** A */
  37910. A = 0,
  37911. /** B */
  37912. B = 1,
  37913. /** X */
  37914. X = 2,
  37915. /** Y */
  37916. Y = 3,
  37917. /** Start */
  37918. Start = 4,
  37919. /** Back */
  37920. Back = 5,
  37921. /** Left button */
  37922. LB = 6,
  37923. /** Right button */
  37924. RB = 7,
  37925. /** Left stick */
  37926. LeftStick = 8,
  37927. /** Right stick */
  37928. RightStick = 9
  37929. }
  37930. /** Defines values for XBox360 DPad */
  37931. export enum Xbox360Dpad {
  37932. /** Up */
  37933. Up = 0,
  37934. /** Down */
  37935. Down = 1,
  37936. /** Left */
  37937. Left = 2,
  37938. /** Right */
  37939. Right = 3
  37940. }
  37941. /**
  37942. * Defines a XBox360 gamepad
  37943. */
  37944. export class Xbox360Pad extends Gamepad {
  37945. private _leftTrigger;
  37946. private _rightTrigger;
  37947. private _onlefttriggerchanged;
  37948. private _onrighttriggerchanged;
  37949. private _onbuttondown;
  37950. private _onbuttonup;
  37951. private _ondpaddown;
  37952. private _ondpadup;
  37953. /** Observable raised when a button is pressed */
  37954. onButtonDownObservable: Observable<Xbox360Button>;
  37955. /** Observable raised when a button is released */
  37956. onButtonUpObservable: Observable<Xbox360Button>;
  37957. /** Observable raised when a pad is pressed */
  37958. onPadDownObservable: Observable<Xbox360Dpad>;
  37959. /** Observable raised when a pad is released */
  37960. onPadUpObservable: Observable<Xbox360Dpad>;
  37961. private _buttonA;
  37962. private _buttonB;
  37963. private _buttonX;
  37964. private _buttonY;
  37965. private _buttonBack;
  37966. private _buttonStart;
  37967. private _buttonLB;
  37968. private _buttonRB;
  37969. private _buttonLeftStick;
  37970. private _buttonRightStick;
  37971. private _dPadUp;
  37972. private _dPadDown;
  37973. private _dPadLeft;
  37974. private _dPadRight;
  37975. private _isXboxOnePad;
  37976. /**
  37977. * Creates a new XBox360 gamepad object
  37978. * @param id defines the id of this gamepad
  37979. * @param index defines its index
  37980. * @param gamepad defines the internal HTML gamepad object
  37981. * @param xboxOne defines if it is a XBox One gamepad
  37982. */
  37983. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37984. /**
  37985. * Defines the callback to call when left trigger is pressed
  37986. * @param callback defines the callback to use
  37987. */
  37988. onlefttriggerchanged(callback: (value: number) => void): void;
  37989. /**
  37990. * Defines the callback to call when right trigger is pressed
  37991. * @param callback defines the callback to use
  37992. */
  37993. onrighttriggerchanged(callback: (value: number) => void): void;
  37994. /**
  37995. * Gets the left trigger value
  37996. */
  37997. /**
  37998. * Sets the left trigger value
  37999. */
  38000. leftTrigger: number;
  38001. /**
  38002. * Gets the right trigger value
  38003. */
  38004. /**
  38005. * Sets the right trigger value
  38006. */
  38007. rightTrigger: number;
  38008. /**
  38009. * Defines the callback to call when a button is pressed
  38010. * @param callback defines the callback to use
  38011. */
  38012. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38013. /**
  38014. * Defines the callback to call when a button is released
  38015. * @param callback defines the callback to use
  38016. */
  38017. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38018. /**
  38019. * Defines the callback to call when a pad is pressed
  38020. * @param callback defines the callback to use
  38021. */
  38022. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38023. /**
  38024. * Defines the callback to call when a pad is released
  38025. * @param callback defines the callback to use
  38026. */
  38027. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38028. private _setButtonValue;
  38029. private _setDPadValue;
  38030. /**
  38031. * Gets the value of the `A` button
  38032. */
  38033. /**
  38034. * Sets the value of the `A` button
  38035. */
  38036. buttonA: number;
  38037. /**
  38038. * Gets the value of the `B` button
  38039. */
  38040. /**
  38041. * Sets the value of the `B` button
  38042. */
  38043. buttonB: number;
  38044. /**
  38045. * Gets the value of the `X` button
  38046. */
  38047. /**
  38048. * Sets the value of the `X` button
  38049. */
  38050. buttonX: number;
  38051. /**
  38052. * Gets the value of the `Y` button
  38053. */
  38054. /**
  38055. * Sets the value of the `Y` button
  38056. */
  38057. buttonY: number;
  38058. /**
  38059. * Gets the value of the `Start` button
  38060. */
  38061. /**
  38062. * Sets the value of the `Start` button
  38063. */
  38064. buttonStart: number;
  38065. /**
  38066. * Gets the value of the `Back` button
  38067. */
  38068. /**
  38069. * Sets the value of the `Back` button
  38070. */
  38071. buttonBack: number;
  38072. /**
  38073. * Gets the value of the `Left` button
  38074. */
  38075. /**
  38076. * Sets the value of the `Left` button
  38077. */
  38078. buttonLB: number;
  38079. /**
  38080. * Gets the value of the `Right` button
  38081. */
  38082. /**
  38083. * Sets the value of the `Right` button
  38084. */
  38085. buttonRB: number;
  38086. /**
  38087. * Gets the value of the Left joystick
  38088. */
  38089. /**
  38090. * Sets the value of the Left joystick
  38091. */
  38092. buttonLeftStick: number;
  38093. /**
  38094. * Gets the value of the Right joystick
  38095. */
  38096. /**
  38097. * Sets the value of the Right joystick
  38098. */
  38099. buttonRightStick: number;
  38100. /**
  38101. * Gets the value of D-pad up
  38102. */
  38103. /**
  38104. * Sets the value of D-pad up
  38105. */
  38106. dPadUp: number;
  38107. /**
  38108. * Gets the value of D-pad down
  38109. */
  38110. /**
  38111. * Sets the value of D-pad down
  38112. */
  38113. dPadDown: number;
  38114. /**
  38115. * Gets the value of D-pad left
  38116. */
  38117. /**
  38118. * Sets the value of D-pad left
  38119. */
  38120. dPadLeft: number;
  38121. /**
  38122. * Gets the value of D-pad right
  38123. */
  38124. /**
  38125. * Sets the value of D-pad right
  38126. */
  38127. dPadRight: number;
  38128. /**
  38129. * Force the gamepad to synchronize with device values
  38130. */
  38131. update(): void;
  38132. /**
  38133. * Disposes the gamepad
  38134. */
  38135. dispose(): void;
  38136. }
  38137. }
  38138. declare module BABYLON {
  38139. /**
  38140. * Manager for handling gamepads
  38141. */
  38142. export class GamepadManager {
  38143. private _scene?;
  38144. private _babylonGamepads;
  38145. private _oneGamepadConnected;
  38146. /** @hidden */
  38147. _isMonitoring: boolean;
  38148. private _gamepadEventSupported;
  38149. private _gamepadSupport;
  38150. /**
  38151. * observable to be triggered when the gamepad controller has been connected
  38152. */
  38153. onGamepadConnectedObservable: Observable<Gamepad>;
  38154. /**
  38155. * observable to be triggered when the gamepad controller has been disconnected
  38156. */
  38157. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38158. private _onGamepadConnectedEvent;
  38159. private _onGamepadDisconnectedEvent;
  38160. /**
  38161. * Initializes the gamepad manager
  38162. * @param _scene BabylonJS scene
  38163. */
  38164. constructor(_scene?: Scene | undefined);
  38165. /**
  38166. * The gamepads in the game pad manager
  38167. */
  38168. readonly gamepads: Gamepad[];
  38169. /**
  38170. * Get the gamepad controllers based on type
  38171. * @param type The type of gamepad controller
  38172. * @returns Nullable gamepad
  38173. */
  38174. getGamepadByType(type?: number): Nullable<Gamepad>;
  38175. /**
  38176. * Disposes the gamepad manager
  38177. */
  38178. dispose(): void;
  38179. private _addNewGamepad;
  38180. private _startMonitoringGamepads;
  38181. private _stopMonitoringGamepads;
  38182. /** @hidden */
  38183. _checkGamepadsStatus(): void;
  38184. private _updateGamepadObjects;
  38185. }
  38186. }
  38187. declare module BABYLON {
  38188. interface Scene {
  38189. /** @hidden */
  38190. _gamepadManager: Nullable<GamepadManager>;
  38191. /**
  38192. * Gets the gamepad manager associated with the scene
  38193. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38194. */
  38195. gamepadManager: GamepadManager;
  38196. }
  38197. /**
  38198. * Interface representing a free camera inputs manager
  38199. */
  38200. interface FreeCameraInputsManager {
  38201. /**
  38202. * Adds gamepad input support to the FreeCameraInputsManager.
  38203. * @returns the FreeCameraInputsManager
  38204. */
  38205. addGamepad(): FreeCameraInputsManager;
  38206. }
  38207. /**
  38208. * Interface representing an arc rotate camera inputs manager
  38209. */
  38210. interface ArcRotateCameraInputsManager {
  38211. /**
  38212. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38213. * @returns the camera inputs manager
  38214. */
  38215. addGamepad(): ArcRotateCameraInputsManager;
  38216. }
  38217. /**
  38218. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38219. */
  38220. export class GamepadSystemSceneComponent implements ISceneComponent {
  38221. /**
  38222. * The component name helpfull to identify the component in the list of scene components.
  38223. */
  38224. readonly name: string;
  38225. /**
  38226. * The scene the component belongs to.
  38227. */
  38228. scene: Scene;
  38229. /**
  38230. * Creates a new instance of the component for the given scene
  38231. * @param scene Defines the scene to register the component in
  38232. */
  38233. constructor(scene: Scene);
  38234. /**
  38235. * Registers the component in a given scene
  38236. */
  38237. register(): void;
  38238. /**
  38239. * Rebuilds the elements related to this component in case of
  38240. * context lost for instance.
  38241. */
  38242. rebuild(): void;
  38243. /**
  38244. * Disposes the component and the associated ressources
  38245. */
  38246. dispose(): void;
  38247. private _beforeCameraUpdate;
  38248. }
  38249. }
  38250. declare module BABYLON {
  38251. /**
  38252. * 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,
  38253. * which still works and will still be found in many Playgrounds.
  38254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38255. */
  38256. export class UniversalCamera extends TouchCamera {
  38257. /**
  38258. * Defines the gamepad rotation sensiblity.
  38259. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38260. */
  38261. gamepadAngularSensibility: number;
  38262. /**
  38263. * Defines the gamepad move sensiblity.
  38264. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38265. */
  38266. gamepadMoveSensibility: number;
  38267. /**
  38268. * 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,
  38269. * which still works and will still be found in many Playgrounds.
  38270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38271. * @param name Define the name of the camera in the scene
  38272. * @param position Define the start position of the camera in the scene
  38273. * @param scene Define the scene the camera belongs to
  38274. */
  38275. constructor(name: string, position: Vector3, scene: Scene);
  38276. /**
  38277. * Gets the current object class name.
  38278. * @return the class name
  38279. */
  38280. getClassName(): string;
  38281. }
  38282. }
  38283. declare module BABYLON {
  38284. /**
  38285. * This represents a FPS type of camera. This is only here for back compat purpose.
  38286. * Please use the UniversalCamera instead as both are identical.
  38287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38288. */
  38289. export class GamepadCamera extends UniversalCamera {
  38290. /**
  38291. * Instantiates a new Gamepad Camera
  38292. * This represents a FPS type of camera. This is only here for back compat purpose.
  38293. * Please use the UniversalCamera instead as both are identical.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. * @param name Define the name of the camera in the scene
  38296. * @param position Define the start position of the camera in the scene
  38297. * @param scene Define the scene the camera belongs to
  38298. */
  38299. constructor(name: string, position: Vector3, scene: Scene);
  38300. /**
  38301. * Gets the current object class name.
  38302. * @return the class name
  38303. */
  38304. getClassName(): string;
  38305. }
  38306. }
  38307. declare module BABYLON {
  38308. /** @hidden */
  38309. export var passPixelShader: {
  38310. name: string;
  38311. shader: string;
  38312. };
  38313. }
  38314. declare module BABYLON {
  38315. /** @hidden */
  38316. export var passCubePixelShader: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module BABYLON {
  38322. /**
  38323. * PassPostProcess which produces an output the same as it's input
  38324. */
  38325. export class PassPostProcess extends PostProcess {
  38326. /**
  38327. * Creates the PassPostProcess
  38328. * @param name The name of the effect.
  38329. * @param options The required width/height ratio to downsize to before computing the render pass.
  38330. * @param camera The camera to apply the render pass to.
  38331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38332. * @param engine The engine which the post process will be applied. (default: current engine)
  38333. * @param reusable If the post process can be reused on the same frame. (default: false)
  38334. * @param textureType The type of texture to be used when performing the post processing.
  38335. * @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)
  38336. */
  38337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38338. }
  38339. /**
  38340. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38341. */
  38342. export class PassCubePostProcess extends PostProcess {
  38343. private _face;
  38344. /**
  38345. * Gets or sets the cube face to display.
  38346. * * 0 is +X
  38347. * * 1 is -X
  38348. * * 2 is +Y
  38349. * * 3 is -Y
  38350. * * 4 is +Z
  38351. * * 5 is -Z
  38352. */
  38353. face: number;
  38354. /**
  38355. * Creates the PassCubePostProcess
  38356. * @param name The name of the effect.
  38357. * @param options The required width/height ratio to downsize to before computing the render pass.
  38358. * @param camera The camera to apply the render pass to.
  38359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38360. * @param engine The engine which the post process will be applied. (default: current engine)
  38361. * @param reusable If the post process can be reused on the same frame. (default: false)
  38362. * @param textureType The type of texture to be used when performing the post processing.
  38363. * @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)
  38364. */
  38365. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38366. }
  38367. }
  38368. declare module BABYLON {
  38369. /** @hidden */
  38370. export var anaglyphPixelShader: {
  38371. name: string;
  38372. shader: string;
  38373. };
  38374. }
  38375. declare module BABYLON {
  38376. /**
  38377. * Postprocess used to generate anaglyphic rendering
  38378. */
  38379. export class AnaglyphPostProcess extends PostProcess {
  38380. private _passedProcess;
  38381. /**
  38382. * Creates a new AnaglyphPostProcess
  38383. * @param name defines postprocess name
  38384. * @param options defines creation options or target ratio scale
  38385. * @param rigCameras defines cameras using this postprocess
  38386. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38387. * @param engine defines hosting engine
  38388. * @param reusable defines if the postprocess will be reused multiple times per frame
  38389. */
  38390. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38391. }
  38392. }
  38393. declare module BABYLON {
  38394. /**
  38395. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38396. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38397. */
  38398. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38399. /**
  38400. * Creates a new AnaglyphArcRotateCamera
  38401. * @param name defines camera name
  38402. * @param alpha defines alpha angle (in radians)
  38403. * @param beta defines beta angle (in radians)
  38404. * @param radius defines radius
  38405. * @param target defines camera target
  38406. * @param interaxialDistance defines distance between each color axis
  38407. * @param scene defines the hosting scene
  38408. */
  38409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38410. /**
  38411. * Gets camera class name
  38412. * @returns AnaglyphArcRotateCamera
  38413. */
  38414. getClassName(): string;
  38415. }
  38416. }
  38417. declare module BABYLON {
  38418. /**
  38419. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38420. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38421. */
  38422. export class AnaglyphFreeCamera extends FreeCamera {
  38423. /**
  38424. * Creates a new AnaglyphFreeCamera
  38425. * @param name defines camera name
  38426. * @param position defines initial position
  38427. * @param interaxialDistance defines distance between each color axis
  38428. * @param scene defines the hosting scene
  38429. */
  38430. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38431. /**
  38432. * Gets camera class name
  38433. * @returns AnaglyphFreeCamera
  38434. */
  38435. getClassName(): string;
  38436. }
  38437. }
  38438. declare module BABYLON {
  38439. /**
  38440. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38441. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38442. */
  38443. export class AnaglyphGamepadCamera extends GamepadCamera {
  38444. /**
  38445. * Creates a new AnaglyphGamepadCamera
  38446. * @param name defines camera name
  38447. * @param position defines initial position
  38448. * @param interaxialDistance defines distance between each color axis
  38449. * @param scene defines the hosting scene
  38450. */
  38451. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38452. /**
  38453. * Gets camera class name
  38454. * @returns AnaglyphGamepadCamera
  38455. */
  38456. getClassName(): string;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /**
  38461. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38462. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38463. */
  38464. export class AnaglyphUniversalCamera extends UniversalCamera {
  38465. /**
  38466. * Creates a new AnaglyphUniversalCamera
  38467. * @param name defines camera name
  38468. * @param position defines initial position
  38469. * @param interaxialDistance defines distance between each color axis
  38470. * @param scene defines the hosting scene
  38471. */
  38472. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38473. /**
  38474. * Gets camera class name
  38475. * @returns AnaglyphUniversalCamera
  38476. */
  38477. getClassName(): string;
  38478. }
  38479. }
  38480. declare module BABYLON {
  38481. /** @hidden */
  38482. export var stereoscopicInterlacePixelShader: {
  38483. name: string;
  38484. shader: string;
  38485. };
  38486. }
  38487. declare module BABYLON {
  38488. /**
  38489. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38490. */
  38491. export class StereoscopicInterlacePostProcess extends PostProcess {
  38492. private _stepSize;
  38493. private _passedProcess;
  38494. /**
  38495. * Initializes a StereoscopicInterlacePostProcess
  38496. * @param name The name of the effect.
  38497. * @param rigCameras The rig cameras to be appled to the post process
  38498. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38500. * @param engine The engine which the post process will be applied. (default: current engine)
  38501. * @param reusable If the post process can be reused on the same frame. (default: false)
  38502. */
  38503. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38504. }
  38505. }
  38506. declare module BABYLON {
  38507. /**
  38508. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38509. * @see http://doc.babylonjs.com/features/cameras
  38510. */
  38511. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38512. /**
  38513. * Creates a new StereoscopicArcRotateCamera
  38514. * @param name defines camera name
  38515. * @param alpha defines alpha angle (in radians)
  38516. * @param beta defines beta angle (in radians)
  38517. * @param radius defines radius
  38518. * @param target defines camera target
  38519. * @param interaxialDistance defines distance between each color axis
  38520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38521. * @param scene defines the hosting scene
  38522. */
  38523. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38524. /**
  38525. * Gets camera class name
  38526. * @returns StereoscopicArcRotateCamera
  38527. */
  38528. getClassName(): string;
  38529. }
  38530. }
  38531. declare module BABYLON {
  38532. /**
  38533. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38534. * @see http://doc.babylonjs.com/features/cameras
  38535. */
  38536. export class StereoscopicFreeCamera extends FreeCamera {
  38537. /**
  38538. * Creates a new StereoscopicFreeCamera
  38539. * @param name defines camera name
  38540. * @param position defines initial position
  38541. * @param interaxialDistance defines distance between each color axis
  38542. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38543. * @param scene defines the hosting scene
  38544. */
  38545. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38546. /**
  38547. * Gets camera class name
  38548. * @returns StereoscopicFreeCamera
  38549. */
  38550. getClassName(): string;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38556. * @see http://doc.babylonjs.com/features/cameras
  38557. */
  38558. export class StereoscopicGamepadCamera extends GamepadCamera {
  38559. /**
  38560. * Creates a new StereoscopicGamepadCamera
  38561. * @param name defines camera name
  38562. * @param position defines initial position
  38563. * @param interaxialDistance defines distance between each color axis
  38564. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38565. * @param scene defines the hosting scene
  38566. */
  38567. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38568. /**
  38569. * Gets camera class name
  38570. * @returns StereoscopicGamepadCamera
  38571. */
  38572. getClassName(): string;
  38573. }
  38574. }
  38575. declare module BABYLON {
  38576. /**
  38577. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38578. * @see http://doc.babylonjs.com/features/cameras
  38579. */
  38580. export class StereoscopicUniversalCamera extends UniversalCamera {
  38581. /**
  38582. * Creates a new StereoscopicUniversalCamera
  38583. * @param name defines camera name
  38584. * @param position defines initial position
  38585. * @param interaxialDistance defines distance between each color axis
  38586. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38587. * @param scene defines the hosting scene
  38588. */
  38589. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38590. /**
  38591. * Gets camera class name
  38592. * @returns StereoscopicUniversalCamera
  38593. */
  38594. getClassName(): string;
  38595. }
  38596. }
  38597. declare module BABYLON {
  38598. /**
  38599. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38600. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38601. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38602. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38603. */
  38604. export class VirtualJoysticksCamera extends FreeCamera {
  38605. /**
  38606. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38610. * @param name Define the name of the camera in the scene
  38611. * @param position Define the start position of the camera in the scene
  38612. * @param scene Define the scene the camera belongs to
  38613. */
  38614. constructor(name: string, position: Vector3, scene: Scene);
  38615. /**
  38616. * Gets the current object class name.
  38617. * @return the class name
  38618. */
  38619. getClassName(): string;
  38620. }
  38621. }
  38622. declare module BABYLON {
  38623. /**
  38624. * This represents all the required metrics to create a VR camera.
  38625. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38626. */
  38627. export class VRCameraMetrics {
  38628. /**
  38629. * Define the horizontal resolution off the screen.
  38630. */
  38631. hResolution: number;
  38632. /**
  38633. * Define the vertical resolution off the screen.
  38634. */
  38635. vResolution: number;
  38636. /**
  38637. * Define the horizontal screen size.
  38638. */
  38639. hScreenSize: number;
  38640. /**
  38641. * Define the vertical screen size.
  38642. */
  38643. vScreenSize: number;
  38644. /**
  38645. * Define the vertical screen center position.
  38646. */
  38647. vScreenCenter: number;
  38648. /**
  38649. * Define the distance of the eyes to the screen.
  38650. */
  38651. eyeToScreenDistance: number;
  38652. /**
  38653. * Define the distance between both lenses
  38654. */
  38655. lensSeparationDistance: number;
  38656. /**
  38657. * Define the distance between both viewer's eyes.
  38658. */
  38659. interpupillaryDistance: number;
  38660. /**
  38661. * Define the distortion factor of the VR postprocess.
  38662. * Please, touch with care.
  38663. */
  38664. distortionK: number[];
  38665. /**
  38666. * Define the chromatic aberration correction factors for the VR post process.
  38667. */
  38668. chromaAbCorrection: number[];
  38669. /**
  38670. * Define the scale factor of the post process.
  38671. * The smaller the better but the slower.
  38672. */
  38673. postProcessScaleFactor: number;
  38674. /**
  38675. * Define an offset for the lens center.
  38676. */
  38677. lensCenterOffset: number;
  38678. /**
  38679. * Define if the current vr camera should compensate the distortion of the lense or not.
  38680. */
  38681. compensateDistortion: boolean;
  38682. /**
  38683. * Defines if multiview should be enabled when rendering (Default: false)
  38684. */
  38685. multiviewEnabled: boolean;
  38686. /**
  38687. * Gets the rendering aspect ratio based on the provided resolutions.
  38688. */
  38689. readonly aspectRatio: number;
  38690. /**
  38691. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38692. */
  38693. readonly aspectRatioFov: number;
  38694. /**
  38695. * @hidden
  38696. */
  38697. readonly leftHMatrix: Matrix;
  38698. /**
  38699. * @hidden
  38700. */
  38701. readonly rightHMatrix: Matrix;
  38702. /**
  38703. * @hidden
  38704. */
  38705. readonly leftPreViewMatrix: Matrix;
  38706. /**
  38707. * @hidden
  38708. */
  38709. readonly rightPreViewMatrix: Matrix;
  38710. /**
  38711. * Get the default VRMetrics based on the most generic setup.
  38712. * @returns the default vr metrics
  38713. */
  38714. static GetDefault(): VRCameraMetrics;
  38715. }
  38716. }
  38717. declare module BABYLON {
  38718. /** @hidden */
  38719. export var vrDistortionCorrectionPixelShader: {
  38720. name: string;
  38721. shader: string;
  38722. };
  38723. }
  38724. declare module BABYLON {
  38725. /**
  38726. * VRDistortionCorrectionPostProcess used for mobile VR
  38727. */
  38728. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38729. private _isRightEye;
  38730. private _distortionFactors;
  38731. private _postProcessScaleFactor;
  38732. private _lensCenterOffset;
  38733. private _scaleIn;
  38734. private _scaleFactor;
  38735. private _lensCenter;
  38736. /**
  38737. * Initializes the VRDistortionCorrectionPostProcess
  38738. * @param name The name of the effect.
  38739. * @param camera The camera to apply the render pass to.
  38740. * @param isRightEye If this is for the right eye distortion
  38741. * @param vrMetrics All the required metrics for the VR camera
  38742. */
  38743. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38744. }
  38745. }
  38746. declare module BABYLON {
  38747. /**
  38748. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38749. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38750. */
  38751. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38752. /**
  38753. * Creates a new VRDeviceOrientationArcRotateCamera
  38754. * @param name defines camera name
  38755. * @param alpha defines the camera rotation along the logitudinal axis
  38756. * @param beta defines the camera rotation along the latitudinal axis
  38757. * @param radius defines the camera distance from its target
  38758. * @param target defines the camera target
  38759. * @param scene defines the scene the camera belongs to
  38760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38762. */
  38763. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38764. /**
  38765. * Gets camera class name
  38766. * @returns VRDeviceOrientationArcRotateCamera
  38767. */
  38768. getClassName(): string;
  38769. }
  38770. }
  38771. declare module BABYLON {
  38772. /**
  38773. * Camera used to simulate VR rendering (based on FreeCamera)
  38774. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38775. */
  38776. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38777. /**
  38778. * Creates a new VRDeviceOrientationFreeCamera
  38779. * @param name defines camera name
  38780. * @param position defines the start position of the camera
  38781. * @param scene defines the scene the camera belongs to
  38782. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38783. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38784. */
  38785. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38786. /**
  38787. * Gets camera class name
  38788. * @returns VRDeviceOrientationFreeCamera
  38789. */
  38790. getClassName(): string;
  38791. }
  38792. }
  38793. declare module BABYLON {
  38794. /**
  38795. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38796. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38797. */
  38798. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38799. /**
  38800. * Creates a new VRDeviceOrientationGamepadCamera
  38801. * @param name defines camera name
  38802. * @param position defines the start position of the camera
  38803. * @param scene defines the scene the camera belongs to
  38804. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38805. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38806. */
  38807. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38808. /**
  38809. * Gets camera class name
  38810. * @returns VRDeviceOrientationGamepadCamera
  38811. */
  38812. getClassName(): string;
  38813. }
  38814. }
  38815. declare module BABYLON {
  38816. /**
  38817. * Base class of materials working in push mode in babylon JS
  38818. * @hidden
  38819. */
  38820. export class PushMaterial extends Material {
  38821. protected _activeEffect: Effect;
  38822. protected _normalMatrix: Matrix;
  38823. /**
  38824. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38825. * This means that the material can keep using a previous shader while a new one is being compiled.
  38826. * This is mostly used when shader parallel compilation is supported (true by default)
  38827. */
  38828. allowShaderHotSwapping: boolean;
  38829. constructor(name: string, scene: Scene);
  38830. getEffect(): Effect;
  38831. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38832. /**
  38833. * Binds the given world matrix to the active effect
  38834. *
  38835. * @param world the matrix to bind
  38836. */
  38837. bindOnlyWorldMatrix(world: Matrix): void;
  38838. /**
  38839. * Binds the given normal matrix to the active effect
  38840. *
  38841. * @param normalMatrix the matrix to bind
  38842. */
  38843. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38844. bind(world: Matrix, mesh?: Mesh): void;
  38845. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38846. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38847. }
  38848. }
  38849. declare module BABYLON {
  38850. /**
  38851. * This groups all the flags used to control the materials channel.
  38852. */
  38853. export class MaterialFlags {
  38854. private static _DiffuseTextureEnabled;
  38855. /**
  38856. * Are diffuse textures enabled in the application.
  38857. */
  38858. static DiffuseTextureEnabled: boolean;
  38859. private static _AmbientTextureEnabled;
  38860. /**
  38861. * Are ambient textures enabled in the application.
  38862. */
  38863. static AmbientTextureEnabled: boolean;
  38864. private static _OpacityTextureEnabled;
  38865. /**
  38866. * Are opacity textures enabled in the application.
  38867. */
  38868. static OpacityTextureEnabled: boolean;
  38869. private static _ReflectionTextureEnabled;
  38870. /**
  38871. * Are reflection textures enabled in the application.
  38872. */
  38873. static ReflectionTextureEnabled: boolean;
  38874. private static _EmissiveTextureEnabled;
  38875. /**
  38876. * Are emissive textures enabled in the application.
  38877. */
  38878. static EmissiveTextureEnabled: boolean;
  38879. private static _SpecularTextureEnabled;
  38880. /**
  38881. * Are specular textures enabled in the application.
  38882. */
  38883. static SpecularTextureEnabled: boolean;
  38884. private static _BumpTextureEnabled;
  38885. /**
  38886. * Are bump textures enabled in the application.
  38887. */
  38888. static BumpTextureEnabled: boolean;
  38889. private static _LightmapTextureEnabled;
  38890. /**
  38891. * Are lightmap textures enabled in the application.
  38892. */
  38893. static LightmapTextureEnabled: boolean;
  38894. private static _RefractionTextureEnabled;
  38895. /**
  38896. * Are refraction textures enabled in the application.
  38897. */
  38898. static RefractionTextureEnabled: boolean;
  38899. private static _ColorGradingTextureEnabled;
  38900. /**
  38901. * Are color grading textures enabled in the application.
  38902. */
  38903. static ColorGradingTextureEnabled: boolean;
  38904. private static _FresnelEnabled;
  38905. /**
  38906. * Are fresnels enabled in the application.
  38907. */
  38908. static FresnelEnabled: boolean;
  38909. private static _ClearCoatTextureEnabled;
  38910. /**
  38911. * Are clear coat textures enabled in the application.
  38912. */
  38913. static ClearCoatTextureEnabled: boolean;
  38914. private static _ClearCoatBumpTextureEnabled;
  38915. /**
  38916. * Are clear coat bump textures enabled in the application.
  38917. */
  38918. static ClearCoatBumpTextureEnabled: boolean;
  38919. private static _ClearCoatTintTextureEnabled;
  38920. /**
  38921. * Are clear coat tint textures enabled in the application.
  38922. */
  38923. static ClearCoatTintTextureEnabled: boolean;
  38924. private static _SheenTextureEnabled;
  38925. /**
  38926. * Are sheen textures enabled in the application.
  38927. */
  38928. static SheenTextureEnabled: boolean;
  38929. private static _AnisotropicTextureEnabled;
  38930. /**
  38931. * Are anisotropic textures enabled in the application.
  38932. */
  38933. static AnisotropicTextureEnabled: boolean;
  38934. private static _ThicknessTextureEnabled;
  38935. /**
  38936. * Are thickness textures enabled in the application.
  38937. */
  38938. static ThicknessTextureEnabled: boolean;
  38939. }
  38940. }
  38941. declare module BABYLON {
  38942. /** @hidden */
  38943. export var defaultFragmentDeclaration: {
  38944. name: string;
  38945. shader: string;
  38946. };
  38947. }
  38948. declare module BABYLON {
  38949. /** @hidden */
  38950. export var defaultUboDeclaration: {
  38951. name: string;
  38952. shader: string;
  38953. };
  38954. }
  38955. declare module BABYLON {
  38956. /** @hidden */
  38957. export var lightFragmentDeclaration: {
  38958. name: string;
  38959. shader: string;
  38960. };
  38961. }
  38962. declare module BABYLON {
  38963. /** @hidden */
  38964. export var lightUboDeclaration: {
  38965. name: string;
  38966. shader: string;
  38967. };
  38968. }
  38969. declare module BABYLON {
  38970. /** @hidden */
  38971. export var lightsFragmentFunctions: {
  38972. name: string;
  38973. shader: string;
  38974. };
  38975. }
  38976. declare module BABYLON {
  38977. /** @hidden */
  38978. export var shadowsFragmentFunctions: {
  38979. name: string;
  38980. shader: string;
  38981. };
  38982. }
  38983. declare module BABYLON {
  38984. /** @hidden */
  38985. export var fresnelFunction: {
  38986. name: string;
  38987. shader: string;
  38988. };
  38989. }
  38990. declare module BABYLON {
  38991. /** @hidden */
  38992. export var reflectionFunction: {
  38993. name: string;
  38994. shader: string;
  38995. };
  38996. }
  38997. declare module BABYLON {
  38998. /** @hidden */
  38999. export var bumpFragmentFunctions: {
  39000. name: string;
  39001. shader: string;
  39002. };
  39003. }
  39004. declare module BABYLON {
  39005. /** @hidden */
  39006. export var logDepthDeclaration: {
  39007. name: string;
  39008. shader: string;
  39009. };
  39010. }
  39011. declare module BABYLON {
  39012. /** @hidden */
  39013. export var bumpFragment: {
  39014. name: string;
  39015. shader: string;
  39016. };
  39017. }
  39018. declare module BABYLON {
  39019. /** @hidden */
  39020. export var depthPrePass: {
  39021. name: string;
  39022. shader: string;
  39023. };
  39024. }
  39025. declare module BABYLON {
  39026. /** @hidden */
  39027. export var lightFragment: {
  39028. name: string;
  39029. shader: string;
  39030. };
  39031. }
  39032. declare module BABYLON {
  39033. /** @hidden */
  39034. export var logDepthFragment: {
  39035. name: string;
  39036. shader: string;
  39037. };
  39038. }
  39039. declare module BABYLON {
  39040. /** @hidden */
  39041. export var defaultPixelShader: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module BABYLON {
  39047. /** @hidden */
  39048. export var defaultVertexDeclaration: {
  39049. name: string;
  39050. shader: string;
  39051. };
  39052. }
  39053. declare module BABYLON {
  39054. /** @hidden */
  39055. export var bumpVertexDeclaration: {
  39056. name: string;
  39057. shader: string;
  39058. };
  39059. }
  39060. declare module BABYLON {
  39061. /** @hidden */
  39062. export var bumpVertex: {
  39063. name: string;
  39064. shader: string;
  39065. };
  39066. }
  39067. declare module BABYLON {
  39068. /** @hidden */
  39069. export var fogVertex: {
  39070. name: string;
  39071. shader: string;
  39072. };
  39073. }
  39074. declare module BABYLON {
  39075. /** @hidden */
  39076. export var shadowsVertex: {
  39077. name: string;
  39078. shader: string;
  39079. };
  39080. }
  39081. declare module BABYLON {
  39082. /** @hidden */
  39083. export var pointCloudVertex: {
  39084. name: string;
  39085. shader: string;
  39086. };
  39087. }
  39088. declare module BABYLON {
  39089. /** @hidden */
  39090. export var logDepthVertex: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module BABYLON {
  39096. /** @hidden */
  39097. export var defaultVertexShader: {
  39098. name: string;
  39099. shader: string;
  39100. };
  39101. }
  39102. declare module BABYLON {
  39103. /** @hidden */
  39104. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39105. MAINUV1: boolean;
  39106. MAINUV2: boolean;
  39107. DIFFUSE: boolean;
  39108. DIFFUSEDIRECTUV: number;
  39109. AMBIENT: boolean;
  39110. AMBIENTDIRECTUV: number;
  39111. OPACITY: boolean;
  39112. OPACITYDIRECTUV: number;
  39113. OPACITYRGB: boolean;
  39114. REFLECTION: boolean;
  39115. EMISSIVE: boolean;
  39116. EMISSIVEDIRECTUV: number;
  39117. SPECULAR: boolean;
  39118. SPECULARDIRECTUV: number;
  39119. BUMP: boolean;
  39120. BUMPDIRECTUV: number;
  39121. PARALLAX: boolean;
  39122. PARALLAXOCCLUSION: boolean;
  39123. SPECULAROVERALPHA: boolean;
  39124. CLIPPLANE: boolean;
  39125. CLIPPLANE2: boolean;
  39126. CLIPPLANE3: boolean;
  39127. CLIPPLANE4: boolean;
  39128. ALPHATEST: boolean;
  39129. DEPTHPREPASS: boolean;
  39130. ALPHAFROMDIFFUSE: boolean;
  39131. POINTSIZE: boolean;
  39132. FOG: boolean;
  39133. SPECULARTERM: boolean;
  39134. DIFFUSEFRESNEL: boolean;
  39135. OPACITYFRESNEL: boolean;
  39136. REFLECTIONFRESNEL: boolean;
  39137. REFRACTIONFRESNEL: boolean;
  39138. EMISSIVEFRESNEL: boolean;
  39139. FRESNEL: boolean;
  39140. NORMAL: boolean;
  39141. UV1: boolean;
  39142. UV2: boolean;
  39143. VERTEXCOLOR: boolean;
  39144. VERTEXALPHA: boolean;
  39145. NUM_BONE_INFLUENCERS: number;
  39146. BonesPerMesh: number;
  39147. BONETEXTURE: boolean;
  39148. INSTANCES: boolean;
  39149. GLOSSINESS: boolean;
  39150. ROUGHNESS: boolean;
  39151. EMISSIVEASILLUMINATION: boolean;
  39152. LINKEMISSIVEWITHDIFFUSE: boolean;
  39153. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39154. LIGHTMAP: boolean;
  39155. LIGHTMAPDIRECTUV: number;
  39156. OBJECTSPACE_NORMALMAP: boolean;
  39157. USELIGHTMAPASSHADOWMAP: boolean;
  39158. REFLECTIONMAP_3D: boolean;
  39159. REFLECTIONMAP_SPHERICAL: boolean;
  39160. REFLECTIONMAP_PLANAR: boolean;
  39161. REFLECTIONMAP_CUBIC: boolean;
  39162. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39163. REFLECTIONMAP_PROJECTION: boolean;
  39164. REFLECTIONMAP_SKYBOX: boolean;
  39165. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39166. REFLECTIONMAP_EXPLICIT: boolean;
  39167. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39168. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39169. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39170. INVERTCUBICMAP: boolean;
  39171. LOGARITHMICDEPTH: boolean;
  39172. REFRACTION: boolean;
  39173. REFRACTIONMAP_3D: boolean;
  39174. REFLECTIONOVERALPHA: boolean;
  39175. TWOSIDEDLIGHTING: boolean;
  39176. SHADOWFLOAT: boolean;
  39177. MORPHTARGETS: boolean;
  39178. MORPHTARGETS_NORMAL: boolean;
  39179. MORPHTARGETS_TANGENT: boolean;
  39180. MORPHTARGETS_UV: boolean;
  39181. NUM_MORPH_INFLUENCERS: number;
  39182. NONUNIFORMSCALING: boolean;
  39183. PREMULTIPLYALPHA: boolean;
  39184. IMAGEPROCESSING: boolean;
  39185. VIGNETTE: boolean;
  39186. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39187. VIGNETTEBLENDMODEOPAQUE: boolean;
  39188. TONEMAPPING: boolean;
  39189. TONEMAPPING_ACES: boolean;
  39190. CONTRAST: boolean;
  39191. COLORCURVES: boolean;
  39192. COLORGRADING: boolean;
  39193. COLORGRADING3D: boolean;
  39194. SAMPLER3DGREENDEPTH: boolean;
  39195. SAMPLER3DBGRMAP: boolean;
  39196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39197. MULTIVIEW: boolean;
  39198. /**
  39199. * If the reflection texture on this material is in linear color space
  39200. * @hidden
  39201. */
  39202. IS_REFLECTION_LINEAR: boolean;
  39203. /**
  39204. * If the refraction texture on this material is in linear color space
  39205. * @hidden
  39206. */
  39207. IS_REFRACTION_LINEAR: boolean;
  39208. EXPOSURE: boolean;
  39209. constructor();
  39210. setReflectionMode(modeToEnable: string): void;
  39211. }
  39212. /**
  39213. * This is the default material used in Babylon. It is the best trade off between quality
  39214. * and performances.
  39215. * @see http://doc.babylonjs.com/babylon101/materials
  39216. */
  39217. export class StandardMaterial extends PushMaterial {
  39218. private _diffuseTexture;
  39219. /**
  39220. * The basic texture of the material as viewed under a light.
  39221. */
  39222. diffuseTexture: Nullable<BaseTexture>;
  39223. private _ambientTexture;
  39224. /**
  39225. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39226. */
  39227. ambientTexture: Nullable<BaseTexture>;
  39228. private _opacityTexture;
  39229. /**
  39230. * Define the transparency of the material from a texture.
  39231. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39232. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39233. */
  39234. opacityTexture: Nullable<BaseTexture>;
  39235. private _reflectionTexture;
  39236. /**
  39237. * Define the texture used to display the reflection.
  39238. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39239. */
  39240. reflectionTexture: Nullable<BaseTexture>;
  39241. private _emissiveTexture;
  39242. /**
  39243. * Define texture of the material as if self lit.
  39244. * This will be mixed in the final result even in the absence of light.
  39245. */
  39246. emissiveTexture: Nullable<BaseTexture>;
  39247. private _specularTexture;
  39248. /**
  39249. * Define how the color and intensity of the highlight given by the light in the material.
  39250. */
  39251. specularTexture: Nullable<BaseTexture>;
  39252. private _bumpTexture;
  39253. /**
  39254. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39255. * 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.
  39256. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39257. */
  39258. bumpTexture: Nullable<BaseTexture>;
  39259. private _lightmapTexture;
  39260. /**
  39261. * Complex lighting can be computationally expensive to compute at runtime.
  39262. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39263. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39264. */
  39265. lightmapTexture: Nullable<BaseTexture>;
  39266. private _refractionTexture;
  39267. /**
  39268. * Define the texture used to display the refraction.
  39269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39270. */
  39271. refractionTexture: Nullable<BaseTexture>;
  39272. /**
  39273. * The color of the material lit by the environmental background lighting.
  39274. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39275. */
  39276. ambientColor: Color3;
  39277. /**
  39278. * The basic color of the material as viewed under a light.
  39279. */
  39280. diffuseColor: Color3;
  39281. /**
  39282. * Define how the color and intensity of the highlight given by the light in the material.
  39283. */
  39284. specularColor: Color3;
  39285. /**
  39286. * Define the color of the material as if self lit.
  39287. * This will be mixed in the final result even in the absence of light.
  39288. */
  39289. emissiveColor: Color3;
  39290. /**
  39291. * Defines how sharp are the highlights in the material.
  39292. * The bigger the value the sharper giving a more glossy feeling to the result.
  39293. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39294. */
  39295. specularPower: number;
  39296. private _useAlphaFromDiffuseTexture;
  39297. /**
  39298. * Does the transparency come from the diffuse texture alpha channel.
  39299. */
  39300. useAlphaFromDiffuseTexture: boolean;
  39301. private _useEmissiveAsIllumination;
  39302. /**
  39303. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39304. */
  39305. useEmissiveAsIllumination: boolean;
  39306. private _linkEmissiveWithDiffuse;
  39307. /**
  39308. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39309. * the emissive level when the final color is close to one.
  39310. */
  39311. linkEmissiveWithDiffuse: boolean;
  39312. private _useSpecularOverAlpha;
  39313. /**
  39314. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39315. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39316. */
  39317. useSpecularOverAlpha: boolean;
  39318. private _useReflectionOverAlpha;
  39319. /**
  39320. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39321. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39322. */
  39323. useReflectionOverAlpha: boolean;
  39324. private _disableLighting;
  39325. /**
  39326. * Does lights from the scene impacts this material.
  39327. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39328. */
  39329. disableLighting: boolean;
  39330. private _useObjectSpaceNormalMap;
  39331. /**
  39332. * Allows using an object space normal map (instead of tangent space).
  39333. */
  39334. useObjectSpaceNormalMap: boolean;
  39335. private _useParallax;
  39336. /**
  39337. * Is parallax enabled or not.
  39338. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39339. */
  39340. useParallax: boolean;
  39341. private _useParallaxOcclusion;
  39342. /**
  39343. * Is parallax occlusion enabled or not.
  39344. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39346. */
  39347. useParallaxOcclusion: boolean;
  39348. /**
  39349. * 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.
  39350. */
  39351. parallaxScaleBias: number;
  39352. private _roughness;
  39353. /**
  39354. * Helps to define how blurry the reflections should appears in the material.
  39355. */
  39356. roughness: number;
  39357. /**
  39358. * In case of refraction, define the value of the index of refraction.
  39359. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39360. */
  39361. indexOfRefraction: number;
  39362. /**
  39363. * Invert the refraction texture alongside the y axis.
  39364. * It can be useful with procedural textures or probe for instance.
  39365. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39366. */
  39367. invertRefractionY: boolean;
  39368. /**
  39369. * Defines the alpha limits in alpha test mode.
  39370. */
  39371. alphaCutOff: number;
  39372. private _useLightmapAsShadowmap;
  39373. /**
  39374. * In case of light mapping, define whether the map contains light or shadow informations.
  39375. */
  39376. useLightmapAsShadowmap: boolean;
  39377. private _diffuseFresnelParameters;
  39378. /**
  39379. * Define the diffuse fresnel parameters of the material.
  39380. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39381. */
  39382. diffuseFresnelParameters: FresnelParameters;
  39383. private _opacityFresnelParameters;
  39384. /**
  39385. * Define the opacity fresnel parameters of the material.
  39386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39387. */
  39388. opacityFresnelParameters: FresnelParameters;
  39389. private _reflectionFresnelParameters;
  39390. /**
  39391. * Define the reflection fresnel parameters of the material.
  39392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39393. */
  39394. reflectionFresnelParameters: FresnelParameters;
  39395. private _refractionFresnelParameters;
  39396. /**
  39397. * Define the refraction fresnel parameters of the material.
  39398. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39399. */
  39400. refractionFresnelParameters: FresnelParameters;
  39401. private _emissiveFresnelParameters;
  39402. /**
  39403. * Define the emissive fresnel parameters of the material.
  39404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39405. */
  39406. emissiveFresnelParameters: FresnelParameters;
  39407. private _useReflectionFresnelFromSpecular;
  39408. /**
  39409. * If true automatically deducts the fresnels values from the material specularity.
  39410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39411. */
  39412. useReflectionFresnelFromSpecular: boolean;
  39413. private _useGlossinessFromSpecularMapAlpha;
  39414. /**
  39415. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39416. */
  39417. useGlossinessFromSpecularMapAlpha: boolean;
  39418. private _maxSimultaneousLights;
  39419. /**
  39420. * Defines the maximum number of lights that can be used in the material
  39421. */
  39422. maxSimultaneousLights: number;
  39423. private _invertNormalMapX;
  39424. /**
  39425. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39426. */
  39427. invertNormalMapX: boolean;
  39428. private _invertNormalMapY;
  39429. /**
  39430. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39431. */
  39432. invertNormalMapY: boolean;
  39433. private _twoSidedLighting;
  39434. /**
  39435. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39436. */
  39437. twoSidedLighting: boolean;
  39438. /**
  39439. * Default configuration related to image processing available in the standard Material.
  39440. */
  39441. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39442. /**
  39443. * Gets the image processing configuration used either in this material.
  39444. */
  39445. /**
  39446. * Sets the Default image processing configuration used either in the this material.
  39447. *
  39448. * If sets to null, the scene one is in use.
  39449. */
  39450. imageProcessingConfiguration: ImageProcessingConfiguration;
  39451. /**
  39452. * Keep track of the image processing observer to allow dispose and replace.
  39453. */
  39454. private _imageProcessingObserver;
  39455. /**
  39456. * Attaches a new image processing configuration to the Standard Material.
  39457. * @param configuration
  39458. */
  39459. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39460. /**
  39461. * Gets wether the color curves effect is enabled.
  39462. */
  39463. /**
  39464. * Sets wether the color curves effect is enabled.
  39465. */
  39466. cameraColorCurvesEnabled: boolean;
  39467. /**
  39468. * Gets wether the color grading effect is enabled.
  39469. */
  39470. /**
  39471. * Gets wether the color grading effect is enabled.
  39472. */
  39473. cameraColorGradingEnabled: boolean;
  39474. /**
  39475. * Gets wether tonemapping is enabled or not.
  39476. */
  39477. /**
  39478. * Sets wether tonemapping is enabled or not
  39479. */
  39480. cameraToneMappingEnabled: boolean;
  39481. /**
  39482. * The camera exposure used on this material.
  39483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39484. * This corresponds to a photographic exposure.
  39485. */
  39486. /**
  39487. * The camera exposure used on this material.
  39488. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39489. * This corresponds to a photographic exposure.
  39490. */
  39491. cameraExposure: number;
  39492. /**
  39493. * Gets The camera contrast used on this material.
  39494. */
  39495. /**
  39496. * Sets The camera contrast used on this material.
  39497. */
  39498. cameraContrast: number;
  39499. /**
  39500. * Gets the Color Grading 2D Lookup Texture.
  39501. */
  39502. /**
  39503. * Sets the Color Grading 2D Lookup Texture.
  39504. */
  39505. cameraColorGradingTexture: Nullable<BaseTexture>;
  39506. /**
  39507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39509. * 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;
  39510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39511. */
  39512. /**
  39513. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39514. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39515. * 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;
  39516. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39517. */
  39518. cameraColorCurves: Nullable<ColorCurves>;
  39519. /**
  39520. * Custom callback helping to override the default shader used in the material.
  39521. */
  39522. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39523. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39524. protected _worldViewProjectionMatrix: Matrix;
  39525. protected _globalAmbientColor: Color3;
  39526. protected _useLogarithmicDepth: boolean;
  39527. /**
  39528. * Instantiates a new standard material.
  39529. * This is the default material used in Babylon. It is the best trade off between quality
  39530. * and performances.
  39531. * @see http://doc.babylonjs.com/babylon101/materials
  39532. * @param name Define the name of the material in the scene
  39533. * @param scene Define the scene the material belong to
  39534. */
  39535. constructor(name: string, scene: Scene);
  39536. /**
  39537. * Gets a boolean indicating that current material needs to register RTT
  39538. */
  39539. readonly hasRenderTargetTextures: boolean;
  39540. /**
  39541. * Gets the current class name of the material e.g. "StandardMaterial"
  39542. * Mainly use in serialization.
  39543. * @returns the class name
  39544. */
  39545. getClassName(): string;
  39546. /**
  39547. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39548. * You can try switching to logarithmic depth.
  39549. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39550. */
  39551. useLogarithmicDepth: boolean;
  39552. /**
  39553. * Specifies if the material will require alpha blending
  39554. * @returns a boolean specifying if alpha blending is needed
  39555. */
  39556. needAlphaBlending(): boolean;
  39557. /**
  39558. * Specifies if this material should be rendered in alpha test mode
  39559. * @returns a boolean specifying if an alpha test is needed.
  39560. */
  39561. needAlphaTesting(): boolean;
  39562. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39563. /**
  39564. * Get the texture used for alpha test purpose.
  39565. * @returns the diffuse texture in case of the standard material.
  39566. */
  39567. getAlphaTestTexture(): Nullable<BaseTexture>;
  39568. /**
  39569. * Get if the submesh is ready to be used and all its information available.
  39570. * Child classes can use it to update shaders
  39571. * @param mesh defines the mesh to check
  39572. * @param subMesh defines which submesh to check
  39573. * @param useInstances specifies that instances should be used
  39574. * @returns a boolean indicating that the submesh is ready or not
  39575. */
  39576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39577. /**
  39578. * Builds the material UBO layouts.
  39579. * Used internally during the effect preparation.
  39580. */
  39581. buildUniformLayout(): void;
  39582. /**
  39583. * Unbinds the material from the mesh
  39584. */
  39585. unbind(): void;
  39586. /**
  39587. * Binds the submesh to this material by preparing the effect and shader to draw
  39588. * @param world defines the world transformation matrix
  39589. * @param mesh defines the mesh containing the submesh
  39590. * @param subMesh defines the submesh to bind the material to
  39591. */
  39592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39593. /**
  39594. * Get the list of animatables in the material.
  39595. * @returns the list of animatables object used in the material
  39596. */
  39597. getAnimatables(): IAnimatable[];
  39598. /**
  39599. * Gets the active textures from the material
  39600. * @returns an array of textures
  39601. */
  39602. getActiveTextures(): BaseTexture[];
  39603. /**
  39604. * Specifies if the material uses a texture
  39605. * @param texture defines the texture to check against the material
  39606. * @returns a boolean specifying if the material uses the texture
  39607. */
  39608. hasTexture(texture: BaseTexture): boolean;
  39609. /**
  39610. * Disposes the material
  39611. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39612. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39613. */
  39614. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39615. /**
  39616. * Makes a duplicate of the material, and gives it a new name
  39617. * @param name defines the new name for the duplicated material
  39618. * @returns the cloned material
  39619. */
  39620. clone(name: string): StandardMaterial;
  39621. /**
  39622. * Serializes this material in a JSON representation
  39623. * @returns the serialized material object
  39624. */
  39625. serialize(): any;
  39626. /**
  39627. * Creates a standard material from parsed material data
  39628. * @param source defines the JSON representation of the material
  39629. * @param scene defines the hosting scene
  39630. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39631. * @returns a new standard material
  39632. */
  39633. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39634. /**
  39635. * Are diffuse textures enabled in the application.
  39636. */
  39637. static DiffuseTextureEnabled: boolean;
  39638. /**
  39639. * Are ambient textures enabled in the application.
  39640. */
  39641. static AmbientTextureEnabled: boolean;
  39642. /**
  39643. * Are opacity textures enabled in the application.
  39644. */
  39645. static OpacityTextureEnabled: boolean;
  39646. /**
  39647. * Are reflection textures enabled in the application.
  39648. */
  39649. static ReflectionTextureEnabled: boolean;
  39650. /**
  39651. * Are emissive textures enabled in the application.
  39652. */
  39653. static EmissiveTextureEnabled: boolean;
  39654. /**
  39655. * Are specular textures enabled in the application.
  39656. */
  39657. static SpecularTextureEnabled: boolean;
  39658. /**
  39659. * Are bump textures enabled in the application.
  39660. */
  39661. static BumpTextureEnabled: boolean;
  39662. /**
  39663. * Are lightmap textures enabled in the application.
  39664. */
  39665. static LightmapTextureEnabled: boolean;
  39666. /**
  39667. * Are refraction textures enabled in the application.
  39668. */
  39669. static RefractionTextureEnabled: boolean;
  39670. /**
  39671. * Are color grading textures enabled in the application.
  39672. */
  39673. static ColorGradingTextureEnabled: boolean;
  39674. /**
  39675. * Are fresnels enabled in the application.
  39676. */
  39677. static FresnelEnabled: boolean;
  39678. }
  39679. }
  39680. declare module BABYLON {
  39681. /**
  39682. * A class extending Texture allowing drawing on a texture
  39683. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39684. */
  39685. export class DynamicTexture extends Texture {
  39686. private _generateMipMaps;
  39687. private _canvas;
  39688. private _context;
  39689. private _engine;
  39690. /**
  39691. * Creates a DynamicTexture
  39692. * @param name defines the name of the texture
  39693. * @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
  39694. * @param scene defines the scene where you want the texture
  39695. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39696. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39697. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39698. */
  39699. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39700. /**
  39701. * Get the current class name of the texture useful for serialization or dynamic coding.
  39702. * @returns "DynamicTexture"
  39703. */
  39704. getClassName(): string;
  39705. /**
  39706. * Gets the current state of canRescale
  39707. */
  39708. readonly canRescale: boolean;
  39709. private _recreate;
  39710. /**
  39711. * Scales the texture
  39712. * @param ratio the scale factor to apply to both width and height
  39713. */
  39714. scale(ratio: number): void;
  39715. /**
  39716. * Resizes the texture
  39717. * @param width the new width
  39718. * @param height the new height
  39719. */
  39720. scaleTo(width: number, height: number): void;
  39721. /**
  39722. * Gets the context of the canvas used by the texture
  39723. * @returns the canvas context of the dynamic texture
  39724. */
  39725. getContext(): CanvasRenderingContext2D;
  39726. /**
  39727. * Clears the texture
  39728. */
  39729. clear(): void;
  39730. /**
  39731. * Updates the texture
  39732. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39733. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39734. */
  39735. update(invertY?: boolean, premulAlpha?: boolean): void;
  39736. /**
  39737. * Draws text onto the texture
  39738. * @param text defines the text to be drawn
  39739. * @param x defines the placement of the text from the left
  39740. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39741. * @param font defines the font to be used with font-style, font-size, font-name
  39742. * @param color defines the color used for the text
  39743. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39744. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39745. * @param update defines whether texture is immediately update (default is true)
  39746. */
  39747. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39748. /**
  39749. * Clones the texture
  39750. * @returns the clone of the texture.
  39751. */
  39752. clone(): DynamicTexture;
  39753. /**
  39754. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39755. * @returns a serialized dynamic texture object
  39756. */
  39757. serialize(): any;
  39758. /** @hidden */
  39759. _rebuild(): void;
  39760. }
  39761. }
  39762. declare module BABYLON {
  39763. /** @hidden */
  39764. export var imageProcessingPixelShader: {
  39765. name: string;
  39766. shader: string;
  39767. };
  39768. }
  39769. declare module BABYLON {
  39770. /**
  39771. * ImageProcessingPostProcess
  39772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39773. */
  39774. export class ImageProcessingPostProcess extends PostProcess {
  39775. /**
  39776. * Default configuration related to image processing available in the PBR Material.
  39777. */
  39778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39779. /**
  39780. * Gets the image processing configuration used either in this material.
  39781. */
  39782. /**
  39783. * Sets the Default image processing configuration used either in the this material.
  39784. *
  39785. * If sets to null, the scene one is in use.
  39786. */
  39787. imageProcessingConfiguration: ImageProcessingConfiguration;
  39788. /**
  39789. * Keep track of the image processing observer to allow dispose and replace.
  39790. */
  39791. private _imageProcessingObserver;
  39792. /**
  39793. * Attaches a new image processing configuration to the PBR Material.
  39794. * @param configuration
  39795. */
  39796. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39797. /**
  39798. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39799. */
  39800. /**
  39801. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39802. */
  39803. colorCurves: Nullable<ColorCurves>;
  39804. /**
  39805. * Gets wether the color curves effect is enabled.
  39806. */
  39807. /**
  39808. * Sets wether the color curves effect is enabled.
  39809. */
  39810. colorCurvesEnabled: boolean;
  39811. /**
  39812. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39813. */
  39814. /**
  39815. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39816. */
  39817. colorGradingTexture: Nullable<BaseTexture>;
  39818. /**
  39819. * Gets wether the color grading effect is enabled.
  39820. */
  39821. /**
  39822. * Gets wether the color grading effect is enabled.
  39823. */
  39824. colorGradingEnabled: boolean;
  39825. /**
  39826. * Gets exposure used in the effect.
  39827. */
  39828. /**
  39829. * Sets exposure used in the effect.
  39830. */
  39831. exposure: number;
  39832. /**
  39833. * Gets wether tonemapping is enabled or not.
  39834. */
  39835. /**
  39836. * Sets wether tonemapping is enabled or not
  39837. */
  39838. toneMappingEnabled: boolean;
  39839. /**
  39840. * Gets the type of tone mapping effect.
  39841. */
  39842. /**
  39843. * Sets the type of tone mapping effect.
  39844. */
  39845. toneMappingType: number;
  39846. /**
  39847. * Gets contrast used in the effect.
  39848. */
  39849. /**
  39850. * Sets contrast used in the effect.
  39851. */
  39852. contrast: number;
  39853. /**
  39854. * Gets Vignette stretch size.
  39855. */
  39856. /**
  39857. * Sets Vignette stretch size.
  39858. */
  39859. vignetteStretch: number;
  39860. /**
  39861. * Gets Vignette centre X Offset.
  39862. */
  39863. /**
  39864. * Sets Vignette centre X Offset.
  39865. */
  39866. vignetteCentreX: number;
  39867. /**
  39868. * Gets Vignette centre Y Offset.
  39869. */
  39870. /**
  39871. * Sets Vignette centre Y Offset.
  39872. */
  39873. vignetteCentreY: number;
  39874. /**
  39875. * Gets Vignette weight or intensity of the vignette effect.
  39876. */
  39877. /**
  39878. * Sets Vignette weight or intensity of the vignette effect.
  39879. */
  39880. vignetteWeight: number;
  39881. /**
  39882. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39883. * if vignetteEnabled is set to true.
  39884. */
  39885. /**
  39886. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39887. * if vignetteEnabled is set to true.
  39888. */
  39889. vignetteColor: Color4;
  39890. /**
  39891. * Gets Camera field of view used by the Vignette effect.
  39892. */
  39893. /**
  39894. * Sets Camera field of view used by the Vignette effect.
  39895. */
  39896. vignetteCameraFov: number;
  39897. /**
  39898. * Gets the vignette blend mode allowing different kind of effect.
  39899. */
  39900. /**
  39901. * Sets the vignette blend mode allowing different kind of effect.
  39902. */
  39903. vignetteBlendMode: number;
  39904. /**
  39905. * Gets wether the vignette effect is enabled.
  39906. */
  39907. /**
  39908. * Sets wether the vignette effect is enabled.
  39909. */
  39910. vignetteEnabled: boolean;
  39911. private _fromLinearSpace;
  39912. /**
  39913. * Gets wether the input of the processing is in Gamma or Linear Space.
  39914. */
  39915. /**
  39916. * Sets wether the input of the processing is in Gamma or Linear Space.
  39917. */
  39918. fromLinearSpace: boolean;
  39919. /**
  39920. * Defines cache preventing GC.
  39921. */
  39922. private _defines;
  39923. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39924. /**
  39925. * "ImageProcessingPostProcess"
  39926. * @returns "ImageProcessingPostProcess"
  39927. */
  39928. getClassName(): string;
  39929. protected _updateParameters(): void;
  39930. dispose(camera?: Camera): void;
  39931. }
  39932. }
  39933. declare module BABYLON {
  39934. /**
  39935. * Class containing static functions to help procedurally build meshes
  39936. */
  39937. export class GroundBuilder {
  39938. /**
  39939. * Creates a ground mesh
  39940. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39941. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39943. * @param name defines the name of the mesh
  39944. * @param options defines the options used to create the mesh
  39945. * @param scene defines the hosting scene
  39946. * @returns the ground mesh
  39947. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39948. */
  39949. static CreateGround(name: string, options: {
  39950. width?: number;
  39951. height?: number;
  39952. subdivisions?: number;
  39953. subdivisionsX?: number;
  39954. subdivisionsY?: number;
  39955. updatable?: boolean;
  39956. }, scene: any): Mesh;
  39957. /**
  39958. * Creates a tiled ground mesh
  39959. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39960. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39961. * * 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
  39962. * * 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
  39963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39964. * @param name defines the name of the mesh
  39965. * @param options defines the options used to create the mesh
  39966. * @param scene defines the hosting scene
  39967. * @returns the tiled ground mesh
  39968. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39969. */
  39970. static CreateTiledGround(name: string, options: {
  39971. xmin: number;
  39972. zmin: number;
  39973. xmax: number;
  39974. zmax: number;
  39975. subdivisions?: {
  39976. w: number;
  39977. h: number;
  39978. };
  39979. precision?: {
  39980. w: number;
  39981. h: number;
  39982. };
  39983. updatable?: boolean;
  39984. }, scene?: Nullable<Scene>): Mesh;
  39985. /**
  39986. * Creates a ground mesh from a height map
  39987. * * The parameter `url` sets the URL of the height map image resource.
  39988. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39989. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39990. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39991. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39992. * * 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.
  39993. * * 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).
  39994. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39996. * @param name defines the name of the mesh
  39997. * @param url defines the url to the height map
  39998. * @param options defines the options used to create the mesh
  39999. * @param scene defines the hosting scene
  40000. * @returns the ground mesh
  40001. * @see https://doc.babylonjs.com/babylon101/height_map
  40002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40003. */
  40004. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40005. width?: number;
  40006. height?: number;
  40007. subdivisions?: number;
  40008. minHeight?: number;
  40009. maxHeight?: number;
  40010. colorFilter?: Color3;
  40011. alphaFilter?: number;
  40012. updatable?: boolean;
  40013. onReady?: (mesh: GroundMesh) => void;
  40014. }, scene?: Nullable<Scene>): GroundMesh;
  40015. }
  40016. }
  40017. declare module BABYLON {
  40018. /**
  40019. * Class containing static functions to help procedurally build meshes
  40020. */
  40021. export class TorusBuilder {
  40022. /**
  40023. * Creates a torus mesh
  40024. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40025. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40026. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40028. * * 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
  40029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40030. * @param name defines the name of the mesh
  40031. * @param options defines the options used to create the mesh
  40032. * @param scene defines the hosting scene
  40033. * @returns the torus mesh
  40034. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40035. */
  40036. static CreateTorus(name: string, options: {
  40037. diameter?: number;
  40038. thickness?: number;
  40039. tessellation?: number;
  40040. updatable?: boolean;
  40041. sideOrientation?: number;
  40042. frontUVs?: Vector4;
  40043. backUVs?: Vector4;
  40044. }, scene: any): Mesh;
  40045. }
  40046. }
  40047. declare module BABYLON {
  40048. /**
  40049. * Class containing static functions to help procedurally build meshes
  40050. */
  40051. export class CylinderBuilder {
  40052. /**
  40053. * Creates a cylinder or a cone mesh
  40054. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40055. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40056. * * 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.
  40057. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40058. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40059. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40060. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40061. * * 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).
  40062. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40063. * * 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).
  40064. * * 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
  40065. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40066. * * 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
  40067. * * 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.
  40068. * * If `enclose` is false, a ring surface is one element.
  40069. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40070. * * 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
  40071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40072. * * 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
  40073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40074. * @param name defines the name of the mesh
  40075. * @param options defines the options used to create the mesh
  40076. * @param scene defines the hosting scene
  40077. * @returns the cylinder mesh
  40078. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40079. */
  40080. static CreateCylinder(name: string, options: {
  40081. height?: number;
  40082. diameterTop?: number;
  40083. diameterBottom?: number;
  40084. diameter?: number;
  40085. tessellation?: number;
  40086. subdivisions?: number;
  40087. arc?: number;
  40088. faceColors?: Color4[];
  40089. faceUV?: Vector4[];
  40090. updatable?: boolean;
  40091. hasRings?: boolean;
  40092. enclose?: boolean;
  40093. cap?: number;
  40094. sideOrientation?: number;
  40095. frontUVs?: Vector4;
  40096. backUVs?: Vector4;
  40097. }, scene: any): Mesh;
  40098. }
  40099. }
  40100. declare module BABYLON {
  40101. /**
  40102. * Options to modify the vr teleportation behavior.
  40103. */
  40104. export interface VRTeleportationOptions {
  40105. /**
  40106. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40107. */
  40108. floorMeshName?: string;
  40109. /**
  40110. * A list of meshes to be used as the teleportation floor. (default: empty)
  40111. */
  40112. floorMeshes?: Mesh[];
  40113. }
  40114. /**
  40115. * Options to modify the vr experience helper's behavior.
  40116. */
  40117. export interface VRExperienceHelperOptions extends WebVROptions {
  40118. /**
  40119. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40120. */
  40121. createDeviceOrientationCamera?: boolean;
  40122. /**
  40123. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40124. */
  40125. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40126. /**
  40127. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40128. */
  40129. laserToggle?: boolean;
  40130. /**
  40131. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40132. */
  40133. floorMeshes?: Mesh[];
  40134. /**
  40135. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40136. */
  40137. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40138. }
  40139. /**
  40140. * Event containing information after VR has been entered
  40141. */
  40142. export class OnAfterEnteringVRObservableEvent {
  40143. /**
  40144. * If entering vr was successful
  40145. */
  40146. success: boolean;
  40147. }
  40148. /**
  40149. * Helps to quickly add VR support to an existing scene.
  40150. * See http://doc.babylonjs.com/how_to/webvr_helper
  40151. */
  40152. export class VRExperienceHelper {
  40153. /** Options to modify the vr experience helper's behavior. */
  40154. webVROptions: VRExperienceHelperOptions;
  40155. private _scene;
  40156. private _position;
  40157. private _btnVR;
  40158. private _btnVRDisplayed;
  40159. private _webVRsupported;
  40160. private _webVRready;
  40161. private _webVRrequesting;
  40162. private _webVRpresenting;
  40163. private _hasEnteredVR;
  40164. private _fullscreenVRpresenting;
  40165. private _canvas;
  40166. private _webVRCamera;
  40167. private _vrDeviceOrientationCamera;
  40168. private _deviceOrientationCamera;
  40169. private _existingCamera;
  40170. private _onKeyDown;
  40171. private _onVrDisplayPresentChange;
  40172. private _onVRDisplayChanged;
  40173. private _onVRRequestPresentStart;
  40174. private _onVRRequestPresentComplete;
  40175. /**
  40176. * Observable raised right before entering VR.
  40177. */
  40178. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40179. /**
  40180. * Observable raised when entering VR has completed.
  40181. */
  40182. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40183. /**
  40184. * Observable raised when exiting VR.
  40185. */
  40186. onExitingVRObservable: Observable<VRExperienceHelper>;
  40187. /**
  40188. * Observable raised when controller mesh is loaded.
  40189. */
  40190. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40191. /** Return this.onEnteringVRObservable
  40192. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40193. */
  40194. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40195. /** Return this.onExitingVRObservable
  40196. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40197. */
  40198. readonly onExitingVR: Observable<VRExperienceHelper>;
  40199. /** Return this.onControllerMeshLoadedObservable
  40200. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40201. */
  40202. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40203. private _rayLength;
  40204. private _useCustomVRButton;
  40205. private _teleportationRequested;
  40206. private _teleportActive;
  40207. private _floorMeshName;
  40208. private _floorMeshesCollection;
  40209. private _rotationAllowed;
  40210. private _teleportBackwardsVector;
  40211. private _teleportationTarget;
  40212. private _isDefaultTeleportationTarget;
  40213. private _postProcessMove;
  40214. private _teleportationFillColor;
  40215. private _teleportationBorderColor;
  40216. private _rotationAngle;
  40217. private _haloCenter;
  40218. private _cameraGazer;
  40219. private _padSensibilityUp;
  40220. private _padSensibilityDown;
  40221. private _leftController;
  40222. private _rightController;
  40223. /**
  40224. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40225. */
  40226. onNewMeshSelected: Observable<AbstractMesh>;
  40227. /**
  40228. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40229. */
  40230. onNewMeshPicked: Observable<PickingInfo>;
  40231. private _circleEase;
  40232. /**
  40233. * Observable raised before camera teleportation
  40234. */
  40235. onBeforeCameraTeleport: Observable<Vector3>;
  40236. /**
  40237. * Observable raised after camera teleportation
  40238. */
  40239. onAfterCameraTeleport: Observable<Vector3>;
  40240. /**
  40241. * Observable raised when current selected mesh gets unselected
  40242. */
  40243. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40244. private _raySelectionPredicate;
  40245. /**
  40246. * To be optionaly changed by user to define custom ray selection
  40247. */
  40248. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40249. /**
  40250. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40251. */
  40252. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40253. /**
  40254. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40255. */
  40256. teleportationEnabled: boolean;
  40257. private _defaultHeight;
  40258. private _teleportationInitialized;
  40259. private _interactionsEnabled;
  40260. private _interactionsRequested;
  40261. private _displayGaze;
  40262. private _displayLaserPointer;
  40263. /**
  40264. * The mesh used to display where the user is going to teleport.
  40265. */
  40266. /**
  40267. * Sets the mesh to be used to display where the user is going to teleport.
  40268. */
  40269. teleportationTarget: Mesh;
  40270. /**
  40271. * 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
  40272. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40273. * See http://doc.babylonjs.com/resources/baking_transformations
  40274. */
  40275. gazeTrackerMesh: Mesh;
  40276. /**
  40277. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40278. */
  40279. updateGazeTrackerScale: boolean;
  40280. /**
  40281. * If the gaze trackers color should be updated when selecting meshes
  40282. */
  40283. updateGazeTrackerColor: boolean;
  40284. /**
  40285. * The gaze tracking mesh corresponding to the left controller
  40286. */
  40287. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40288. /**
  40289. * The gaze tracking mesh corresponding to the right controller
  40290. */
  40291. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40292. /**
  40293. * If the ray of the gaze should be displayed.
  40294. */
  40295. /**
  40296. * Sets if the ray of the gaze should be displayed.
  40297. */
  40298. displayGaze: boolean;
  40299. /**
  40300. * If the ray of the LaserPointer should be displayed.
  40301. */
  40302. /**
  40303. * Sets if the ray of the LaserPointer should be displayed.
  40304. */
  40305. displayLaserPointer: boolean;
  40306. /**
  40307. * The deviceOrientationCamera used as the camera when not in VR.
  40308. */
  40309. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40310. /**
  40311. * Based on the current WebVR support, returns the current VR camera used.
  40312. */
  40313. readonly currentVRCamera: Nullable<Camera>;
  40314. /**
  40315. * The webVRCamera which is used when in VR.
  40316. */
  40317. readonly webVRCamera: WebVRFreeCamera;
  40318. /**
  40319. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40320. */
  40321. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40322. private readonly _teleportationRequestInitiated;
  40323. /**
  40324. * Defines wether or not Pointer lock should be requested when switching to
  40325. * full screen.
  40326. */
  40327. requestPointerLockOnFullScreen: boolean;
  40328. /**
  40329. * Instantiates a VRExperienceHelper.
  40330. * Helps to quickly add VR support to an existing scene.
  40331. * @param scene The scene the VRExperienceHelper belongs to.
  40332. * @param webVROptions Options to modify the vr experience helper's behavior.
  40333. */
  40334. constructor(scene: Scene,
  40335. /** Options to modify the vr experience helper's behavior. */
  40336. webVROptions?: VRExperienceHelperOptions);
  40337. private _onDefaultMeshLoaded;
  40338. private _onResize;
  40339. private _onFullscreenChange;
  40340. /**
  40341. * Gets a value indicating if we are currently in VR mode.
  40342. */
  40343. readonly isInVRMode: boolean;
  40344. private onVrDisplayPresentChange;
  40345. private onVRDisplayChanged;
  40346. private moveButtonToBottomRight;
  40347. private displayVRButton;
  40348. private updateButtonVisibility;
  40349. private _cachedAngularSensibility;
  40350. /**
  40351. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40352. * Otherwise, will use the fullscreen API.
  40353. */
  40354. enterVR(): void;
  40355. /**
  40356. * Attempt to exit VR, or fullscreen.
  40357. */
  40358. exitVR(): void;
  40359. /**
  40360. * The position of the vr experience helper.
  40361. */
  40362. /**
  40363. * Sets the position of the vr experience helper.
  40364. */
  40365. position: Vector3;
  40366. /**
  40367. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40368. */
  40369. enableInteractions(): void;
  40370. private readonly _noControllerIsActive;
  40371. private beforeRender;
  40372. private _isTeleportationFloor;
  40373. /**
  40374. * Adds a floor mesh to be used for teleportation.
  40375. * @param floorMesh the mesh to be used for teleportation.
  40376. */
  40377. addFloorMesh(floorMesh: Mesh): void;
  40378. /**
  40379. * Removes a floor mesh from being used for teleportation.
  40380. * @param floorMesh the mesh to be removed.
  40381. */
  40382. removeFloorMesh(floorMesh: Mesh): void;
  40383. /**
  40384. * Enables interactions and teleportation using the VR controllers and gaze.
  40385. * @param vrTeleportationOptions options to modify teleportation behavior.
  40386. */
  40387. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40388. private _onNewGamepadConnected;
  40389. private _tryEnableInteractionOnController;
  40390. private _onNewGamepadDisconnected;
  40391. private _enableInteractionOnController;
  40392. private _checkTeleportWithRay;
  40393. private _checkRotate;
  40394. private _checkTeleportBackwards;
  40395. private _enableTeleportationOnController;
  40396. private _createTeleportationCircles;
  40397. private _displayTeleportationTarget;
  40398. private _hideTeleportationTarget;
  40399. private _rotateCamera;
  40400. private _moveTeleportationSelectorTo;
  40401. private _workingVector;
  40402. private _workingQuaternion;
  40403. private _workingMatrix;
  40404. /**
  40405. * Teleports the users feet to the desired location
  40406. * @param location The location where the user's feet should be placed
  40407. */
  40408. teleportCamera(location: Vector3): void;
  40409. private _convertNormalToDirectionOfRay;
  40410. private _castRayAndSelectObject;
  40411. private _notifySelectedMeshUnselected;
  40412. /**
  40413. * Sets the color of the laser ray from the vr controllers.
  40414. * @param color new color for the ray.
  40415. */
  40416. changeLaserColor(color: Color3): void;
  40417. /**
  40418. * Sets the color of the ray from the vr headsets gaze.
  40419. * @param color new color for the ray.
  40420. */
  40421. changeGazeColor(color: Color3): void;
  40422. /**
  40423. * Exits VR and disposes of the vr experience helper
  40424. */
  40425. dispose(): void;
  40426. /**
  40427. * Gets the name of the VRExperienceHelper class
  40428. * @returns "VRExperienceHelper"
  40429. */
  40430. getClassName(): string;
  40431. }
  40432. }
  40433. declare module BABYLON {
  40434. /**
  40435. * Manages an XRSession
  40436. * @see https://doc.babylonjs.com/how_to/webxr
  40437. */
  40438. export class WebXRSessionManager implements IDisposable {
  40439. private scene;
  40440. /**
  40441. * Fires every time a new xrFrame arrives which can be used to update the camera
  40442. */
  40443. onXRFrameObservable: Observable<any>;
  40444. /**
  40445. * Fires when the xr session is ended either by the device or manually done
  40446. */
  40447. onXRSessionEnded: Observable<any>;
  40448. /** @hidden */
  40449. _xrSession: XRSession;
  40450. /** @hidden */
  40451. _frameOfReference: XRFrameOfReference;
  40452. /** @hidden */
  40453. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40454. /** @hidden */
  40455. _currentXRFrame: Nullable<XRFrame>;
  40456. private _xrNavigator;
  40457. private _xrDevice;
  40458. private _tmpMatrix;
  40459. /**
  40460. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40461. * @param scene The scene which the session should be created for
  40462. */
  40463. constructor(scene: Scene);
  40464. /**
  40465. * Initializes the manager
  40466. * After initialization enterXR can be called to start an XR session
  40467. * @returns Promise which resolves after it is initialized
  40468. */
  40469. initializeAsync(): Promise<void>;
  40470. /**
  40471. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40472. * @param sessionCreationOptions xr options to create the session with
  40473. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40474. * @returns Promise which resolves after it enters XR
  40475. */
  40476. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40477. /**
  40478. * Stops the xrSession and restores the renderloop
  40479. * @returns Promise which resolves after it exits XR
  40480. */
  40481. exitXRAsync(): Promise<void>;
  40482. /**
  40483. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40484. * @param ray ray to cast into the environment
  40485. * @returns Promise which resolves with a collision point in the environment if it exists
  40486. */
  40487. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40488. /**
  40489. * Checks if a session would be supported for the creation options specified
  40490. * @param options creation options to check if they are supported
  40491. * @returns true if supported
  40492. */
  40493. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40494. /**
  40495. * @hidden
  40496. * Converts the render layer of xrSession to a render target
  40497. * @param session session to create render target for
  40498. * @param scene scene the new render target should be created for
  40499. */
  40500. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40501. /**
  40502. * Disposes of the session manager
  40503. */
  40504. dispose(): void;
  40505. }
  40506. }
  40507. declare module BABYLON {
  40508. /**
  40509. * WebXR Camera which holds the views for the xrSession
  40510. * @see https://doc.babylonjs.com/how_to/webxr
  40511. */
  40512. export class WebXRCamera extends FreeCamera {
  40513. private static _TmpMatrix;
  40514. /**
  40515. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40516. * @param name the name of the camera
  40517. * @param scene the scene to add the camera to
  40518. */
  40519. constructor(name: string, scene: Scene);
  40520. private _updateNumberOfRigCameras;
  40521. /** @hidden */
  40522. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40523. /**
  40524. * Updates the cameras position from the current pose information of the XR session
  40525. * @param xrSessionManager the session containing pose information
  40526. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40527. */
  40528. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40529. }
  40530. }
  40531. declare module BABYLON {
  40532. /**
  40533. * States of the webXR experience
  40534. */
  40535. export enum WebXRState {
  40536. /**
  40537. * Transitioning to being in XR mode
  40538. */
  40539. ENTERING_XR = 0,
  40540. /**
  40541. * Transitioning to non XR mode
  40542. */
  40543. EXITING_XR = 1,
  40544. /**
  40545. * In XR mode and presenting
  40546. */
  40547. IN_XR = 2,
  40548. /**
  40549. * Not entered XR mode
  40550. */
  40551. NOT_IN_XR = 3
  40552. }
  40553. /**
  40554. * Helper class used to enable XR
  40555. * @see https://doc.babylonjs.com/how_to/webxr
  40556. */
  40557. export class WebXRExperienceHelper implements IDisposable {
  40558. private scene;
  40559. /**
  40560. * 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
  40561. */
  40562. container: AbstractMesh;
  40563. /**
  40564. * Camera used to render xr content
  40565. */
  40566. camera: WebXRCamera;
  40567. /**
  40568. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40569. */
  40570. state: WebXRState;
  40571. private _setState;
  40572. private static _TmpVector;
  40573. /**
  40574. * Fires when the state of the experience helper has changed
  40575. */
  40576. onStateChangedObservable: Observable<WebXRState>;
  40577. /** @hidden */
  40578. _sessionManager: WebXRSessionManager;
  40579. private _nonVRCamera;
  40580. private _originalSceneAutoClear;
  40581. private _supported;
  40582. /**
  40583. * Creates the experience helper
  40584. * @param scene the scene to attach the experience helper to
  40585. * @returns a promise for the experience helper
  40586. */
  40587. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40588. /**
  40589. * Creates a WebXRExperienceHelper
  40590. * @param scene The scene the helper should be created in
  40591. */
  40592. private constructor();
  40593. /**
  40594. * Exits XR mode and returns the scene to its original state
  40595. * @returns promise that resolves after xr mode has exited
  40596. */
  40597. exitXRAsync(): Promise<void>;
  40598. /**
  40599. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40600. * @param sessionCreationOptions options for the XR session
  40601. * @param frameOfReference frame of reference of the XR session
  40602. * @returns promise that resolves after xr mode has entered
  40603. */
  40604. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40605. /**
  40606. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40607. * @param ray ray to cast into the environment
  40608. * @returns Promise which resolves with a collision point in the environment if it exists
  40609. */
  40610. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40611. /**
  40612. * Updates the global position of the camera by moving the camera's container
  40613. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40614. * @param position The desired global position of the camera
  40615. */
  40616. setPositionOfCameraUsingContainer(position: Vector3): void;
  40617. /**
  40618. * Rotates the xr camera by rotating the camera's container around the camera's position
  40619. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40620. * @param rotation the desired quaternion rotation to apply to the camera
  40621. */
  40622. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40623. /**
  40624. * Checks if the creation options are supported by the xr session
  40625. * @param options creation options
  40626. * @returns true if supported
  40627. */
  40628. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40629. /**
  40630. * Disposes of the experience helper
  40631. */
  40632. dispose(): void;
  40633. }
  40634. }
  40635. declare module BABYLON {
  40636. /**
  40637. * Button which can be used to enter a different mode of XR
  40638. */
  40639. export class WebXREnterExitUIButton {
  40640. /** button element */
  40641. element: HTMLElement;
  40642. /** XR initialization options for the button */
  40643. initializationOptions: XRSessionCreationOptions;
  40644. /**
  40645. * Creates a WebXREnterExitUIButton
  40646. * @param element button element
  40647. * @param initializationOptions XR initialization options for the button
  40648. */
  40649. constructor(
  40650. /** button element */
  40651. element: HTMLElement,
  40652. /** XR initialization options for the button */
  40653. initializationOptions: XRSessionCreationOptions);
  40654. /**
  40655. * Overwritable function which can be used to update the button's visuals when the state changes
  40656. * @param activeButton the current active button in the UI
  40657. */
  40658. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40659. }
  40660. /**
  40661. * Options to create the webXR UI
  40662. */
  40663. export class WebXREnterExitUIOptions {
  40664. /**
  40665. * Context to enter xr with
  40666. */
  40667. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40668. /**
  40669. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40670. */
  40671. customButtons?: Array<WebXREnterExitUIButton>;
  40672. }
  40673. /**
  40674. * UI to allow the user to enter/exit XR mode
  40675. */
  40676. export class WebXREnterExitUI implements IDisposable {
  40677. private scene;
  40678. private _overlay;
  40679. private _buttons;
  40680. private _activeButton;
  40681. /**
  40682. * Fired every time the active button is changed.
  40683. *
  40684. * When xr is entered via a button that launches xr that button will be the callback parameter
  40685. *
  40686. * When exiting xr the callback parameter will be null)
  40687. */
  40688. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40689. /**
  40690. * Creates UI to allow the user to enter/exit XR mode
  40691. * @param scene the scene to add the ui to
  40692. * @param helper the xr experience helper to enter/exit xr with
  40693. * @param options options to configure the UI
  40694. * @returns the created ui
  40695. */
  40696. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40697. private constructor();
  40698. private _updateButtons;
  40699. /**
  40700. * Disposes of the object
  40701. */
  40702. dispose(): void;
  40703. }
  40704. }
  40705. declare module BABYLON {
  40706. /**
  40707. * Represents an XR input
  40708. */
  40709. export class WebXRController {
  40710. /**
  40711. * 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
  40712. */
  40713. grip?: AbstractMesh;
  40714. /**
  40715. * Pointer which can be used to select objects or attach a visible laser to
  40716. */
  40717. pointer: AbstractMesh;
  40718. /**
  40719. * Creates the controller
  40720. * @see https://doc.babylonjs.com/how_to/webxr
  40721. * @param scene the scene which the controller should be associated to
  40722. */
  40723. constructor(scene: Scene);
  40724. /**
  40725. * Disposes of the object
  40726. */
  40727. dispose(): void;
  40728. }
  40729. /**
  40730. * XR input used to track XR inputs such as controllers/rays
  40731. */
  40732. export class WebXRInput implements IDisposable {
  40733. private helper;
  40734. /**
  40735. * XR controllers being tracked
  40736. */
  40737. controllers: Array<WebXRController>;
  40738. private _tmpMatrix;
  40739. private _frameObserver;
  40740. /**
  40741. * Initializes the WebXRInput
  40742. * @param helper experience helper which the input should be created for
  40743. */
  40744. constructor(helper: WebXRExperienceHelper);
  40745. /**
  40746. * Disposes of the object
  40747. */
  40748. dispose(): void;
  40749. }
  40750. }
  40751. declare module BABYLON {
  40752. /**
  40753. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40754. */
  40755. export class WebXRManagedOutputCanvas implements IDisposable {
  40756. private _canvas;
  40757. /**
  40758. * xrpresent context of the canvas which can be used to display/mirror xr content
  40759. */
  40760. canvasContext: Nullable<WebGLRenderingContext>;
  40761. /**
  40762. * Initializes the canvas to be added/removed upon entering/exiting xr
  40763. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40764. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40765. */
  40766. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40767. /**
  40768. * Disposes of the object
  40769. */
  40770. dispose(): void;
  40771. private _setManagedOutputCanvas;
  40772. private _addCanvas;
  40773. private _removeCanvas;
  40774. }
  40775. }
  40776. declare module BABYLON {
  40777. /**
  40778. * Contains an array of blocks representing the octree
  40779. */
  40780. export interface IOctreeContainer<T> {
  40781. /**
  40782. * Blocks within the octree
  40783. */
  40784. blocks: Array<OctreeBlock<T>>;
  40785. }
  40786. /**
  40787. * Class used to store a cell in an octree
  40788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40789. */
  40790. export class OctreeBlock<T> {
  40791. /**
  40792. * Gets the content of the current block
  40793. */
  40794. entries: T[];
  40795. /**
  40796. * Gets the list of block children
  40797. */
  40798. blocks: Array<OctreeBlock<T>>;
  40799. private _depth;
  40800. private _maxDepth;
  40801. private _capacity;
  40802. private _minPoint;
  40803. private _maxPoint;
  40804. private _boundingVectors;
  40805. private _creationFunc;
  40806. /**
  40807. * Creates a new block
  40808. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40809. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40810. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40811. * @param depth defines the current depth of this block in the octree
  40812. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40813. * @param creationFunc defines a callback to call when an element is added to the block
  40814. */
  40815. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40816. /**
  40817. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40818. */
  40819. readonly capacity: number;
  40820. /**
  40821. * Gets the minimum vector (in world space) of the block's bounding box
  40822. */
  40823. readonly minPoint: Vector3;
  40824. /**
  40825. * Gets the maximum vector (in world space) of the block's bounding box
  40826. */
  40827. readonly maxPoint: Vector3;
  40828. /**
  40829. * Add a new element to this block
  40830. * @param entry defines the element to add
  40831. */
  40832. addEntry(entry: T): void;
  40833. /**
  40834. * Remove an element from this block
  40835. * @param entry defines the element to remove
  40836. */
  40837. removeEntry(entry: T): void;
  40838. /**
  40839. * Add an array of elements to this block
  40840. * @param entries defines the array of elements to add
  40841. */
  40842. addEntries(entries: T[]): void;
  40843. /**
  40844. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40845. * @param frustumPlanes defines the frustum planes to test
  40846. * @param selection defines the array to store current content if selection is positive
  40847. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40848. */
  40849. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40850. /**
  40851. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40852. * @param sphereCenter defines the bounding sphere center
  40853. * @param sphereRadius defines the bounding sphere radius
  40854. * @param selection defines the array to store current content if selection is positive
  40855. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40856. */
  40857. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40858. /**
  40859. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40860. * @param ray defines the ray to test with
  40861. * @param selection defines the array to store current content if selection is positive
  40862. */
  40863. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40864. /**
  40865. * Subdivide the content into child blocks (this block will then be empty)
  40866. */
  40867. createInnerBlocks(): void;
  40868. /**
  40869. * @hidden
  40870. */
  40871. 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;
  40872. }
  40873. }
  40874. declare module BABYLON {
  40875. /**
  40876. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40877. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40878. */
  40879. export class Octree<T> {
  40880. /** 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.) */
  40881. maxDepth: number;
  40882. /**
  40883. * Blocks within the octree containing objects
  40884. */
  40885. blocks: Array<OctreeBlock<T>>;
  40886. /**
  40887. * Content stored in the octree
  40888. */
  40889. dynamicContent: T[];
  40890. private _maxBlockCapacity;
  40891. private _selectionContent;
  40892. private _creationFunc;
  40893. /**
  40894. * Creates a octree
  40895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40896. * @param creationFunc function to be used to instatiate the octree
  40897. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40898. * @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.)
  40899. */
  40900. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40901. /** 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.) */
  40902. maxDepth?: number);
  40903. /**
  40904. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40905. * @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);
  40906. * @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);
  40907. * @param entries meshes to be added to the octree blocks
  40908. */
  40909. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40910. /**
  40911. * Adds a mesh to the octree
  40912. * @param entry Mesh to add to the octree
  40913. */
  40914. addMesh(entry: T): void;
  40915. /**
  40916. * Remove an element from the octree
  40917. * @param entry defines the element to remove
  40918. */
  40919. removeMesh(entry: T): void;
  40920. /**
  40921. * Selects an array of meshes within the frustum
  40922. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40923. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40924. * @returns array of meshes within the frustum
  40925. */
  40926. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40927. /**
  40928. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40929. * @param sphereCenter defines the bounding sphere center
  40930. * @param sphereRadius defines the bounding sphere radius
  40931. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40932. * @returns an array of objects that intersect the sphere
  40933. */
  40934. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40935. /**
  40936. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40937. * @param ray defines the ray to test with
  40938. * @returns array of intersected objects
  40939. */
  40940. intersectsRay(ray: Ray): SmartArray<T>;
  40941. /**
  40942. * Adds a mesh into the octree block if it intersects the block
  40943. */
  40944. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40945. /**
  40946. * Adds a submesh into the octree block if it intersects the block
  40947. */
  40948. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40949. }
  40950. }
  40951. declare module BABYLON {
  40952. interface Scene {
  40953. /**
  40954. * @hidden
  40955. * Backing Filed
  40956. */
  40957. _selectionOctree: Octree<AbstractMesh>;
  40958. /**
  40959. * Gets the octree used to boost mesh selection (picking)
  40960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40961. */
  40962. selectionOctree: Octree<AbstractMesh>;
  40963. /**
  40964. * Creates or updates the octree used to boost selection (picking)
  40965. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40966. * @param maxCapacity defines the maximum capacity per leaf
  40967. * @param maxDepth defines the maximum depth of the octree
  40968. * @returns an octree of AbstractMesh
  40969. */
  40970. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40971. }
  40972. interface AbstractMesh {
  40973. /**
  40974. * @hidden
  40975. * Backing Field
  40976. */
  40977. _submeshesOctree: Octree<SubMesh>;
  40978. /**
  40979. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40980. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40981. * @param maxCapacity defines the maximum size of each block (64 by default)
  40982. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40983. * @returns the new octree
  40984. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40986. */
  40987. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40988. }
  40989. /**
  40990. * Defines the octree scene component responsible to manage any octrees
  40991. * in a given scene.
  40992. */
  40993. export class OctreeSceneComponent {
  40994. /**
  40995. * The component name help to identify the component in the list of scene components.
  40996. */
  40997. readonly name: string;
  40998. /**
  40999. * The scene the component belongs to.
  41000. */
  41001. scene: Scene;
  41002. /**
  41003. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41004. */
  41005. readonly checksIsEnabled: boolean;
  41006. /**
  41007. * Creates a new instance of the component for the given scene
  41008. * @param scene Defines the scene to register the component in
  41009. */
  41010. constructor(scene: Scene);
  41011. /**
  41012. * Registers the component in a given scene
  41013. */
  41014. register(): void;
  41015. /**
  41016. * Return the list of active meshes
  41017. * @returns the list of active meshes
  41018. */
  41019. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41020. /**
  41021. * Return the list of active sub meshes
  41022. * @param mesh The mesh to get the candidates sub meshes from
  41023. * @returns the list of active sub meshes
  41024. */
  41025. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41026. private _tempRay;
  41027. /**
  41028. * Return the list of sub meshes intersecting with a given local ray
  41029. * @param mesh defines the mesh to find the submesh for
  41030. * @param localRay defines the ray in local space
  41031. * @returns the list of intersecting sub meshes
  41032. */
  41033. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41034. /**
  41035. * Return the list of sub meshes colliding with a collider
  41036. * @param mesh defines the mesh to find the submesh for
  41037. * @param collider defines the collider to evaluate the collision against
  41038. * @returns the list of colliding sub meshes
  41039. */
  41040. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41041. /**
  41042. * Rebuilds the elements related to this component in case of
  41043. * context lost for instance.
  41044. */
  41045. rebuild(): void;
  41046. /**
  41047. * Disposes the component and the associated ressources.
  41048. */
  41049. dispose(): void;
  41050. }
  41051. }
  41052. declare module BABYLON {
  41053. /**
  41054. * Renders a layer on top of an existing scene
  41055. */
  41056. export class UtilityLayerRenderer implements IDisposable {
  41057. /** the original scene that will be rendered on top of */
  41058. originalScene: Scene;
  41059. private _pointerCaptures;
  41060. private _lastPointerEvents;
  41061. private static _DefaultUtilityLayer;
  41062. private static _DefaultKeepDepthUtilityLayer;
  41063. private _sharedGizmoLight;
  41064. private _renderCamera;
  41065. /**
  41066. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41067. * @returns the camera that is used when rendering the utility layer
  41068. */
  41069. getRenderCamera(): Nullable<Camera>;
  41070. /**
  41071. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41072. * @param cam the camera that should be used when rendering the utility layer
  41073. */
  41074. setRenderCamera(cam: Nullable<Camera>): void;
  41075. /**
  41076. * @hidden
  41077. * Light which used by gizmos to get light shading
  41078. */
  41079. _getSharedGizmoLight(): HemisphericLight;
  41080. /**
  41081. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41082. */
  41083. pickUtilitySceneFirst: boolean;
  41084. /**
  41085. * 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)
  41086. */
  41087. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41088. /**
  41089. * 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)
  41090. */
  41091. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41092. /**
  41093. * The scene that is rendered on top of the original scene
  41094. */
  41095. utilityLayerScene: Scene;
  41096. /**
  41097. * If the utility layer should automatically be rendered on top of existing scene
  41098. */
  41099. shouldRender: boolean;
  41100. /**
  41101. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41102. */
  41103. onlyCheckPointerDownEvents: boolean;
  41104. /**
  41105. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41106. */
  41107. processAllEvents: boolean;
  41108. /**
  41109. * Observable raised when the pointer move from the utility layer scene to the main scene
  41110. */
  41111. onPointerOutObservable: Observable<number>;
  41112. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41113. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41114. private _afterRenderObserver;
  41115. private _sceneDisposeObserver;
  41116. private _originalPointerObserver;
  41117. /**
  41118. * Instantiates a UtilityLayerRenderer
  41119. * @param originalScene the original scene that will be rendered on top of
  41120. * @param handleEvents boolean indicating if the utility layer should handle events
  41121. */
  41122. constructor(
  41123. /** the original scene that will be rendered on top of */
  41124. originalScene: Scene, handleEvents?: boolean);
  41125. private _notifyObservers;
  41126. /**
  41127. * Renders the utility layers scene on top of the original scene
  41128. */
  41129. render(): void;
  41130. /**
  41131. * Disposes of the renderer
  41132. */
  41133. dispose(): void;
  41134. private _updateCamera;
  41135. }
  41136. }
  41137. declare module BABYLON {
  41138. /**
  41139. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41140. */
  41141. export class Gizmo implements IDisposable {
  41142. /** The utility layer the gizmo will be added to */
  41143. gizmoLayer: UtilityLayerRenderer;
  41144. /**
  41145. * The root mesh of the gizmo
  41146. */
  41147. _rootMesh: Mesh;
  41148. private _attachedMesh;
  41149. /**
  41150. * Ratio for the scale of the gizmo (Default: 1)
  41151. */
  41152. scaleRatio: number;
  41153. /**
  41154. * If a custom mesh has been set (Default: false)
  41155. */
  41156. protected _customMeshSet: boolean;
  41157. /**
  41158. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41159. * * When set, interactions will be enabled
  41160. */
  41161. attachedMesh: Nullable<AbstractMesh>;
  41162. /**
  41163. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41164. * @param mesh The mesh to replace the default mesh of the gizmo
  41165. */
  41166. setCustomMesh(mesh: Mesh): void;
  41167. /**
  41168. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41169. */
  41170. updateGizmoRotationToMatchAttachedMesh: boolean;
  41171. /**
  41172. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41173. */
  41174. updateGizmoPositionToMatchAttachedMesh: boolean;
  41175. /**
  41176. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41177. */
  41178. protected _updateScale: boolean;
  41179. protected _interactionsEnabled: boolean;
  41180. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41181. private _beforeRenderObserver;
  41182. private _tempVector;
  41183. /**
  41184. * Creates a gizmo
  41185. * @param gizmoLayer The utility layer the gizmo will be added to
  41186. */
  41187. constructor(
  41188. /** The utility layer the gizmo will be added to */
  41189. gizmoLayer?: UtilityLayerRenderer);
  41190. /**
  41191. * Updates the gizmo to match the attached mesh's position/rotation
  41192. */
  41193. protected _update(): void;
  41194. /**
  41195. * Disposes of the gizmo
  41196. */
  41197. dispose(): void;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * Single plane drag gizmo
  41203. */
  41204. export class PlaneDragGizmo extends Gizmo {
  41205. /**
  41206. * Drag behavior responsible for the gizmos dragging interactions
  41207. */
  41208. dragBehavior: PointerDragBehavior;
  41209. private _pointerObserver;
  41210. /**
  41211. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41212. */
  41213. snapDistance: number;
  41214. /**
  41215. * Event that fires each time the gizmo snaps to a new location.
  41216. * * snapDistance is the the change in distance
  41217. */
  41218. onSnapObservable: Observable<{
  41219. snapDistance: number;
  41220. }>;
  41221. private _plane;
  41222. private _coloredMaterial;
  41223. private _hoverMaterial;
  41224. private _isEnabled;
  41225. private _parent;
  41226. /** @hidden */
  41227. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41228. /** @hidden */
  41229. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41230. /**
  41231. * Creates a PlaneDragGizmo
  41232. * @param gizmoLayer The utility layer the gizmo will be added to
  41233. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41234. * @param color The color of the gizmo
  41235. */
  41236. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41238. /**
  41239. * If the gizmo is enabled
  41240. */
  41241. isEnabled: boolean;
  41242. /**
  41243. * Disposes of the gizmo
  41244. */
  41245. dispose(): void;
  41246. }
  41247. }
  41248. declare module BABYLON {
  41249. /**
  41250. * Gizmo that enables dragging a mesh along 3 axis
  41251. */
  41252. export class PositionGizmo extends Gizmo {
  41253. /**
  41254. * Internal gizmo used for interactions on the x axis
  41255. */
  41256. xGizmo: AxisDragGizmo;
  41257. /**
  41258. * Internal gizmo used for interactions on the y axis
  41259. */
  41260. yGizmo: AxisDragGizmo;
  41261. /**
  41262. * Internal gizmo used for interactions on the z axis
  41263. */
  41264. zGizmo: AxisDragGizmo;
  41265. /**
  41266. * Internal gizmo used for interactions on the yz plane
  41267. */
  41268. xPlaneGizmo: PlaneDragGizmo;
  41269. /**
  41270. * Internal gizmo used for interactions on the xz plane
  41271. */
  41272. yPlaneGizmo: PlaneDragGizmo;
  41273. /**
  41274. * Internal gizmo used for interactions on the xy plane
  41275. */
  41276. zPlaneGizmo: PlaneDragGizmo;
  41277. /**
  41278. * private variables
  41279. */
  41280. private _meshAttached;
  41281. private _updateGizmoRotationToMatchAttachedMesh;
  41282. private _snapDistance;
  41283. private _scaleRatio;
  41284. /** Fires an event when any of it's sub gizmos are dragged */
  41285. onDragStartObservable: Observable<unknown>;
  41286. /** Fires an event when any of it's sub gizmos are released from dragging */
  41287. onDragEndObservable: Observable<unknown>;
  41288. /**
  41289. * If set to true, planar drag is enabled
  41290. */
  41291. private _planarGizmoEnabled;
  41292. attachedMesh: Nullable<AbstractMesh>;
  41293. /**
  41294. * Creates a PositionGizmo
  41295. * @param gizmoLayer The utility layer the gizmo will be added to
  41296. */
  41297. constructor(gizmoLayer?: UtilityLayerRenderer);
  41298. /**
  41299. * If the planar drag gizmo is enabled
  41300. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41301. */
  41302. planarGizmoEnabled: boolean;
  41303. updateGizmoRotationToMatchAttachedMesh: boolean;
  41304. /**
  41305. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41306. */
  41307. snapDistance: number;
  41308. /**
  41309. * Ratio for the scale of the gizmo (Default: 1)
  41310. */
  41311. scaleRatio: number;
  41312. /**
  41313. * Disposes of the gizmo
  41314. */
  41315. dispose(): void;
  41316. /**
  41317. * CustomMeshes are not supported by this gizmo
  41318. * @param mesh The mesh to replace the default mesh of the gizmo
  41319. */
  41320. setCustomMesh(mesh: Mesh): void;
  41321. }
  41322. }
  41323. declare module BABYLON {
  41324. /**
  41325. * Single axis drag gizmo
  41326. */
  41327. export class AxisDragGizmo extends Gizmo {
  41328. /**
  41329. * Drag behavior responsible for the gizmos dragging interactions
  41330. */
  41331. dragBehavior: PointerDragBehavior;
  41332. private _pointerObserver;
  41333. /**
  41334. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41335. */
  41336. snapDistance: number;
  41337. /**
  41338. * Event that fires each time the gizmo snaps to a new location.
  41339. * * snapDistance is the the change in distance
  41340. */
  41341. onSnapObservable: Observable<{
  41342. snapDistance: number;
  41343. }>;
  41344. private _isEnabled;
  41345. private _parent;
  41346. private _arrow;
  41347. private _coloredMaterial;
  41348. private _hoverMaterial;
  41349. /** @hidden */
  41350. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41351. /** @hidden */
  41352. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41353. /**
  41354. * Creates an AxisDragGizmo
  41355. * @param gizmoLayer The utility layer the gizmo will be added to
  41356. * @param dragAxis The axis which the gizmo will be able to drag on
  41357. * @param color The color of the gizmo
  41358. */
  41359. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41360. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41361. /**
  41362. * If the gizmo is enabled
  41363. */
  41364. isEnabled: boolean;
  41365. /**
  41366. * Disposes of the gizmo
  41367. */
  41368. dispose(): void;
  41369. }
  41370. }
  41371. declare module BABYLON.Debug {
  41372. /**
  41373. * The Axes viewer will show 3 axes in a specific point in space
  41374. */
  41375. export class AxesViewer {
  41376. private _xAxis;
  41377. private _yAxis;
  41378. private _zAxis;
  41379. private _scaleLinesFactor;
  41380. private _instanced;
  41381. /**
  41382. * Gets the hosting scene
  41383. */
  41384. scene: Scene;
  41385. /**
  41386. * Gets or sets a number used to scale line length
  41387. */
  41388. scaleLines: number;
  41389. /** Gets the node hierarchy used to render x-axis */
  41390. readonly xAxis: TransformNode;
  41391. /** Gets the node hierarchy used to render y-axis */
  41392. readonly yAxis: TransformNode;
  41393. /** Gets the node hierarchy used to render z-axis */
  41394. readonly zAxis: TransformNode;
  41395. /**
  41396. * Creates a new AxesViewer
  41397. * @param scene defines the hosting scene
  41398. * @param scaleLines defines a number used to scale line length (1 by default)
  41399. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41400. * @param xAxis defines the node hierarchy used to render the x-axis
  41401. * @param yAxis defines the node hierarchy used to render the y-axis
  41402. * @param zAxis defines the node hierarchy used to render the z-axis
  41403. */
  41404. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41405. /**
  41406. * Force the viewer to update
  41407. * @param position defines the position of the viewer
  41408. * @param xaxis defines the x axis of the viewer
  41409. * @param yaxis defines the y axis of the viewer
  41410. * @param zaxis defines the z axis of the viewer
  41411. */
  41412. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41413. /**
  41414. * Creates an instance of this axes viewer.
  41415. * @returns a new axes viewer with instanced meshes
  41416. */
  41417. createInstance(): AxesViewer;
  41418. /** Releases resources */
  41419. dispose(): void;
  41420. private static _SetRenderingGroupId;
  41421. }
  41422. }
  41423. declare module BABYLON.Debug {
  41424. /**
  41425. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41426. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41427. */
  41428. export class BoneAxesViewer extends AxesViewer {
  41429. /**
  41430. * Gets or sets the target mesh where to display the axes viewer
  41431. */
  41432. mesh: Nullable<Mesh>;
  41433. /**
  41434. * Gets or sets the target bone where to display the axes viewer
  41435. */
  41436. bone: Nullable<Bone>;
  41437. /** Gets current position */
  41438. pos: Vector3;
  41439. /** Gets direction of X axis */
  41440. xaxis: Vector3;
  41441. /** Gets direction of Y axis */
  41442. yaxis: Vector3;
  41443. /** Gets direction of Z axis */
  41444. zaxis: Vector3;
  41445. /**
  41446. * Creates a new BoneAxesViewer
  41447. * @param scene defines the hosting scene
  41448. * @param bone defines the target bone
  41449. * @param mesh defines the target mesh
  41450. * @param scaleLines defines a scaling factor for line length (1 by default)
  41451. */
  41452. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41453. /**
  41454. * Force the viewer to update
  41455. */
  41456. update(): void;
  41457. /** Releases resources */
  41458. dispose(): void;
  41459. }
  41460. }
  41461. declare module BABYLON {
  41462. /**
  41463. * Interface used to define scene explorer extensibility option
  41464. */
  41465. export interface IExplorerExtensibilityOption {
  41466. /**
  41467. * Define the option label
  41468. */
  41469. label: string;
  41470. /**
  41471. * Defines the action to execute on click
  41472. */
  41473. action: (entity: any) => void;
  41474. }
  41475. /**
  41476. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41477. */
  41478. export interface IExplorerExtensibilityGroup {
  41479. /**
  41480. * Defines a predicate to test if a given type mut be extended
  41481. */
  41482. predicate: (entity: any) => boolean;
  41483. /**
  41484. * Gets the list of options added to a type
  41485. */
  41486. entries: IExplorerExtensibilityOption[];
  41487. }
  41488. /**
  41489. * Interface used to define the options to use to create the Inspector
  41490. */
  41491. export interface IInspectorOptions {
  41492. /**
  41493. * Display in overlay mode (default: false)
  41494. */
  41495. overlay?: boolean;
  41496. /**
  41497. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41498. */
  41499. globalRoot?: HTMLElement;
  41500. /**
  41501. * Display the Scene explorer
  41502. */
  41503. showExplorer?: boolean;
  41504. /**
  41505. * Display the property inspector
  41506. */
  41507. showInspector?: boolean;
  41508. /**
  41509. * Display in embed mode (both panes on the right)
  41510. */
  41511. embedMode?: boolean;
  41512. /**
  41513. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41514. */
  41515. handleResize?: boolean;
  41516. /**
  41517. * Allow the panes to popup (default: true)
  41518. */
  41519. enablePopup?: boolean;
  41520. /**
  41521. * Allow the panes to be closed by users (default: true)
  41522. */
  41523. enableClose?: boolean;
  41524. /**
  41525. * Optional list of extensibility entries
  41526. */
  41527. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41528. /**
  41529. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41530. */
  41531. inspectorURL?: string;
  41532. }
  41533. interface Scene {
  41534. /**
  41535. * @hidden
  41536. * Backing field
  41537. */
  41538. _debugLayer: DebugLayer;
  41539. /**
  41540. * Gets the debug layer (aka Inspector) associated with the scene
  41541. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41542. */
  41543. debugLayer: DebugLayer;
  41544. }
  41545. /**
  41546. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41547. * what is happening in your scene
  41548. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41549. */
  41550. export class DebugLayer {
  41551. /**
  41552. * Define the url to get the inspector script from.
  41553. * By default it uses the babylonjs CDN.
  41554. * @ignoreNaming
  41555. */
  41556. static InspectorURL: string;
  41557. private _scene;
  41558. private BJSINSPECTOR;
  41559. /**
  41560. * Observable triggered when a property is changed through the inspector.
  41561. */
  41562. onPropertyChangedObservable: Observable<{
  41563. object: any;
  41564. property: string;
  41565. value: any;
  41566. initialValue: any;
  41567. }>;
  41568. /**
  41569. * Instantiates a new debug layer.
  41570. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41571. * what is happening in your scene
  41572. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41573. * @param scene Defines the scene to inspect
  41574. */
  41575. constructor(scene: Scene);
  41576. /** Creates the inspector window. */
  41577. private _createInspector;
  41578. /**
  41579. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41580. * @param entity defines the entity to select
  41581. * @param lineContainerTitle defines the specific block to highlight
  41582. */
  41583. select(entity: any, lineContainerTitle?: string): void;
  41584. /** Get the inspector from bundle or global */
  41585. private _getGlobalInspector;
  41586. /**
  41587. * Get if the inspector is visible or not.
  41588. * @returns true if visible otherwise, false
  41589. */
  41590. isVisible(): boolean;
  41591. /**
  41592. * Hide the inspector and close its window.
  41593. */
  41594. hide(): void;
  41595. /**
  41596. * Launch the debugLayer.
  41597. * @param config Define the configuration of the inspector
  41598. * @return a promise fulfilled when the debug layer is visible
  41599. */
  41600. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41601. }
  41602. }
  41603. declare module BABYLON {
  41604. /**
  41605. * Class containing static functions to help procedurally build meshes
  41606. */
  41607. export class BoxBuilder {
  41608. /**
  41609. * Creates a box mesh
  41610. * * The parameter `size` sets the size (float) of each box side (default 1)
  41611. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41612. * * 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)
  41613. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41615. * * 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
  41616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41617. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41618. * @param name defines the name of the mesh
  41619. * @param options defines the options used to create the mesh
  41620. * @param scene defines the hosting scene
  41621. * @returns the box mesh
  41622. */
  41623. static CreateBox(name: string, options: {
  41624. size?: number;
  41625. width?: number;
  41626. height?: number;
  41627. depth?: number;
  41628. faceUV?: Vector4[];
  41629. faceColors?: Color4[];
  41630. sideOrientation?: number;
  41631. frontUVs?: Vector4;
  41632. backUVs?: Vector4;
  41633. wrap?: boolean;
  41634. topBaseAt?: number;
  41635. bottomBaseAt?: number;
  41636. updatable?: boolean;
  41637. }, scene?: Nullable<Scene>): Mesh;
  41638. }
  41639. }
  41640. declare module BABYLON {
  41641. /**
  41642. * Class containing static functions to help procedurally build meshes
  41643. */
  41644. export class SphereBuilder {
  41645. /**
  41646. * Creates a sphere mesh
  41647. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41648. * * 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`)
  41649. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41650. * * 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
  41651. * * 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)
  41652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41653. * * 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
  41654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41655. * @param name defines the name of the mesh
  41656. * @param options defines the options used to create the mesh
  41657. * @param scene defines the hosting scene
  41658. * @returns the sphere mesh
  41659. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41660. */
  41661. static CreateSphere(name: string, options: {
  41662. segments?: number;
  41663. diameter?: number;
  41664. diameterX?: number;
  41665. diameterY?: number;
  41666. diameterZ?: number;
  41667. arc?: number;
  41668. slice?: number;
  41669. sideOrientation?: number;
  41670. frontUVs?: Vector4;
  41671. backUVs?: Vector4;
  41672. updatable?: boolean;
  41673. }, scene: any): Mesh;
  41674. }
  41675. }
  41676. declare module BABYLON.Debug {
  41677. /**
  41678. * Used to show the physics impostor around the specific mesh
  41679. */
  41680. export class PhysicsViewer {
  41681. /** @hidden */
  41682. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41683. /** @hidden */
  41684. protected _meshes: Array<Nullable<AbstractMesh>>;
  41685. /** @hidden */
  41686. protected _scene: Nullable<Scene>;
  41687. /** @hidden */
  41688. protected _numMeshes: number;
  41689. /** @hidden */
  41690. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41691. private _renderFunction;
  41692. private _utilityLayer;
  41693. private _debugBoxMesh;
  41694. private _debugSphereMesh;
  41695. private _debugCylinderMesh;
  41696. private _debugMaterial;
  41697. private _debugMeshMeshes;
  41698. /**
  41699. * Creates a new PhysicsViewer
  41700. * @param scene defines the hosting scene
  41701. */
  41702. constructor(scene: Scene);
  41703. /** @hidden */
  41704. protected _updateDebugMeshes(): void;
  41705. /**
  41706. * Renders a specified physic impostor
  41707. * @param impostor defines the impostor to render
  41708. * @param targetMesh defines the mesh represented by the impostor
  41709. * @returns the new debug mesh used to render the impostor
  41710. */
  41711. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41712. /**
  41713. * Hides a specified physic impostor
  41714. * @param impostor defines the impostor to hide
  41715. */
  41716. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41717. private _getDebugMaterial;
  41718. private _getDebugBoxMesh;
  41719. private _getDebugSphereMesh;
  41720. private _getDebugCylinderMesh;
  41721. private _getDebugMeshMesh;
  41722. private _getDebugMesh;
  41723. /** Releases all resources */
  41724. dispose(): void;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Class containing static functions to help procedurally build meshes
  41730. */
  41731. export class LinesBuilder {
  41732. /**
  41733. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41734. * * 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
  41735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41736. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41737. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41738. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41739. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41740. * * 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
  41741. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41744. * @param name defines the name of the new line system
  41745. * @param options defines the options used to create the line system
  41746. * @param scene defines the hosting scene
  41747. * @returns a new line system mesh
  41748. */
  41749. static CreateLineSystem(name: string, options: {
  41750. lines: Vector3[][];
  41751. updatable?: boolean;
  41752. instance?: Nullable<LinesMesh>;
  41753. colors?: Nullable<Color4[][]>;
  41754. useVertexAlpha?: boolean;
  41755. }, scene: Nullable<Scene>): LinesMesh;
  41756. /**
  41757. * Creates a line mesh
  41758. * 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
  41759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41760. * * The parameter `points` is an array successive Vector3
  41761. * * 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
  41762. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41764. * * When updating an instance, remember that only point positions can change, not the number of points
  41765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41767. * @param name defines the name of the new line system
  41768. * @param options defines the options used to create the line system
  41769. * @param scene defines the hosting scene
  41770. * @returns a new line mesh
  41771. */
  41772. static CreateLines(name: string, options: {
  41773. points: Vector3[];
  41774. updatable?: boolean;
  41775. instance?: Nullable<LinesMesh>;
  41776. colors?: Color4[];
  41777. useVertexAlpha?: boolean;
  41778. }, scene?: Nullable<Scene>): LinesMesh;
  41779. /**
  41780. * Creates a dashed line mesh
  41781. * * 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
  41782. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41783. * * The parameter `points` is an array successive Vector3
  41784. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41785. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41786. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41787. * * 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
  41788. * * When updating an instance, remember that only point positions can change, not the number of points
  41789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41790. * @param name defines the name of the mesh
  41791. * @param options defines the options used to create the mesh
  41792. * @param scene defines the hosting scene
  41793. * @returns the dashed line mesh
  41794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41795. */
  41796. static CreateDashedLines(name: string, options: {
  41797. points: Vector3[];
  41798. dashSize?: number;
  41799. gapSize?: number;
  41800. dashNb?: number;
  41801. updatable?: boolean;
  41802. instance?: LinesMesh;
  41803. }, scene?: Nullable<Scene>): LinesMesh;
  41804. }
  41805. }
  41806. declare module BABYLON {
  41807. /**
  41808. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41809. * in order to better appreciate the issue one might have.
  41810. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41811. */
  41812. export class RayHelper {
  41813. /**
  41814. * Defines the ray we are currently tryin to visualize.
  41815. */
  41816. ray: Nullable<Ray>;
  41817. private _renderPoints;
  41818. private _renderLine;
  41819. private _renderFunction;
  41820. private _scene;
  41821. private _updateToMeshFunction;
  41822. private _attachedToMesh;
  41823. private _meshSpaceDirection;
  41824. private _meshSpaceOrigin;
  41825. /**
  41826. * Helper function to create a colored helper in a scene in one line.
  41827. * @param ray Defines the ray we are currently tryin to visualize
  41828. * @param scene Defines the scene the ray is used in
  41829. * @param color Defines the color we want to see the ray in
  41830. * @returns The newly created ray helper.
  41831. */
  41832. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41833. /**
  41834. * Instantiate a new ray helper.
  41835. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41836. * in order to better appreciate the issue one might have.
  41837. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41838. * @param ray Defines the ray we are currently tryin to visualize
  41839. */
  41840. constructor(ray: Ray);
  41841. /**
  41842. * Shows the ray we are willing to debug.
  41843. * @param scene Defines the scene the ray needs to be rendered in
  41844. * @param color Defines the color the ray needs to be rendered in
  41845. */
  41846. show(scene: Scene, color?: Color3): void;
  41847. /**
  41848. * Hides the ray we are debugging.
  41849. */
  41850. hide(): void;
  41851. private _render;
  41852. /**
  41853. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41854. * @param mesh Defines the mesh we want the helper attached to
  41855. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41856. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41857. * @param length Defines the length of the ray
  41858. */
  41859. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41860. /**
  41861. * Detach the ray helper from the mesh it has previously been attached to.
  41862. */
  41863. detachFromMesh(): void;
  41864. private _updateToMesh;
  41865. /**
  41866. * Dispose the helper and release its associated resources.
  41867. */
  41868. dispose(): void;
  41869. }
  41870. }
  41871. declare module BABYLON.Debug {
  41872. /**
  41873. * Class used to render a debug view of a given skeleton
  41874. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41875. */
  41876. export class SkeletonViewer {
  41877. /** defines the skeleton to render */
  41878. skeleton: Skeleton;
  41879. /** defines the mesh attached to the skeleton */
  41880. mesh: AbstractMesh;
  41881. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41882. autoUpdateBonesMatrices: boolean;
  41883. /** defines the rendering group id to use with the viewer */
  41884. renderingGroupId: number;
  41885. /** Gets or sets the color used to render the skeleton */
  41886. color: Color3;
  41887. private _scene;
  41888. private _debugLines;
  41889. private _debugMesh;
  41890. private _isEnabled;
  41891. private _renderFunction;
  41892. private _utilityLayer;
  41893. /**
  41894. * Returns the mesh used to render the bones
  41895. */
  41896. readonly debugMesh: Nullable<LinesMesh>;
  41897. /**
  41898. * Creates a new SkeletonViewer
  41899. * @param skeleton defines the skeleton to render
  41900. * @param mesh defines the mesh attached to the skeleton
  41901. * @param scene defines the hosting scene
  41902. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41903. * @param renderingGroupId defines the rendering group id to use with the viewer
  41904. */
  41905. constructor(
  41906. /** defines the skeleton to render */
  41907. skeleton: Skeleton,
  41908. /** defines the mesh attached to the skeleton */
  41909. mesh: AbstractMesh, scene: Scene,
  41910. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41911. autoUpdateBonesMatrices?: boolean,
  41912. /** defines the rendering group id to use with the viewer */
  41913. renderingGroupId?: number);
  41914. /** Gets or sets a boolean indicating if the viewer is enabled */
  41915. isEnabled: boolean;
  41916. private _getBonePosition;
  41917. private _getLinesForBonesWithLength;
  41918. private _getLinesForBonesNoLength;
  41919. /** Update the viewer to sync with current skeleton state */
  41920. update(): void;
  41921. /** Release associated resources */
  41922. dispose(): void;
  41923. }
  41924. }
  41925. declare module BABYLON {
  41926. /**
  41927. * Options to create the null engine
  41928. */
  41929. export class NullEngineOptions {
  41930. /**
  41931. * Render width (Default: 512)
  41932. */
  41933. renderWidth: number;
  41934. /**
  41935. * Render height (Default: 256)
  41936. */
  41937. renderHeight: number;
  41938. /**
  41939. * Texture size (Default: 512)
  41940. */
  41941. textureSize: number;
  41942. /**
  41943. * If delta time between frames should be constant
  41944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41945. */
  41946. deterministicLockstep: boolean;
  41947. /**
  41948. * Maximum about of steps between frames (Default: 4)
  41949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41950. */
  41951. lockstepMaxSteps: number;
  41952. }
  41953. /**
  41954. * The null engine class provides support for headless version of babylon.js.
  41955. * This can be used in server side scenario or for testing purposes
  41956. */
  41957. export class NullEngine extends Engine {
  41958. private _options;
  41959. /**
  41960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41961. */
  41962. isDeterministicLockStep(): boolean;
  41963. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41964. getLockstepMaxSteps(): number;
  41965. /**
  41966. * Sets hardware scaling, used to save performance if needed
  41967. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41968. */
  41969. getHardwareScalingLevel(): number;
  41970. constructor(options?: NullEngineOptions);
  41971. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41972. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41973. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41974. getRenderWidth(useScreen?: boolean): number;
  41975. getRenderHeight(useScreen?: boolean): number;
  41976. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41977. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41978. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41979. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41980. bindSamplers(effect: Effect): void;
  41981. enableEffect(effect: Effect): void;
  41982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41983. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41984. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41985. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41986. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41987. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41988. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41989. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41990. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41991. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41992. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41993. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41994. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41995. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41996. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41997. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41998. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41999. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42000. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42002. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42003. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42004. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42005. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42006. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42007. bindBuffers(vertexBuffers: {
  42008. [key: string]: VertexBuffer;
  42009. }, indexBuffer: DataBuffer, effect: Effect): void;
  42010. wipeCaches(bruteForce?: boolean): void;
  42011. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42012. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42013. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42014. /** @hidden */
  42015. _createTexture(): WebGLTexture;
  42016. /** @hidden */
  42017. _releaseTexture(texture: InternalTexture): void;
  42018. 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;
  42019. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42020. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42021. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42022. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42023. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42024. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42025. areAllEffectsReady(): boolean;
  42026. /**
  42027. * @hidden
  42028. * Get the current error code of the webGL context
  42029. * @returns the error code
  42030. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42031. */
  42032. getError(): number;
  42033. /** @hidden */
  42034. _getUnpackAlignement(): number;
  42035. /** @hidden */
  42036. _unpackFlipY(value: boolean): void;
  42037. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42038. /**
  42039. * Updates a dynamic vertex buffer.
  42040. * @param vertexBuffer the vertex buffer to update
  42041. * @param data the data used to update the vertex buffer
  42042. * @param byteOffset the byte offset of the data (optional)
  42043. * @param byteLength the byte length of the data (optional)
  42044. */
  42045. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42046. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42047. /** @hidden */
  42048. _bindTexture(channel: number, texture: InternalTexture): void;
  42049. /** @hidden */
  42050. _releaseBuffer(buffer: DataBuffer): boolean;
  42051. releaseEffects(): void;
  42052. displayLoadingUI(): void;
  42053. hideLoadingUI(): void;
  42054. /** @hidden */
  42055. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42056. /** @hidden */
  42057. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42058. /** @hidden */
  42059. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42060. /** @hidden */
  42061. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /** @hidden */
  42066. export class _OcclusionDataStorage {
  42067. /** @hidden */
  42068. occlusionInternalRetryCounter: number;
  42069. /** @hidden */
  42070. isOcclusionQueryInProgress: boolean;
  42071. /** @hidden */
  42072. isOccluded: boolean;
  42073. /** @hidden */
  42074. occlusionRetryCount: number;
  42075. /** @hidden */
  42076. occlusionType: number;
  42077. /** @hidden */
  42078. occlusionQueryAlgorithmType: number;
  42079. }
  42080. interface Engine {
  42081. /**
  42082. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42083. * @return the new query
  42084. */
  42085. createQuery(): WebGLQuery;
  42086. /**
  42087. * Delete and release a webGL query
  42088. * @param query defines the query to delete
  42089. * @return the current engine
  42090. */
  42091. deleteQuery(query: WebGLQuery): Engine;
  42092. /**
  42093. * Check if a given query has resolved and got its value
  42094. * @param query defines the query to check
  42095. * @returns true if the query got its value
  42096. */
  42097. isQueryResultAvailable(query: WebGLQuery): boolean;
  42098. /**
  42099. * Gets the value of a given query
  42100. * @param query defines the query to check
  42101. * @returns the value of the query
  42102. */
  42103. getQueryResult(query: WebGLQuery): number;
  42104. /**
  42105. * Initiates an occlusion query
  42106. * @param algorithmType defines the algorithm to use
  42107. * @param query defines the query to use
  42108. * @returns the current engine
  42109. * @see http://doc.babylonjs.com/features/occlusionquery
  42110. */
  42111. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42112. /**
  42113. * Ends an occlusion query
  42114. * @see http://doc.babylonjs.com/features/occlusionquery
  42115. * @param algorithmType defines the algorithm to use
  42116. * @returns the current engine
  42117. */
  42118. endOcclusionQuery(algorithmType: number): Engine;
  42119. /**
  42120. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42121. * Please note that only one query can be issued at a time
  42122. * @returns a time token used to track the time span
  42123. */
  42124. startTimeQuery(): Nullable<_TimeToken>;
  42125. /**
  42126. * Ends a time query
  42127. * @param token defines the token used to measure the time span
  42128. * @returns the time spent (in ns)
  42129. */
  42130. endTimeQuery(token: _TimeToken): int;
  42131. /** @hidden */
  42132. _currentNonTimestampToken: Nullable<_TimeToken>;
  42133. /** @hidden */
  42134. _createTimeQuery(): WebGLQuery;
  42135. /** @hidden */
  42136. _deleteTimeQuery(query: WebGLQuery): void;
  42137. /** @hidden */
  42138. _getGlAlgorithmType(algorithmType: number): number;
  42139. /** @hidden */
  42140. _getTimeQueryResult(query: WebGLQuery): any;
  42141. /** @hidden */
  42142. _getTimeQueryAvailability(query: WebGLQuery): any;
  42143. }
  42144. interface AbstractMesh {
  42145. /**
  42146. * Backing filed
  42147. * @hidden
  42148. */
  42149. __occlusionDataStorage: _OcclusionDataStorage;
  42150. /**
  42151. * Access property
  42152. * @hidden
  42153. */
  42154. _occlusionDataStorage: _OcclusionDataStorage;
  42155. /**
  42156. * 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.
  42157. * The default value is -1 which means don't break the query and wait till the result
  42158. * @see http://doc.babylonjs.com/features/occlusionquery
  42159. */
  42160. occlusionRetryCount: number;
  42161. /**
  42162. * 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:
  42163. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42164. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42165. * * 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.
  42166. * @see http://doc.babylonjs.com/features/occlusionquery
  42167. */
  42168. occlusionType: number;
  42169. /**
  42170. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42171. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42172. * * 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.
  42173. * @see http://doc.babylonjs.com/features/occlusionquery
  42174. */
  42175. occlusionQueryAlgorithmType: number;
  42176. /**
  42177. * 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
  42178. * @see http://doc.babylonjs.com/features/occlusionquery
  42179. */
  42180. isOccluded: boolean;
  42181. /**
  42182. * Flag to check the progress status of the query
  42183. * @see http://doc.babylonjs.com/features/occlusionquery
  42184. */
  42185. isOcclusionQueryInProgress: boolean;
  42186. }
  42187. }
  42188. declare module BABYLON {
  42189. /** @hidden */
  42190. export var _forceTransformFeedbackToBundle: boolean;
  42191. interface Engine {
  42192. /**
  42193. * Creates a webGL transform feedback object
  42194. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42195. * @returns the webGL transform feedback object
  42196. */
  42197. createTransformFeedback(): WebGLTransformFeedback;
  42198. /**
  42199. * Delete a webGL transform feedback object
  42200. * @param value defines the webGL transform feedback object to delete
  42201. */
  42202. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42203. /**
  42204. * Bind a webGL transform feedback object to the webgl context
  42205. * @param value defines the webGL transform feedback object to bind
  42206. */
  42207. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42208. /**
  42209. * Begins a transform feedback operation
  42210. * @param usePoints defines if points or triangles must be used
  42211. */
  42212. beginTransformFeedback(usePoints: boolean): void;
  42213. /**
  42214. * Ends a transform feedback operation
  42215. */
  42216. endTransformFeedback(): void;
  42217. /**
  42218. * Specify the varyings to use with transform feedback
  42219. * @param program defines the associated webGL program
  42220. * @param value defines the list of strings representing the varying names
  42221. */
  42222. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42223. /**
  42224. * Bind a webGL buffer for a transform feedback operation
  42225. * @param value defines the webGL buffer to bind
  42226. */
  42227. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42228. }
  42229. }
  42230. declare module BABYLON {
  42231. /**
  42232. * Creation options of the multi render target texture.
  42233. */
  42234. export interface IMultiRenderTargetOptions {
  42235. /**
  42236. * Define if the texture needs to create mip maps after render.
  42237. */
  42238. generateMipMaps?: boolean;
  42239. /**
  42240. * Define the types of all the draw buffers we want to create
  42241. */
  42242. types?: number[];
  42243. /**
  42244. * Define the sampling modes of all the draw buffers we want to create
  42245. */
  42246. samplingModes?: number[];
  42247. /**
  42248. * Define if a depth buffer is required
  42249. */
  42250. generateDepthBuffer?: boolean;
  42251. /**
  42252. * Define if a stencil buffer is required
  42253. */
  42254. generateStencilBuffer?: boolean;
  42255. /**
  42256. * Define if a depth texture is required instead of a depth buffer
  42257. */
  42258. generateDepthTexture?: boolean;
  42259. /**
  42260. * Define the number of desired draw buffers
  42261. */
  42262. textureCount?: number;
  42263. /**
  42264. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42265. */
  42266. doNotChangeAspectRatio?: boolean;
  42267. /**
  42268. * Define the default type of the buffers we are creating
  42269. */
  42270. defaultType?: number;
  42271. }
  42272. /**
  42273. * A multi render target, like a render target provides the ability to render to a texture.
  42274. * Unlike the render target, it can render to several draw buffers in one draw.
  42275. * This is specially interesting in deferred rendering or for any effects requiring more than
  42276. * just one color from a single pass.
  42277. */
  42278. export class MultiRenderTarget extends RenderTargetTexture {
  42279. private _internalTextures;
  42280. private _textures;
  42281. private _multiRenderTargetOptions;
  42282. /**
  42283. * Get if draw buffers are currently supported by the used hardware and browser.
  42284. */
  42285. readonly isSupported: boolean;
  42286. /**
  42287. * Get the list of textures generated by the multi render target.
  42288. */
  42289. readonly textures: Texture[];
  42290. /**
  42291. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42292. */
  42293. readonly depthTexture: Texture;
  42294. /**
  42295. * Set the wrapping mode on U of all the textures we are rendering to.
  42296. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42297. */
  42298. wrapU: number;
  42299. /**
  42300. * Set the wrapping mode on V of all the textures we are rendering to.
  42301. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42302. */
  42303. wrapV: number;
  42304. /**
  42305. * Instantiate a new multi render target texture.
  42306. * A multi render target, like a render target provides the ability to render to a texture.
  42307. * Unlike the render target, it can render to several draw buffers in one draw.
  42308. * This is specially interesting in deferred rendering or for any effects requiring more than
  42309. * just one color from a single pass.
  42310. * @param name Define the name of the texture
  42311. * @param size Define the size of the buffers to render to
  42312. * @param count Define the number of target we are rendering into
  42313. * @param scene Define the scene the texture belongs to
  42314. * @param options Define the options used to create the multi render target
  42315. */
  42316. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42317. /** @hidden */
  42318. _rebuild(): void;
  42319. private _createInternalTextures;
  42320. private _createTextures;
  42321. /**
  42322. * Define the number of samples used if MSAA is enabled.
  42323. */
  42324. samples: number;
  42325. /**
  42326. * Resize all the textures in the multi render target.
  42327. * Be carrefull as it will recreate all the data in the new texture.
  42328. * @param size Define the new size
  42329. */
  42330. resize(size: any): void;
  42331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42332. /**
  42333. * Dispose the render targets and their associated resources
  42334. */
  42335. dispose(): void;
  42336. /**
  42337. * Release all the underlying texture used as draw buffers.
  42338. */
  42339. releaseInternalTextures(): void;
  42340. }
  42341. }
  42342. declare module BABYLON {
  42343. interface Engine {
  42344. /**
  42345. * Unbind a list of render target textures from the webGL context
  42346. * This is used only when drawBuffer extension or webGL2 are active
  42347. * @param textures defines the render target textures to unbind
  42348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42350. */
  42351. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42352. /**
  42353. * Create a multi render target texture
  42354. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42355. * @param size defines the size of the texture
  42356. * @param options defines the creation options
  42357. * @returns the cube texture as an InternalTexture
  42358. */
  42359. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42360. /**
  42361. * Update the sample count for a given multiple render target texture
  42362. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42363. * @param textures defines the textures to update
  42364. * @param samples defines the sample count to set
  42365. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42366. */
  42367. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * Gather the list of clipboard event types as constants.
  42373. */
  42374. export class ClipboardEventTypes {
  42375. /**
  42376. * The clipboard event is fired when a copy command is active (pressed).
  42377. */
  42378. static readonly COPY: number;
  42379. /**
  42380. * The clipboard event is fired when a cut command is active (pressed).
  42381. */
  42382. static readonly CUT: number;
  42383. /**
  42384. * The clipboard event is fired when a paste command is active (pressed).
  42385. */
  42386. static readonly PASTE: number;
  42387. }
  42388. /**
  42389. * This class is used to store clipboard related info for the onClipboardObservable event.
  42390. */
  42391. export class ClipboardInfo {
  42392. /**
  42393. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42394. */
  42395. type: number;
  42396. /**
  42397. * Defines the related dom event
  42398. */
  42399. event: ClipboardEvent;
  42400. /**
  42401. *Creates an instance of ClipboardInfo.
  42402. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42403. * @param event Defines the related dom event
  42404. */
  42405. constructor(
  42406. /**
  42407. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42408. */
  42409. type: number,
  42410. /**
  42411. * Defines the related dom event
  42412. */
  42413. event: ClipboardEvent);
  42414. /**
  42415. * Get the clipboard event's type from the keycode.
  42416. * @param keyCode Defines the keyCode for the current keyboard event.
  42417. * @return {number}
  42418. */
  42419. static GetTypeFromCharacter(keyCode: number): number;
  42420. }
  42421. }
  42422. declare module BABYLON {
  42423. /**
  42424. * Class used to represent data loading progression
  42425. */
  42426. export class SceneLoaderProgressEvent {
  42427. /** defines if data length to load can be evaluated */
  42428. readonly lengthComputable: boolean;
  42429. /** defines the loaded data length */
  42430. readonly loaded: number;
  42431. /** defines the data length to load */
  42432. readonly total: number;
  42433. /**
  42434. * Create a new progress event
  42435. * @param lengthComputable defines if data length to load can be evaluated
  42436. * @param loaded defines the loaded data length
  42437. * @param total defines the data length to load
  42438. */
  42439. constructor(
  42440. /** defines if data length to load can be evaluated */
  42441. lengthComputable: boolean,
  42442. /** defines the loaded data length */
  42443. loaded: number,
  42444. /** defines the data length to load */
  42445. total: number);
  42446. /**
  42447. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42448. * @param event defines the source event
  42449. * @returns a new SceneLoaderProgressEvent
  42450. */
  42451. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42452. }
  42453. /**
  42454. * Interface used by SceneLoader plugins to define supported file extensions
  42455. */
  42456. export interface ISceneLoaderPluginExtensions {
  42457. /**
  42458. * Defines the list of supported extensions
  42459. */
  42460. [extension: string]: {
  42461. isBinary: boolean;
  42462. };
  42463. }
  42464. /**
  42465. * Interface used by SceneLoader plugin factory
  42466. */
  42467. export interface ISceneLoaderPluginFactory {
  42468. /**
  42469. * Defines the name of the factory
  42470. */
  42471. name: string;
  42472. /**
  42473. * Function called to create a new plugin
  42474. * @return the new plugin
  42475. */
  42476. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42477. /**
  42478. * Boolean indicating if the plugin can direct load specific data
  42479. */
  42480. canDirectLoad?: (data: string) => boolean;
  42481. }
  42482. /**
  42483. * Interface used to define a SceneLoader plugin
  42484. */
  42485. export interface ISceneLoaderPlugin {
  42486. /**
  42487. * The friendly name of this plugin.
  42488. */
  42489. name: string;
  42490. /**
  42491. * The file extensions supported by this plugin.
  42492. */
  42493. extensions: string | ISceneLoaderPluginExtensions;
  42494. /**
  42495. * Import meshes into a scene.
  42496. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42497. * @param scene The scene to import into
  42498. * @param data The data to import
  42499. * @param rootUrl The root url for scene and resources
  42500. * @param meshes The meshes array to import into
  42501. * @param particleSystems The particle systems array to import into
  42502. * @param skeletons The skeletons array to import into
  42503. * @param onError The callback when import fails
  42504. * @returns True if successful or false otherwise
  42505. */
  42506. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42507. /**
  42508. * Load into a scene.
  42509. * @param scene The scene to load into
  42510. * @param data The data to import
  42511. * @param rootUrl The root url for scene and resources
  42512. * @param onError The callback when import fails
  42513. * @returns true if successful or false otherwise
  42514. */
  42515. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42516. /**
  42517. * The callback that returns true if the data can be directly loaded.
  42518. */
  42519. canDirectLoad?: (data: string) => boolean;
  42520. /**
  42521. * The callback that allows custom handling of the root url based on the response url.
  42522. */
  42523. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42524. /**
  42525. * Load into an asset container.
  42526. * @param scene The scene to load into
  42527. * @param data The data to import
  42528. * @param rootUrl The root url for scene and resources
  42529. * @param onError The callback when import fails
  42530. * @returns The loaded asset container
  42531. */
  42532. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42533. }
  42534. /**
  42535. * Interface used to define an async SceneLoader plugin
  42536. */
  42537. export interface ISceneLoaderPluginAsync {
  42538. /**
  42539. * The friendly name of this plugin.
  42540. */
  42541. name: string;
  42542. /**
  42543. * The file extensions supported by this plugin.
  42544. */
  42545. extensions: string | ISceneLoaderPluginExtensions;
  42546. /**
  42547. * Import meshes into a scene.
  42548. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42549. * @param scene The scene to import into
  42550. * @param data The data to import
  42551. * @param rootUrl The root url for scene and resources
  42552. * @param onProgress The callback when the load progresses
  42553. * @param fileName Defines the name of the file to load
  42554. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42555. */
  42556. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42557. meshes: AbstractMesh[];
  42558. particleSystems: IParticleSystem[];
  42559. skeletons: Skeleton[];
  42560. animationGroups: AnimationGroup[];
  42561. }>;
  42562. /**
  42563. * Load into a scene.
  42564. * @param scene The scene to load into
  42565. * @param data The data to import
  42566. * @param rootUrl The root url for scene and resources
  42567. * @param onProgress The callback when the load progresses
  42568. * @param fileName Defines the name of the file to load
  42569. * @returns Nothing
  42570. */
  42571. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42572. /**
  42573. * The callback that returns true if the data can be directly loaded.
  42574. */
  42575. canDirectLoad?: (data: string) => boolean;
  42576. /**
  42577. * The callback that allows custom handling of the root url based on the response url.
  42578. */
  42579. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42580. /**
  42581. * Load into an asset container.
  42582. * @param scene The scene to load into
  42583. * @param data The data to import
  42584. * @param rootUrl The root url for scene and resources
  42585. * @param onProgress The callback when the load progresses
  42586. * @param fileName Defines the name of the file to load
  42587. * @returns The loaded asset container
  42588. */
  42589. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42590. }
  42591. /**
  42592. * Class used to load scene from various file formats using registered plugins
  42593. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42594. */
  42595. export class SceneLoader {
  42596. /**
  42597. * No logging while loading
  42598. */
  42599. static readonly NO_LOGGING: number;
  42600. /**
  42601. * Minimal logging while loading
  42602. */
  42603. static readonly MINIMAL_LOGGING: number;
  42604. /**
  42605. * Summary logging while loading
  42606. */
  42607. static readonly SUMMARY_LOGGING: number;
  42608. /**
  42609. * Detailled logging while loading
  42610. */
  42611. static readonly DETAILED_LOGGING: number;
  42612. /**
  42613. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42614. */
  42615. static ForceFullSceneLoadingForIncremental: boolean;
  42616. /**
  42617. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42618. */
  42619. static ShowLoadingScreen: boolean;
  42620. /**
  42621. * Defines the current logging level (while loading the scene)
  42622. * @ignorenaming
  42623. */
  42624. static loggingLevel: number;
  42625. /**
  42626. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42627. */
  42628. static CleanBoneMatrixWeights: boolean;
  42629. /**
  42630. * Event raised when a plugin is used to load a scene
  42631. */
  42632. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42633. private static _registeredPlugins;
  42634. private static _getDefaultPlugin;
  42635. private static _getPluginForExtension;
  42636. private static _getPluginForDirectLoad;
  42637. private static _getPluginForFilename;
  42638. private static _getDirectLoad;
  42639. private static _loadData;
  42640. private static _getFileInfo;
  42641. /**
  42642. * Gets a plugin that can load the given extension
  42643. * @param extension defines the extension to load
  42644. * @returns a plugin or null if none works
  42645. */
  42646. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42647. /**
  42648. * Gets a boolean indicating that the given extension can be loaded
  42649. * @param extension defines the extension to load
  42650. * @returns true if the extension is supported
  42651. */
  42652. static IsPluginForExtensionAvailable(extension: string): boolean;
  42653. /**
  42654. * Adds a new plugin to the list of registered plugins
  42655. * @param plugin defines the plugin to add
  42656. */
  42657. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42658. /**
  42659. * Import meshes into a scene
  42660. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42661. * @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)
  42662. * @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)
  42663. * @param scene the instance of BABYLON.Scene to append to
  42664. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42665. * @param onProgress a callback with a progress event for each file being loaded
  42666. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42667. * @param pluginExtension the extension used to determine the plugin
  42668. * @returns The loaded plugin
  42669. */
  42670. 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>;
  42671. /**
  42672. * Import meshes into a scene
  42673. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42674. * @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)
  42675. * @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)
  42676. * @param scene the instance of BABYLON.Scene to append to
  42677. * @param onProgress a callback with a progress event for each file being loaded
  42678. * @param pluginExtension the extension used to determine the plugin
  42679. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42680. */
  42681. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42682. meshes: AbstractMesh[];
  42683. particleSystems: IParticleSystem[];
  42684. skeletons: Skeleton[];
  42685. animationGroups: AnimationGroup[];
  42686. }>;
  42687. /**
  42688. * Load a scene
  42689. * @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)
  42690. * @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)
  42691. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42692. * @param onSuccess a callback with the scene when import succeeds
  42693. * @param onProgress a callback with a progress event for each file being loaded
  42694. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42695. * @param pluginExtension the extension used to determine the plugin
  42696. * @returns The loaded plugin
  42697. */
  42698. 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>;
  42699. /**
  42700. * Load a scene
  42701. * @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)
  42702. * @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)
  42703. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42704. * @param onProgress a callback with a progress event for each file being loaded
  42705. * @param pluginExtension the extension used to determine the plugin
  42706. * @returns The loaded scene
  42707. */
  42708. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42709. /**
  42710. * Append a scene
  42711. * @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)
  42712. * @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)
  42713. * @param scene is the instance of BABYLON.Scene to append to
  42714. * @param onSuccess a callback with the scene when import succeeds
  42715. * @param onProgress a callback with a progress event for each file being loaded
  42716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42717. * @param pluginExtension the extension used to determine the plugin
  42718. * @returns The loaded plugin
  42719. */
  42720. 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>;
  42721. /**
  42722. * Append a scene
  42723. * @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)
  42724. * @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)
  42725. * @param scene is the instance of BABYLON.Scene to append to
  42726. * @param onProgress a callback with a progress event for each file being loaded
  42727. * @param pluginExtension the extension used to determine the plugin
  42728. * @returns The given scene
  42729. */
  42730. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42731. /**
  42732. * Load a scene into an asset container
  42733. * @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)
  42734. * @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)
  42735. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42736. * @param onSuccess a callback with the scene when import succeeds
  42737. * @param onProgress a callback with a progress event for each file being loaded
  42738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42739. * @param pluginExtension the extension used to determine the plugin
  42740. * @returns The loaded plugin
  42741. */
  42742. 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>;
  42743. /**
  42744. * Load a scene into an asset container
  42745. * @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)
  42746. * @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)
  42747. * @param scene is the instance of Scene to append to
  42748. * @param onProgress a callback with a progress event for each file being loaded
  42749. * @param pluginExtension the extension used to determine the plugin
  42750. * @returns The loaded asset container
  42751. */
  42752. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42753. }
  42754. }
  42755. declare module BABYLON {
  42756. /**
  42757. * Google Daydream controller
  42758. */
  42759. export class DaydreamController extends WebVRController {
  42760. /**
  42761. * Base Url for the controller model.
  42762. */
  42763. static MODEL_BASE_URL: string;
  42764. /**
  42765. * File name for the controller model.
  42766. */
  42767. static MODEL_FILENAME: string;
  42768. /**
  42769. * Gamepad Id prefix used to identify Daydream Controller.
  42770. */
  42771. static readonly GAMEPAD_ID_PREFIX: string;
  42772. /**
  42773. * Creates a new DaydreamController from a gamepad
  42774. * @param vrGamepad the gamepad that the controller should be created from
  42775. */
  42776. constructor(vrGamepad: any);
  42777. /**
  42778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42779. * @param scene scene in which to add meshes
  42780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42781. */
  42782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42783. /**
  42784. * Called once for each button that changed state since the last frame
  42785. * @param buttonIdx Which button index changed
  42786. * @param state New state of the button
  42787. * @param changes Which properties on the state changed since last frame
  42788. */
  42789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42790. }
  42791. }
  42792. declare module BABYLON {
  42793. /**
  42794. * Gear VR Controller
  42795. */
  42796. export class GearVRController extends WebVRController {
  42797. /**
  42798. * Base Url for the controller model.
  42799. */
  42800. static MODEL_BASE_URL: string;
  42801. /**
  42802. * File name for the controller model.
  42803. */
  42804. static MODEL_FILENAME: string;
  42805. /**
  42806. * Gamepad Id prefix used to identify this controller.
  42807. */
  42808. static readonly GAMEPAD_ID_PREFIX: string;
  42809. private readonly _buttonIndexToObservableNameMap;
  42810. /**
  42811. * Creates a new GearVRController from a gamepad
  42812. * @param vrGamepad the gamepad that the controller should be created from
  42813. */
  42814. constructor(vrGamepad: any);
  42815. /**
  42816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42817. * @param scene scene in which to add meshes
  42818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42819. */
  42820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42821. /**
  42822. * Called once for each button that changed state since the last frame
  42823. * @param buttonIdx Which button index changed
  42824. * @param state New state of the button
  42825. * @param changes Which properties on the state changed since last frame
  42826. */
  42827. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42828. }
  42829. }
  42830. declare module BABYLON {
  42831. /**
  42832. * Generic Controller
  42833. */
  42834. export class GenericController extends WebVRController {
  42835. /**
  42836. * Base Url for the controller model.
  42837. */
  42838. static readonly MODEL_BASE_URL: string;
  42839. /**
  42840. * File name for the controller model.
  42841. */
  42842. static readonly MODEL_FILENAME: string;
  42843. /**
  42844. * Creates a new GenericController from a gamepad
  42845. * @param vrGamepad the gamepad that the controller should be created from
  42846. */
  42847. constructor(vrGamepad: any);
  42848. /**
  42849. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42850. * @param scene scene in which to add meshes
  42851. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42852. */
  42853. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42854. /**
  42855. * Called once for each button that changed state since the last frame
  42856. * @param buttonIdx Which button index changed
  42857. * @param state New state of the button
  42858. * @param changes Which properties on the state changed since last frame
  42859. */
  42860. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42861. }
  42862. }
  42863. declare module BABYLON {
  42864. /**
  42865. * Oculus Touch Controller
  42866. */
  42867. export class OculusTouchController extends WebVRController {
  42868. /**
  42869. * Base Url for the controller model.
  42870. */
  42871. static MODEL_BASE_URL: string;
  42872. /**
  42873. * File name for the left controller model.
  42874. */
  42875. static MODEL_LEFT_FILENAME: string;
  42876. /**
  42877. * File name for the right controller model.
  42878. */
  42879. static MODEL_RIGHT_FILENAME: string;
  42880. /**
  42881. * Base Url for the Quest controller model.
  42882. */
  42883. static QUEST_MODEL_BASE_URL: string;
  42884. /**
  42885. * @hidden
  42886. * If the controllers are running on a device that needs the updated Quest controller models
  42887. */
  42888. static _IsQuest: boolean;
  42889. /**
  42890. * Fired when the secondary trigger on this controller is modified
  42891. */
  42892. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42893. /**
  42894. * Fired when the thumb rest on this controller is modified
  42895. */
  42896. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42897. /**
  42898. * Creates a new OculusTouchController from a gamepad
  42899. * @param vrGamepad the gamepad that the controller should be created from
  42900. */
  42901. constructor(vrGamepad: any);
  42902. /**
  42903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42904. * @param scene scene in which to add meshes
  42905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42906. */
  42907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42908. /**
  42909. * Fired when the A button on this controller is modified
  42910. */
  42911. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42912. /**
  42913. * Fired when the B button on this controller is modified
  42914. */
  42915. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42916. /**
  42917. * Fired when the X button on this controller is modified
  42918. */
  42919. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42920. /**
  42921. * Fired when the Y button on this controller is modified
  42922. */
  42923. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42924. /**
  42925. * Called once for each button that changed state since the last frame
  42926. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42927. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42928. * 2) secondary trigger (same)
  42929. * 3) A (right) X (left), touch, pressed = value
  42930. * 4) B / Y
  42931. * 5) thumb rest
  42932. * @param buttonIdx Which button index changed
  42933. * @param state New state of the button
  42934. * @param changes Which properties on the state changed since last frame
  42935. */
  42936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42937. }
  42938. }
  42939. declare module BABYLON {
  42940. /**
  42941. * Vive Controller
  42942. */
  42943. export class ViveController extends WebVRController {
  42944. /**
  42945. * Base Url for the controller model.
  42946. */
  42947. static MODEL_BASE_URL: string;
  42948. /**
  42949. * File name for the controller model.
  42950. */
  42951. static MODEL_FILENAME: string;
  42952. /**
  42953. * Creates a new ViveController from a gamepad
  42954. * @param vrGamepad the gamepad that the controller should be created from
  42955. */
  42956. constructor(vrGamepad: any);
  42957. /**
  42958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42959. * @param scene scene in which to add meshes
  42960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42961. */
  42962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42963. /**
  42964. * Fired when the left button on this controller is modified
  42965. */
  42966. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42967. /**
  42968. * Fired when the right button on this controller is modified
  42969. */
  42970. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42971. /**
  42972. * Fired when the menu button on this controller is modified
  42973. */
  42974. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42975. /**
  42976. * Called once for each button that changed state since the last frame
  42977. * Vive mapping:
  42978. * 0: touchpad
  42979. * 1: trigger
  42980. * 2: left AND right buttons
  42981. * 3: menu button
  42982. * @param buttonIdx Which button index changed
  42983. * @param state New state of the button
  42984. * @param changes Which properties on the state changed since last frame
  42985. */
  42986. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42987. }
  42988. }
  42989. declare module BABYLON {
  42990. /**
  42991. * Defines the WindowsMotionController object that the state of the windows motion controller
  42992. */
  42993. export class WindowsMotionController extends WebVRController {
  42994. /**
  42995. * The base url used to load the left and right controller models
  42996. */
  42997. static MODEL_BASE_URL: string;
  42998. /**
  42999. * The name of the left controller model file
  43000. */
  43001. static MODEL_LEFT_FILENAME: string;
  43002. /**
  43003. * The name of the right controller model file
  43004. */
  43005. static MODEL_RIGHT_FILENAME: string;
  43006. /**
  43007. * The controller name prefix for this controller type
  43008. */
  43009. static readonly GAMEPAD_ID_PREFIX: string;
  43010. /**
  43011. * The controller id pattern for this controller type
  43012. */
  43013. private static readonly GAMEPAD_ID_PATTERN;
  43014. private _loadedMeshInfo;
  43015. private readonly _mapping;
  43016. /**
  43017. * Fired when the trackpad on this controller is clicked
  43018. */
  43019. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43020. /**
  43021. * Fired when the trackpad on this controller is modified
  43022. */
  43023. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43024. /**
  43025. * The current x and y values of this controller's trackpad
  43026. */
  43027. trackpad: StickValues;
  43028. /**
  43029. * Creates a new WindowsMotionController from a gamepad
  43030. * @param vrGamepad the gamepad that the controller should be created from
  43031. */
  43032. constructor(vrGamepad: any);
  43033. /**
  43034. * Fired when the trigger on this controller is modified
  43035. */
  43036. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43037. /**
  43038. * Fired when the menu button on this controller is modified
  43039. */
  43040. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43041. /**
  43042. * Fired when the grip button on this controller is modified
  43043. */
  43044. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43045. /**
  43046. * Fired when the thumbstick button on this controller is modified
  43047. */
  43048. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43049. /**
  43050. * Fired when the touchpad button on this controller is modified
  43051. */
  43052. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43053. /**
  43054. * Fired when the touchpad values on this controller are modified
  43055. */
  43056. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43057. private _updateTrackpad;
  43058. /**
  43059. * Called once per frame by the engine.
  43060. */
  43061. update(): void;
  43062. /**
  43063. * Called once for each button that changed state since the last frame
  43064. * @param buttonIdx Which button index changed
  43065. * @param state New state of the button
  43066. * @param changes Which properties on the state changed since last frame
  43067. */
  43068. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43069. /**
  43070. * Moves the buttons on the controller mesh based on their current state
  43071. * @param buttonName the name of the button to move
  43072. * @param buttonValue the value of the button which determines the buttons new position
  43073. */
  43074. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43075. /**
  43076. * Moves the axis on the controller mesh based on its current state
  43077. * @param axis the index of the axis
  43078. * @param axisValue the value of the axis which determines the meshes new position
  43079. * @hidden
  43080. */
  43081. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43082. /**
  43083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43084. * @param scene scene in which to add meshes
  43085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43086. */
  43087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43088. /**
  43089. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43090. * can be transformed by button presses and axes values, based on this._mapping.
  43091. *
  43092. * @param scene scene in which the meshes exist
  43093. * @param meshes list of meshes that make up the controller model to process
  43094. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43095. */
  43096. private processModel;
  43097. private createMeshInfo;
  43098. /**
  43099. * Gets the ray of the controller in the direction the controller is pointing
  43100. * @param length the length the resulting ray should be
  43101. * @returns a ray in the direction the controller is pointing
  43102. */
  43103. getForwardRay(length?: number): Ray;
  43104. /**
  43105. * Disposes of the controller
  43106. */
  43107. dispose(): void;
  43108. }
  43109. }
  43110. declare module BABYLON {
  43111. /**
  43112. * Class containing static functions to help procedurally build meshes
  43113. */
  43114. export class PolyhedronBuilder {
  43115. /**
  43116. * Creates a polyhedron mesh
  43117. * * 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
  43118. * * The parameter `size` (positive float, default 1) sets the polygon size
  43119. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43120. * * 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`
  43121. * * 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
  43122. * * 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)`)
  43123. * * 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
  43124. * * 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
  43125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43126. * * 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
  43127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43128. * @param name defines the name of the mesh
  43129. * @param options defines the options used to create the mesh
  43130. * @param scene defines the hosting scene
  43131. * @returns the polyhedron mesh
  43132. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43133. */
  43134. static CreatePolyhedron(name: string, options: {
  43135. type?: number;
  43136. size?: number;
  43137. sizeX?: number;
  43138. sizeY?: number;
  43139. sizeZ?: number;
  43140. custom?: any;
  43141. faceUV?: Vector4[];
  43142. faceColors?: Color4[];
  43143. flat?: boolean;
  43144. updatable?: boolean;
  43145. sideOrientation?: number;
  43146. frontUVs?: Vector4;
  43147. backUVs?: Vector4;
  43148. }, scene?: Nullable<Scene>): Mesh;
  43149. }
  43150. }
  43151. declare module BABYLON {
  43152. /**
  43153. * Gizmo that enables scaling a mesh along 3 axis
  43154. */
  43155. export class ScaleGizmo extends Gizmo {
  43156. /**
  43157. * Internal gizmo used for interactions on the x axis
  43158. */
  43159. xGizmo: AxisScaleGizmo;
  43160. /**
  43161. * Internal gizmo used for interactions on the y axis
  43162. */
  43163. yGizmo: AxisScaleGizmo;
  43164. /**
  43165. * Internal gizmo used for interactions on the z axis
  43166. */
  43167. zGizmo: AxisScaleGizmo;
  43168. /**
  43169. * Internal gizmo used to scale all axis equally
  43170. */
  43171. uniformScaleGizmo: AxisScaleGizmo;
  43172. private _meshAttached;
  43173. private _updateGizmoRotationToMatchAttachedMesh;
  43174. private _snapDistance;
  43175. private _scaleRatio;
  43176. private _uniformScalingMesh;
  43177. private _octahedron;
  43178. /** Fires an event when any of it's sub gizmos are dragged */
  43179. onDragStartObservable: Observable<unknown>;
  43180. /** Fires an event when any of it's sub gizmos are released from dragging */
  43181. onDragEndObservable: Observable<unknown>;
  43182. attachedMesh: Nullable<AbstractMesh>;
  43183. /**
  43184. * Creates a ScaleGizmo
  43185. * @param gizmoLayer The utility layer the gizmo will be added to
  43186. */
  43187. constructor(gizmoLayer?: UtilityLayerRenderer);
  43188. updateGizmoRotationToMatchAttachedMesh: boolean;
  43189. /**
  43190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43191. */
  43192. snapDistance: number;
  43193. /**
  43194. * Ratio for the scale of the gizmo (Default: 1)
  43195. */
  43196. scaleRatio: number;
  43197. /**
  43198. * Disposes of the gizmo
  43199. */
  43200. dispose(): void;
  43201. }
  43202. }
  43203. declare module BABYLON {
  43204. /**
  43205. * Single axis scale gizmo
  43206. */
  43207. export class AxisScaleGizmo extends Gizmo {
  43208. /**
  43209. * Drag behavior responsible for the gizmos dragging interactions
  43210. */
  43211. dragBehavior: PointerDragBehavior;
  43212. private _pointerObserver;
  43213. /**
  43214. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43215. */
  43216. snapDistance: number;
  43217. /**
  43218. * Event that fires each time the gizmo snaps to a new location.
  43219. * * snapDistance is the the change in distance
  43220. */
  43221. onSnapObservable: Observable<{
  43222. snapDistance: number;
  43223. }>;
  43224. /**
  43225. * If the scaling operation should be done on all axis (default: false)
  43226. */
  43227. uniformScaling: boolean;
  43228. private _isEnabled;
  43229. private _parent;
  43230. private _arrow;
  43231. private _coloredMaterial;
  43232. private _hoverMaterial;
  43233. /**
  43234. * Creates an AxisScaleGizmo
  43235. * @param gizmoLayer The utility layer the gizmo will be added to
  43236. * @param dragAxis The axis which the gizmo will be able to scale on
  43237. * @param color The color of the gizmo
  43238. */
  43239. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43240. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43241. /**
  43242. * If the gizmo is enabled
  43243. */
  43244. isEnabled: boolean;
  43245. /**
  43246. * Disposes of the gizmo
  43247. */
  43248. dispose(): void;
  43249. /**
  43250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43251. * @param mesh The mesh to replace the default mesh of the gizmo
  43252. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43253. */
  43254. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43255. }
  43256. }
  43257. declare module BABYLON {
  43258. /**
  43259. * Bounding box gizmo
  43260. */
  43261. export class BoundingBoxGizmo extends Gizmo {
  43262. private _lineBoundingBox;
  43263. private _rotateSpheresParent;
  43264. private _scaleBoxesParent;
  43265. private _boundingDimensions;
  43266. private _renderObserver;
  43267. private _pointerObserver;
  43268. private _scaleDragSpeed;
  43269. private _tmpQuaternion;
  43270. private _tmpVector;
  43271. private _tmpRotationMatrix;
  43272. /**
  43273. * 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)
  43274. */
  43275. ignoreChildren: boolean;
  43276. /**
  43277. * 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)
  43278. */
  43279. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43280. /**
  43281. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43282. */
  43283. rotationSphereSize: number;
  43284. /**
  43285. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43286. */
  43287. scaleBoxSize: number;
  43288. /**
  43289. * 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)
  43290. */
  43291. fixedDragMeshScreenSize: boolean;
  43292. /**
  43293. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43294. */
  43295. fixedDragMeshScreenSizeDistanceFactor: number;
  43296. /**
  43297. * Fired when a rotation sphere or scale box is dragged
  43298. */
  43299. onDragStartObservable: Observable<{}>;
  43300. /**
  43301. * Fired when a scale box is dragged
  43302. */
  43303. onScaleBoxDragObservable: Observable<{}>;
  43304. /**
  43305. * Fired when a scale box drag is ended
  43306. */
  43307. onScaleBoxDragEndObservable: Observable<{}>;
  43308. /**
  43309. * Fired when a rotation sphere is dragged
  43310. */
  43311. onRotationSphereDragObservable: Observable<{}>;
  43312. /**
  43313. * Fired when a rotation sphere drag is ended
  43314. */
  43315. onRotationSphereDragEndObservable: Observable<{}>;
  43316. /**
  43317. * 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)
  43318. */
  43319. scalePivot: Nullable<Vector3>;
  43320. /**
  43321. * Mesh used as a pivot to rotate the attached mesh
  43322. */
  43323. private _anchorMesh;
  43324. private _existingMeshScale;
  43325. private _dragMesh;
  43326. private pointerDragBehavior;
  43327. private coloredMaterial;
  43328. private hoverColoredMaterial;
  43329. /**
  43330. * Sets the color of the bounding box gizmo
  43331. * @param color the color to set
  43332. */
  43333. setColor(color: Color3): void;
  43334. /**
  43335. * Creates an BoundingBoxGizmo
  43336. * @param gizmoLayer The utility layer the gizmo will be added to
  43337. * @param color The color of the gizmo
  43338. */
  43339. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43341. private _selectNode;
  43342. /**
  43343. * Updates the bounding box information for the Gizmo
  43344. */
  43345. updateBoundingBox(): void;
  43346. private _updateRotationSpheres;
  43347. private _updateScaleBoxes;
  43348. /**
  43349. * Enables rotation on the specified axis and disables rotation on the others
  43350. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43351. */
  43352. setEnabledRotationAxis(axis: string): void;
  43353. /**
  43354. * Enables/disables scaling
  43355. * @param enable if scaling should be enabled
  43356. */
  43357. setEnabledScaling(enable: boolean): void;
  43358. private _updateDummy;
  43359. /**
  43360. * Enables a pointer drag behavior on the bounding box of the gizmo
  43361. */
  43362. enableDragBehavior(): void;
  43363. /**
  43364. * Disposes of the gizmo
  43365. */
  43366. dispose(): void;
  43367. /**
  43368. * 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)
  43369. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43370. * @returns the bounding box mesh with the passed in mesh as a child
  43371. */
  43372. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43373. /**
  43374. * CustomMeshes are not supported by this gizmo
  43375. * @param mesh The mesh to replace the default mesh of the gizmo
  43376. */
  43377. setCustomMesh(mesh: Mesh): void;
  43378. }
  43379. }
  43380. declare module BABYLON {
  43381. /**
  43382. * Single plane rotation gizmo
  43383. */
  43384. export class PlaneRotationGizmo extends Gizmo {
  43385. /**
  43386. * Drag behavior responsible for the gizmos dragging interactions
  43387. */
  43388. dragBehavior: PointerDragBehavior;
  43389. private _pointerObserver;
  43390. /**
  43391. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43392. */
  43393. snapDistance: number;
  43394. /**
  43395. * Event that fires each time the gizmo snaps to a new location.
  43396. * * snapDistance is the the change in distance
  43397. */
  43398. onSnapObservable: Observable<{
  43399. snapDistance: number;
  43400. }>;
  43401. private _isEnabled;
  43402. private _parent;
  43403. /**
  43404. * Creates a PlaneRotationGizmo
  43405. * @param gizmoLayer The utility layer the gizmo will be added to
  43406. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43407. * @param color The color of the gizmo
  43408. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43409. */
  43410. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43411. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43412. /**
  43413. * If the gizmo is enabled
  43414. */
  43415. isEnabled: boolean;
  43416. /**
  43417. * Disposes of the gizmo
  43418. */
  43419. dispose(): void;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * Gizmo that enables rotating a mesh along 3 axis
  43425. */
  43426. export class RotationGizmo extends Gizmo {
  43427. /**
  43428. * Internal gizmo used for interactions on the x axis
  43429. */
  43430. xGizmo: PlaneRotationGizmo;
  43431. /**
  43432. * Internal gizmo used for interactions on the y axis
  43433. */
  43434. yGizmo: PlaneRotationGizmo;
  43435. /**
  43436. * Internal gizmo used for interactions on the z axis
  43437. */
  43438. zGizmo: PlaneRotationGizmo;
  43439. /** Fires an event when any of it's sub gizmos are dragged */
  43440. onDragStartObservable: Observable<unknown>;
  43441. /** Fires an event when any of it's sub gizmos are released from dragging */
  43442. onDragEndObservable: Observable<unknown>;
  43443. private _meshAttached;
  43444. attachedMesh: Nullable<AbstractMesh>;
  43445. /**
  43446. * Creates a RotationGizmo
  43447. * @param gizmoLayer The utility layer the gizmo will be added to
  43448. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43449. */
  43450. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43451. updateGizmoRotationToMatchAttachedMesh: boolean;
  43452. /**
  43453. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43454. */
  43455. snapDistance: number;
  43456. /**
  43457. * Ratio for the scale of the gizmo (Default: 1)
  43458. */
  43459. scaleRatio: number;
  43460. /**
  43461. * Disposes of the gizmo
  43462. */
  43463. dispose(): void;
  43464. /**
  43465. * CustomMeshes are not supported by this gizmo
  43466. * @param mesh The mesh to replace the default mesh of the gizmo
  43467. */
  43468. setCustomMesh(mesh: Mesh): void;
  43469. }
  43470. }
  43471. declare module BABYLON {
  43472. /**
  43473. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43474. */
  43475. export class GizmoManager implements IDisposable {
  43476. private scene;
  43477. /**
  43478. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43479. */
  43480. gizmos: {
  43481. positionGizmo: Nullable<PositionGizmo>;
  43482. rotationGizmo: Nullable<RotationGizmo>;
  43483. scaleGizmo: Nullable<ScaleGizmo>;
  43484. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43485. };
  43486. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43487. clearGizmoOnEmptyPointerEvent: boolean;
  43488. /** Fires an event when the manager is attached to a mesh */
  43489. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43490. private _gizmosEnabled;
  43491. private _pointerObserver;
  43492. private _attachedMesh;
  43493. private _boundingBoxColor;
  43494. private _defaultUtilityLayer;
  43495. private _defaultKeepDepthUtilityLayer;
  43496. /**
  43497. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43498. */
  43499. boundingBoxDragBehavior: SixDofDragBehavior;
  43500. /**
  43501. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43502. */
  43503. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43504. /**
  43505. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43506. */
  43507. usePointerToAttachGizmos: boolean;
  43508. /**
  43509. * Utility layer that the bounding box gizmo belongs to
  43510. */
  43511. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43512. /**
  43513. * Utility layer that all gizmos besides bounding box belong to
  43514. */
  43515. readonly utilityLayer: UtilityLayerRenderer;
  43516. /**
  43517. * Instatiates a gizmo manager
  43518. * @param scene the scene to overlay the gizmos on top of
  43519. */
  43520. constructor(scene: Scene);
  43521. /**
  43522. * Attaches a set of gizmos to the specified mesh
  43523. * @param mesh The mesh the gizmo's should be attached to
  43524. */
  43525. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43526. /**
  43527. * If the position gizmo is enabled
  43528. */
  43529. positionGizmoEnabled: boolean;
  43530. /**
  43531. * If the rotation gizmo is enabled
  43532. */
  43533. rotationGizmoEnabled: boolean;
  43534. /**
  43535. * If the scale gizmo is enabled
  43536. */
  43537. scaleGizmoEnabled: boolean;
  43538. /**
  43539. * If the boundingBox gizmo is enabled
  43540. */
  43541. boundingBoxGizmoEnabled: boolean;
  43542. /**
  43543. * Disposes of the gizmo manager
  43544. */
  43545. dispose(): void;
  43546. }
  43547. }
  43548. declare module BABYLON {
  43549. /**
  43550. * A directional light is defined by a direction (what a surprise!).
  43551. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43552. * 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.
  43553. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43554. */
  43555. export class DirectionalLight extends ShadowLight {
  43556. private _shadowFrustumSize;
  43557. /**
  43558. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43559. */
  43560. /**
  43561. * Specifies a fix frustum size for the shadow generation.
  43562. */
  43563. shadowFrustumSize: number;
  43564. private _shadowOrthoScale;
  43565. /**
  43566. * Gets the shadow projection scale against the optimal computed one.
  43567. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43568. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43569. */
  43570. /**
  43571. * Sets the shadow projection scale against the optimal computed one.
  43572. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43573. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43574. */
  43575. shadowOrthoScale: number;
  43576. /**
  43577. * Automatically compute the projection matrix to best fit (including all the casters)
  43578. * on each frame.
  43579. */
  43580. autoUpdateExtends: boolean;
  43581. private _orthoLeft;
  43582. private _orthoRight;
  43583. private _orthoTop;
  43584. private _orthoBottom;
  43585. /**
  43586. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43587. * The directional light is emitted from everywhere in the given direction.
  43588. * It can cast shadows.
  43589. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43590. * @param name The friendly name of the light
  43591. * @param direction The direction of the light
  43592. * @param scene The scene the light belongs to
  43593. */
  43594. constructor(name: string, direction: Vector3, scene: Scene);
  43595. /**
  43596. * Returns the string "DirectionalLight".
  43597. * @return The class name
  43598. */
  43599. getClassName(): string;
  43600. /**
  43601. * Returns the integer 1.
  43602. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43603. */
  43604. getTypeID(): number;
  43605. /**
  43606. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43607. * Returns the DirectionalLight Shadow projection matrix.
  43608. */
  43609. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43610. /**
  43611. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43612. * Returns the DirectionalLight Shadow projection matrix.
  43613. */
  43614. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43615. /**
  43616. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43617. * Returns the DirectionalLight Shadow projection matrix.
  43618. */
  43619. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43620. protected _buildUniformLayout(): void;
  43621. /**
  43622. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43623. * @param effect The effect to update
  43624. * @param lightIndex The index of the light in the effect to update
  43625. * @returns The directional light
  43626. */
  43627. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43628. /**
  43629. * Gets the minZ used for shadow according to both the scene and the light.
  43630. *
  43631. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43632. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43633. * @param activeCamera The camera we are returning the min for
  43634. * @returns the depth min z
  43635. */
  43636. getDepthMinZ(activeCamera: Camera): number;
  43637. /**
  43638. * Gets the maxZ used for shadow according to both the scene and the light.
  43639. *
  43640. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43641. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43642. * @param activeCamera The camera we are returning the max for
  43643. * @returns the depth max z
  43644. */
  43645. getDepthMaxZ(activeCamera: Camera): number;
  43646. /**
  43647. * Prepares the list of defines specific to the light type.
  43648. * @param defines the list of defines
  43649. * @param lightIndex defines the index of the light for the effect
  43650. */
  43651. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43652. }
  43653. }
  43654. declare module BABYLON {
  43655. /**
  43656. * Class containing static functions to help procedurally build meshes
  43657. */
  43658. export class HemisphereBuilder {
  43659. /**
  43660. * Creates a hemisphere mesh
  43661. * @param name defines the name of the mesh
  43662. * @param options defines the options used to create the mesh
  43663. * @param scene defines the hosting scene
  43664. * @returns the hemisphere mesh
  43665. */
  43666. static CreateHemisphere(name: string, options: {
  43667. segments?: number;
  43668. diameter?: number;
  43669. sideOrientation?: number;
  43670. }, scene: any): Mesh;
  43671. }
  43672. }
  43673. declare module BABYLON {
  43674. /**
  43675. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43676. * These values define a cone of light starting from the position, emitting toward the direction.
  43677. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43678. * and the exponent defines the speed of the decay of the light with distance (reach).
  43679. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43680. */
  43681. export class SpotLight extends ShadowLight {
  43682. private _angle;
  43683. private _innerAngle;
  43684. private _cosHalfAngle;
  43685. private _lightAngleScale;
  43686. private _lightAngleOffset;
  43687. /**
  43688. * Gets the cone angle of the spot light in Radians.
  43689. */
  43690. /**
  43691. * Sets the cone angle of the spot light in Radians.
  43692. */
  43693. angle: number;
  43694. /**
  43695. * Only used in gltf falloff mode, this defines the angle where
  43696. * the directional falloff will start before cutting at angle which could be seen
  43697. * as outer angle.
  43698. */
  43699. /**
  43700. * Only used in gltf falloff mode, this defines the angle where
  43701. * the directional falloff will start before cutting at angle which could be seen
  43702. * as outer angle.
  43703. */
  43704. innerAngle: number;
  43705. private _shadowAngleScale;
  43706. /**
  43707. * Allows scaling the angle of the light for shadow generation only.
  43708. */
  43709. /**
  43710. * Allows scaling the angle of the light for shadow generation only.
  43711. */
  43712. shadowAngleScale: number;
  43713. /**
  43714. * The light decay speed with the distance from the emission spot.
  43715. */
  43716. exponent: number;
  43717. private _projectionTextureMatrix;
  43718. /**
  43719. * Allows reading the projecton texture
  43720. */
  43721. readonly projectionTextureMatrix: Matrix;
  43722. protected _projectionTextureLightNear: number;
  43723. /**
  43724. * Gets the near clip of the Spotlight for texture projection.
  43725. */
  43726. /**
  43727. * Sets the near clip of the Spotlight for texture projection.
  43728. */
  43729. projectionTextureLightNear: number;
  43730. protected _projectionTextureLightFar: number;
  43731. /**
  43732. * Gets the far clip of the Spotlight for texture projection.
  43733. */
  43734. /**
  43735. * Sets the far clip of the Spotlight for texture projection.
  43736. */
  43737. projectionTextureLightFar: number;
  43738. protected _projectionTextureUpDirection: Vector3;
  43739. /**
  43740. * Gets the Up vector of the Spotlight for texture projection.
  43741. */
  43742. /**
  43743. * Sets the Up vector of the Spotlight for texture projection.
  43744. */
  43745. projectionTextureUpDirection: Vector3;
  43746. private _projectionTexture;
  43747. /**
  43748. * Gets the projection texture of the light.
  43749. */
  43750. /**
  43751. * Sets the projection texture of the light.
  43752. */
  43753. projectionTexture: Nullable<BaseTexture>;
  43754. private _projectionTextureViewLightDirty;
  43755. private _projectionTextureProjectionLightDirty;
  43756. private _projectionTextureDirty;
  43757. private _projectionTextureViewTargetVector;
  43758. private _projectionTextureViewLightMatrix;
  43759. private _projectionTextureProjectionLightMatrix;
  43760. private _projectionTextureScalingMatrix;
  43761. /**
  43762. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43763. * It can cast shadows.
  43764. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43765. * @param name The light friendly name
  43766. * @param position The position of the spot light in the scene
  43767. * @param direction The direction of the light in the scene
  43768. * @param angle The cone angle of the light in Radians
  43769. * @param exponent The light decay speed with the distance from the emission spot
  43770. * @param scene The scene the lights belongs to
  43771. */
  43772. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43773. /**
  43774. * Returns the string "SpotLight".
  43775. * @returns the class name
  43776. */
  43777. getClassName(): string;
  43778. /**
  43779. * Returns the integer 2.
  43780. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43781. */
  43782. getTypeID(): number;
  43783. /**
  43784. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43785. */
  43786. protected _setDirection(value: Vector3): void;
  43787. /**
  43788. * Overrides the position setter to recompute the projection texture view light Matrix.
  43789. */
  43790. protected _setPosition(value: Vector3): void;
  43791. /**
  43792. * 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.
  43793. * Returns the SpotLight.
  43794. */
  43795. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43796. protected _computeProjectionTextureViewLightMatrix(): void;
  43797. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43798. /**
  43799. * Main function for light texture projection matrix computing.
  43800. */
  43801. protected _computeProjectionTextureMatrix(): void;
  43802. protected _buildUniformLayout(): void;
  43803. private _computeAngleValues;
  43804. /**
  43805. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43806. * @param effect The effect to update
  43807. * @param lightIndex The index of the light in the effect to update
  43808. * @returns The spot light
  43809. */
  43810. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43811. /**
  43812. * Disposes the light and the associated resources.
  43813. */
  43814. dispose(): void;
  43815. /**
  43816. * Prepares the list of defines specific to the light type.
  43817. * @param defines the list of defines
  43818. * @param lightIndex defines the index of the light for the effect
  43819. */
  43820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43821. }
  43822. }
  43823. declare module BABYLON {
  43824. /**
  43825. * Gizmo that enables viewing a light
  43826. */
  43827. export class LightGizmo extends Gizmo {
  43828. private _lightMesh;
  43829. private _material;
  43830. private cachedPosition;
  43831. private cachedForward;
  43832. /**
  43833. * Creates a LightGizmo
  43834. * @param gizmoLayer The utility layer the gizmo will be added to
  43835. */
  43836. constructor(gizmoLayer?: UtilityLayerRenderer);
  43837. private _light;
  43838. /**
  43839. * The light that the gizmo is attached to
  43840. */
  43841. light: Nullable<Light>;
  43842. /**
  43843. * @hidden
  43844. * Updates the gizmo to match the attached mesh's position/rotation
  43845. */
  43846. protected _update(): void;
  43847. private static _Scale;
  43848. /**
  43849. * Creates the lines for a light mesh
  43850. */
  43851. private static _createLightLines;
  43852. /**
  43853. * Disposes of the light gizmo
  43854. */
  43855. dispose(): void;
  43856. private static _CreateHemisphericLightMesh;
  43857. private static _CreatePointLightMesh;
  43858. private static _CreateSpotLightMesh;
  43859. private static _CreateDirectionalLightMesh;
  43860. }
  43861. }
  43862. declare module BABYLON {
  43863. /** @hidden */
  43864. export var backgroundFragmentDeclaration: {
  43865. name: string;
  43866. shader: string;
  43867. };
  43868. }
  43869. declare module BABYLON {
  43870. /** @hidden */
  43871. export var backgroundUboDeclaration: {
  43872. name: string;
  43873. shader: string;
  43874. };
  43875. }
  43876. declare module BABYLON {
  43877. /** @hidden */
  43878. export var backgroundPixelShader: {
  43879. name: string;
  43880. shader: string;
  43881. };
  43882. }
  43883. declare module BABYLON {
  43884. /** @hidden */
  43885. export var backgroundVertexDeclaration: {
  43886. name: string;
  43887. shader: string;
  43888. };
  43889. }
  43890. declare module BABYLON {
  43891. /** @hidden */
  43892. export var backgroundVertexShader: {
  43893. name: string;
  43894. shader: string;
  43895. };
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Background material used to create an efficient environement around your scene.
  43900. */
  43901. export class BackgroundMaterial extends PushMaterial {
  43902. /**
  43903. * Standard reflectance value at parallel view angle.
  43904. */
  43905. static StandardReflectance0: number;
  43906. /**
  43907. * Standard reflectance value at grazing angle.
  43908. */
  43909. static StandardReflectance90: number;
  43910. protected _primaryColor: Color3;
  43911. /**
  43912. * Key light Color (multiply against the environement texture)
  43913. */
  43914. primaryColor: Color3;
  43915. protected __perceptualColor: Nullable<Color3>;
  43916. /**
  43917. * Experimental Internal Use Only.
  43918. *
  43919. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43920. * This acts as a helper to set the primary color to a more "human friendly" value.
  43921. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43922. * output color as close as possible from the chosen value.
  43923. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43924. * part of lighting setup.)
  43925. */
  43926. _perceptualColor: Nullable<Color3>;
  43927. protected _primaryColorShadowLevel: float;
  43928. /**
  43929. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43930. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43931. */
  43932. primaryColorShadowLevel: float;
  43933. protected _primaryColorHighlightLevel: float;
  43934. /**
  43935. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43936. * The primary color is used at the level chosen to define what the white area would look.
  43937. */
  43938. primaryColorHighlightLevel: float;
  43939. protected _reflectionTexture: Nullable<BaseTexture>;
  43940. /**
  43941. * Reflection Texture used in the material.
  43942. * Should be author in a specific way for the best result (refer to the documentation).
  43943. */
  43944. reflectionTexture: Nullable<BaseTexture>;
  43945. protected _reflectionBlur: float;
  43946. /**
  43947. * Reflection Texture level of blur.
  43948. *
  43949. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43950. * texture twice.
  43951. */
  43952. reflectionBlur: float;
  43953. protected _diffuseTexture: Nullable<BaseTexture>;
  43954. /**
  43955. * Diffuse Texture used in the material.
  43956. * Should be author in a specific way for the best result (refer to the documentation).
  43957. */
  43958. diffuseTexture: Nullable<BaseTexture>;
  43959. protected _shadowLights: Nullable<IShadowLight[]>;
  43960. /**
  43961. * Specify the list of lights casting shadow on the material.
  43962. * All scene shadow lights will be included if null.
  43963. */
  43964. shadowLights: Nullable<IShadowLight[]>;
  43965. protected _shadowLevel: float;
  43966. /**
  43967. * Helps adjusting the shadow to a softer level if required.
  43968. * 0 means black shadows and 1 means no shadows.
  43969. */
  43970. shadowLevel: float;
  43971. protected _sceneCenter: Vector3;
  43972. /**
  43973. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43974. * It is usually zero but might be interesting to modify according to your setup.
  43975. */
  43976. sceneCenter: Vector3;
  43977. protected _opacityFresnel: boolean;
  43978. /**
  43979. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43980. * This helps ensuring a nice transition when the camera goes under the ground.
  43981. */
  43982. opacityFresnel: boolean;
  43983. protected _reflectionFresnel: boolean;
  43984. /**
  43985. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43986. * This helps adding a mirror texture on the ground.
  43987. */
  43988. reflectionFresnel: boolean;
  43989. protected _reflectionFalloffDistance: number;
  43990. /**
  43991. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43992. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43993. */
  43994. reflectionFalloffDistance: number;
  43995. protected _reflectionAmount: number;
  43996. /**
  43997. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43998. */
  43999. reflectionAmount: number;
  44000. protected _reflectionReflectance0: number;
  44001. /**
  44002. * This specifies the weight of the reflection at grazing angle.
  44003. */
  44004. reflectionReflectance0: number;
  44005. protected _reflectionReflectance90: number;
  44006. /**
  44007. * This specifies the weight of the reflection at a perpendicular point of view.
  44008. */
  44009. reflectionReflectance90: number;
  44010. /**
  44011. * Sets the reflection reflectance fresnel values according to the default standard
  44012. * empirically know to work well :-)
  44013. */
  44014. reflectionStandardFresnelWeight: number;
  44015. protected _useRGBColor: boolean;
  44016. /**
  44017. * Helps to directly use the maps channels instead of their level.
  44018. */
  44019. useRGBColor: boolean;
  44020. protected _enableNoise: boolean;
  44021. /**
  44022. * This helps reducing the banding effect that could occur on the background.
  44023. */
  44024. enableNoise: boolean;
  44025. /**
  44026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44027. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44028. * Recommended to be keep at 1.0 except for special cases.
  44029. */
  44030. fovMultiplier: number;
  44031. private _fovMultiplier;
  44032. /**
  44033. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44034. */
  44035. useEquirectangularFOV: boolean;
  44036. private _maxSimultaneousLights;
  44037. /**
  44038. * Number of Simultaneous lights allowed on the material.
  44039. */
  44040. maxSimultaneousLights: int;
  44041. /**
  44042. * Default configuration related to image processing available in the Background Material.
  44043. */
  44044. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44045. /**
  44046. * Keep track of the image processing observer to allow dispose and replace.
  44047. */
  44048. private _imageProcessingObserver;
  44049. /**
  44050. * Attaches a new image processing configuration to the PBR Material.
  44051. * @param configuration (if null the scene configuration will be use)
  44052. */
  44053. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44054. /**
  44055. * Gets the image processing configuration used either in this material.
  44056. */
  44057. /**
  44058. * Sets the Default image processing configuration used either in the this material.
  44059. *
  44060. * If sets to null, the scene one is in use.
  44061. */
  44062. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44063. /**
  44064. * Gets wether the color curves effect is enabled.
  44065. */
  44066. /**
  44067. * Sets wether the color curves effect is enabled.
  44068. */
  44069. cameraColorCurvesEnabled: boolean;
  44070. /**
  44071. * Gets wether the color grading effect is enabled.
  44072. */
  44073. /**
  44074. * Gets wether the color grading effect is enabled.
  44075. */
  44076. cameraColorGradingEnabled: boolean;
  44077. /**
  44078. * Gets wether tonemapping is enabled or not.
  44079. */
  44080. /**
  44081. * Sets wether tonemapping is enabled or not
  44082. */
  44083. cameraToneMappingEnabled: boolean;
  44084. /**
  44085. * The camera exposure used on this material.
  44086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44087. * This corresponds to a photographic exposure.
  44088. */
  44089. /**
  44090. * The camera exposure used on this material.
  44091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44092. * This corresponds to a photographic exposure.
  44093. */
  44094. cameraExposure: float;
  44095. /**
  44096. * Gets The camera contrast used on this material.
  44097. */
  44098. /**
  44099. * Sets The camera contrast used on this material.
  44100. */
  44101. cameraContrast: float;
  44102. /**
  44103. * Gets the Color Grading 2D Lookup Texture.
  44104. */
  44105. /**
  44106. * Sets the Color Grading 2D Lookup Texture.
  44107. */
  44108. cameraColorGradingTexture: Nullable<BaseTexture>;
  44109. /**
  44110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44112. * 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;
  44113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44114. */
  44115. /**
  44116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44118. * 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;
  44119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44120. */
  44121. cameraColorCurves: Nullable<ColorCurves>;
  44122. /**
  44123. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44124. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44125. */
  44126. switchToBGR: boolean;
  44127. private _renderTargets;
  44128. private _reflectionControls;
  44129. private _white;
  44130. private _primaryShadowColor;
  44131. private _primaryHighlightColor;
  44132. /**
  44133. * Instantiates a Background Material in the given scene
  44134. * @param name The friendly name of the material
  44135. * @param scene The scene to add the material to
  44136. */
  44137. constructor(name: string, scene: Scene);
  44138. /**
  44139. * Gets a boolean indicating that current material needs to register RTT
  44140. */
  44141. readonly hasRenderTargetTextures: boolean;
  44142. /**
  44143. * The entire material has been created in order to prevent overdraw.
  44144. * @returns false
  44145. */
  44146. needAlphaTesting(): boolean;
  44147. /**
  44148. * The entire material has been created in order to prevent overdraw.
  44149. * @returns true if blending is enable
  44150. */
  44151. needAlphaBlending(): boolean;
  44152. /**
  44153. * Checks wether the material is ready to be rendered for a given mesh.
  44154. * @param mesh The mesh to render
  44155. * @param subMesh The submesh to check against
  44156. * @param useInstances Specify wether or not the material is used with instances
  44157. * @returns true if all the dependencies are ready (Textures, Effects...)
  44158. */
  44159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44160. /**
  44161. * Compute the primary color according to the chosen perceptual color.
  44162. */
  44163. private _computePrimaryColorFromPerceptualColor;
  44164. /**
  44165. * Compute the highlights and shadow colors according to their chosen levels.
  44166. */
  44167. private _computePrimaryColors;
  44168. /**
  44169. * Build the uniform buffer used in the material.
  44170. */
  44171. buildUniformLayout(): void;
  44172. /**
  44173. * Unbind the material.
  44174. */
  44175. unbind(): void;
  44176. /**
  44177. * Bind only the world matrix to the material.
  44178. * @param world The world matrix to bind.
  44179. */
  44180. bindOnlyWorldMatrix(world: Matrix): void;
  44181. /**
  44182. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44183. * @param world The world matrix to bind.
  44184. * @param subMesh The submesh to bind for.
  44185. */
  44186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44187. /**
  44188. * Dispose the material.
  44189. * @param forceDisposeEffect Force disposal of the associated effect.
  44190. * @param forceDisposeTextures Force disposal of the associated textures.
  44191. */
  44192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44193. /**
  44194. * Clones the material.
  44195. * @param name The cloned name.
  44196. * @returns The cloned material.
  44197. */
  44198. clone(name: string): BackgroundMaterial;
  44199. /**
  44200. * Serializes the current material to its JSON representation.
  44201. * @returns The JSON representation.
  44202. */
  44203. serialize(): any;
  44204. /**
  44205. * Gets the class name of the material
  44206. * @returns "BackgroundMaterial"
  44207. */
  44208. getClassName(): string;
  44209. /**
  44210. * Parse a JSON input to create back a background material.
  44211. * @param source The JSON data to parse
  44212. * @param scene The scene to create the parsed material in
  44213. * @param rootUrl The root url of the assets the material depends upon
  44214. * @returns the instantiated BackgroundMaterial.
  44215. */
  44216. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44217. }
  44218. }
  44219. declare module BABYLON {
  44220. /**
  44221. * Represents the different options available during the creation of
  44222. * a Environment helper.
  44223. *
  44224. * This can control the default ground, skybox and image processing setup of your scene.
  44225. */
  44226. export interface IEnvironmentHelperOptions {
  44227. /**
  44228. * Specifies wether or not to create a ground.
  44229. * True by default.
  44230. */
  44231. createGround: boolean;
  44232. /**
  44233. * Specifies the ground size.
  44234. * 15 by default.
  44235. */
  44236. groundSize: number;
  44237. /**
  44238. * The texture used on the ground for the main color.
  44239. * Comes from the BabylonJS CDN by default.
  44240. *
  44241. * Remarks: Can be either a texture or a url.
  44242. */
  44243. groundTexture: string | BaseTexture;
  44244. /**
  44245. * The color mixed in the ground texture by default.
  44246. * BabylonJS clearColor by default.
  44247. */
  44248. groundColor: Color3;
  44249. /**
  44250. * Specifies the ground opacity.
  44251. * 1 by default.
  44252. */
  44253. groundOpacity: number;
  44254. /**
  44255. * Enables the ground to receive shadows.
  44256. * True by default.
  44257. */
  44258. enableGroundShadow: boolean;
  44259. /**
  44260. * Helps preventing the shadow to be fully black on the ground.
  44261. * 0.5 by default.
  44262. */
  44263. groundShadowLevel: number;
  44264. /**
  44265. * Creates a mirror texture attach to the ground.
  44266. * false by default.
  44267. */
  44268. enableGroundMirror: boolean;
  44269. /**
  44270. * Specifies the ground mirror size ratio.
  44271. * 0.3 by default as the default kernel is 64.
  44272. */
  44273. groundMirrorSizeRatio: number;
  44274. /**
  44275. * Specifies the ground mirror blur kernel size.
  44276. * 64 by default.
  44277. */
  44278. groundMirrorBlurKernel: number;
  44279. /**
  44280. * Specifies the ground mirror visibility amount.
  44281. * 1 by default
  44282. */
  44283. groundMirrorAmount: number;
  44284. /**
  44285. * Specifies the ground mirror reflectance weight.
  44286. * This uses the standard weight of the background material to setup the fresnel effect
  44287. * of the mirror.
  44288. * 1 by default.
  44289. */
  44290. groundMirrorFresnelWeight: number;
  44291. /**
  44292. * Specifies the ground mirror Falloff distance.
  44293. * This can helps reducing the size of the reflection.
  44294. * 0 by Default.
  44295. */
  44296. groundMirrorFallOffDistance: number;
  44297. /**
  44298. * Specifies the ground mirror texture type.
  44299. * Unsigned Int by Default.
  44300. */
  44301. groundMirrorTextureType: number;
  44302. /**
  44303. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44304. * the shown objects.
  44305. */
  44306. groundYBias: number;
  44307. /**
  44308. * Specifies wether or not to create a skybox.
  44309. * True by default.
  44310. */
  44311. createSkybox: boolean;
  44312. /**
  44313. * Specifies the skybox size.
  44314. * 20 by default.
  44315. */
  44316. skyboxSize: number;
  44317. /**
  44318. * The texture used on the skybox for the main color.
  44319. * Comes from the BabylonJS CDN by default.
  44320. *
  44321. * Remarks: Can be either a texture or a url.
  44322. */
  44323. skyboxTexture: string | BaseTexture;
  44324. /**
  44325. * The color mixed in the skybox texture by default.
  44326. * BabylonJS clearColor by default.
  44327. */
  44328. skyboxColor: Color3;
  44329. /**
  44330. * The background rotation around the Y axis of the scene.
  44331. * This helps aligning the key lights of your scene with the background.
  44332. * 0 by default.
  44333. */
  44334. backgroundYRotation: number;
  44335. /**
  44336. * Compute automatically the size of the elements to best fit with the scene.
  44337. */
  44338. sizeAuto: boolean;
  44339. /**
  44340. * Default position of the rootMesh if autoSize is not true.
  44341. */
  44342. rootPosition: Vector3;
  44343. /**
  44344. * Sets up the image processing in the scene.
  44345. * true by default.
  44346. */
  44347. setupImageProcessing: boolean;
  44348. /**
  44349. * The texture used as your environment texture in the scene.
  44350. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44351. *
  44352. * Remarks: Can be either a texture or a url.
  44353. */
  44354. environmentTexture: string | BaseTexture;
  44355. /**
  44356. * The value of the exposure to apply to the scene.
  44357. * 0.6 by default if setupImageProcessing is true.
  44358. */
  44359. cameraExposure: number;
  44360. /**
  44361. * The value of the contrast to apply to the scene.
  44362. * 1.6 by default if setupImageProcessing is true.
  44363. */
  44364. cameraContrast: number;
  44365. /**
  44366. * Specifies wether or not tonemapping should be enabled in the scene.
  44367. * true by default if setupImageProcessing is true.
  44368. */
  44369. toneMappingEnabled: boolean;
  44370. }
  44371. /**
  44372. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44373. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44374. * It also helps with the default setup of your imageProcessing configuration.
  44375. */
  44376. export class EnvironmentHelper {
  44377. /**
  44378. * Default ground texture URL.
  44379. */
  44380. private static _groundTextureCDNUrl;
  44381. /**
  44382. * Default skybox texture URL.
  44383. */
  44384. private static _skyboxTextureCDNUrl;
  44385. /**
  44386. * Default environment texture URL.
  44387. */
  44388. private static _environmentTextureCDNUrl;
  44389. /**
  44390. * Creates the default options for the helper.
  44391. */
  44392. private static _getDefaultOptions;
  44393. private _rootMesh;
  44394. /**
  44395. * Gets the root mesh created by the helper.
  44396. */
  44397. readonly rootMesh: Mesh;
  44398. private _skybox;
  44399. /**
  44400. * Gets the skybox created by the helper.
  44401. */
  44402. readonly skybox: Nullable<Mesh>;
  44403. private _skyboxTexture;
  44404. /**
  44405. * Gets the skybox texture created by the helper.
  44406. */
  44407. readonly skyboxTexture: Nullable<BaseTexture>;
  44408. private _skyboxMaterial;
  44409. /**
  44410. * Gets the skybox material created by the helper.
  44411. */
  44412. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44413. private _ground;
  44414. /**
  44415. * Gets the ground mesh created by the helper.
  44416. */
  44417. readonly ground: Nullable<Mesh>;
  44418. private _groundTexture;
  44419. /**
  44420. * Gets the ground texture created by the helper.
  44421. */
  44422. readonly groundTexture: Nullable<BaseTexture>;
  44423. private _groundMirror;
  44424. /**
  44425. * Gets the ground mirror created by the helper.
  44426. */
  44427. readonly groundMirror: Nullable<MirrorTexture>;
  44428. /**
  44429. * Gets the ground mirror render list to helps pushing the meshes
  44430. * you wish in the ground reflection.
  44431. */
  44432. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44433. private _groundMaterial;
  44434. /**
  44435. * Gets the ground material created by the helper.
  44436. */
  44437. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44438. /**
  44439. * Stores the creation options.
  44440. */
  44441. private readonly _scene;
  44442. private _options;
  44443. /**
  44444. * This observable will be notified with any error during the creation of the environment,
  44445. * mainly texture creation errors.
  44446. */
  44447. onErrorObservable: Observable<{
  44448. message?: string;
  44449. exception?: any;
  44450. }>;
  44451. /**
  44452. * constructor
  44453. * @param options Defines the options we want to customize the helper
  44454. * @param scene The scene to add the material to
  44455. */
  44456. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44457. /**
  44458. * Updates the background according to the new options
  44459. * @param options
  44460. */
  44461. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44462. /**
  44463. * Sets the primary color of all the available elements.
  44464. * @param color the main color to affect to the ground and the background
  44465. */
  44466. setMainColor(color: Color3): void;
  44467. /**
  44468. * Setup the image processing according to the specified options.
  44469. */
  44470. private _setupImageProcessing;
  44471. /**
  44472. * Setup the environment texture according to the specified options.
  44473. */
  44474. private _setupEnvironmentTexture;
  44475. /**
  44476. * Setup the background according to the specified options.
  44477. */
  44478. private _setupBackground;
  44479. /**
  44480. * Get the scene sizes according to the setup.
  44481. */
  44482. private _getSceneSize;
  44483. /**
  44484. * Setup the ground according to the specified options.
  44485. */
  44486. private _setupGround;
  44487. /**
  44488. * Setup the ground material according to the specified options.
  44489. */
  44490. private _setupGroundMaterial;
  44491. /**
  44492. * Setup the ground diffuse texture according to the specified options.
  44493. */
  44494. private _setupGroundDiffuseTexture;
  44495. /**
  44496. * Setup the ground mirror texture according to the specified options.
  44497. */
  44498. private _setupGroundMirrorTexture;
  44499. /**
  44500. * Setup the ground to receive the mirror texture.
  44501. */
  44502. private _setupMirrorInGroundMaterial;
  44503. /**
  44504. * Setup the skybox according to the specified options.
  44505. */
  44506. private _setupSkybox;
  44507. /**
  44508. * Setup the skybox material according to the specified options.
  44509. */
  44510. private _setupSkyboxMaterial;
  44511. /**
  44512. * Setup the skybox reflection texture according to the specified options.
  44513. */
  44514. private _setupSkyboxReflectionTexture;
  44515. private _errorHandler;
  44516. /**
  44517. * Dispose all the elements created by the Helper.
  44518. */
  44519. dispose(): void;
  44520. }
  44521. }
  44522. declare module BABYLON {
  44523. /**
  44524. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44525. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44526. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44527. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44528. */
  44529. export class PhotoDome extends TransformNode {
  44530. /**
  44531. * Define the image as a Monoscopic panoramic 360 image.
  44532. */
  44533. static readonly MODE_MONOSCOPIC: number;
  44534. /**
  44535. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44536. */
  44537. static readonly MODE_TOPBOTTOM: number;
  44538. /**
  44539. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44540. */
  44541. static readonly MODE_SIDEBYSIDE: number;
  44542. private _useDirectMapping;
  44543. /**
  44544. * The texture being displayed on the sphere
  44545. */
  44546. protected _photoTexture: Texture;
  44547. /**
  44548. * Gets or sets the texture being displayed on the sphere
  44549. */
  44550. photoTexture: Texture;
  44551. /**
  44552. * Observable raised when an error occured while loading the 360 image
  44553. */
  44554. onLoadErrorObservable: Observable<string>;
  44555. /**
  44556. * The skybox material
  44557. */
  44558. protected _material: BackgroundMaterial;
  44559. /**
  44560. * The surface used for the skybox
  44561. */
  44562. protected _mesh: Mesh;
  44563. /**
  44564. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44565. * Also see the options.resolution property.
  44566. */
  44567. fovMultiplier: number;
  44568. private _imageMode;
  44569. /**
  44570. * Gets or set the current video mode for the video. It can be:
  44571. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44572. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44573. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44574. */
  44575. imageMode: number;
  44576. /**
  44577. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44578. * @param name Element's name, child elements will append suffixes for their own names.
  44579. * @param urlsOfPhoto defines the url of the photo to display
  44580. * @param options defines an object containing optional or exposed sub element properties
  44581. * @param onError defines a callback called when an error occured while loading the texture
  44582. */
  44583. constructor(name: string, urlOfPhoto: string, options: {
  44584. resolution?: number;
  44585. size?: number;
  44586. useDirectMapping?: boolean;
  44587. faceForward?: boolean;
  44588. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44589. private _onBeforeCameraRenderObserver;
  44590. private _changeImageMode;
  44591. /**
  44592. * Releases resources associated with this node.
  44593. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44594. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44595. */
  44596. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44597. }
  44598. }
  44599. declare module BABYLON {
  44600. /** @hidden */
  44601. export var rgbdDecodePixelShader: {
  44602. name: string;
  44603. shader: string;
  44604. };
  44605. }
  44606. declare module BABYLON {
  44607. /**
  44608. * Class used to host texture specific utilities
  44609. */
  44610. export class BRDFTextureTools {
  44611. /**
  44612. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44613. * @param texture the texture to expand.
  44614. */
  44615. private static _ExpandDefaultBRDFTexture;
  44616. /**
  44617. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44618. * @param scene defines the hosting scene
  44619. * @returns the environment BRDF texture
  44620. */
  44621. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44622. private static _environmentBRDFBase64Texture;
  44623. }
  44624. }
  44625. declare module BABYLON {
  44626. /**
  44627. * @hidden
  44628. */
  44629. export interface IMaterialClearCoatDefines {
  44630. CLEARCOAT: boolean;
  44631. CLEARCOAT_DEFAULTIOR: boolean;
  44632. CLEARCOAT_TEXTURE: boolean;
  44633. CLEARCOAT_TEXTUREDIRECTUV: number;
  44634. CLEARCOAT_BUMP: boolean;
  44635. CLEARCOAT_BUMPDIRECTUV: number;
  44636. CLEARCOAT_TINT: boolean;
  44637. CLEARCOAT_TINT_TEXTURE: boolean;
  44638. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44639. /** @hidden */
  44640. _areTexturesDirty: boolean;
  44641. }
  44642. /**
  44643. * Define the code related to the clear coat parameters of the pbr material.
  44644. */
  44645. export class PBRClearCoatConfiguration {
  44646. /**
  44647. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44648. * The default fits with a polyurethane material.
  44649. */
  44650. private static readonly _DefaultIndexOfRefraction;
  44651. private _isEnabled;
  44652. /**
  44653. * Defines if the clear coat is enabled in the material.
  44654. */
  44655. isEnabled: boolean;
  44656. /**
  44657. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44658. */
  44659. intensity: number;
  44660. /**
  44661. * Defines the clear coat layer roughness.
  44662. */
  44663. roughness: number;
  44664. private _indexOfRefraction;
  44665. /**
  44666. * Defines the index of refraction of the clear coat.
  44667. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44668. * The default fits with a polyurethane material.
  44669. * Changing the default value is more performance intensive.
  44670. */
  44671. indexOfRefraction: number;
  44672. private _texture;
  44673. /**
  44674. * Stores the clear coat values in a texture.
  44675. */
  44676. texture: Nullable<BaseTexture>;
  44677. private _bumpTexture;
  44678. /**
  44679. * Define the clear coat specific bump texture.
  44680. */
  44681. bumpTexture: Nullable<BaseTexture>;
  44682. private _isTintEnabled;
  44683. /**
  44684. * Defines if the clear coat tint is enabled in the material.
  44685. */
  44686. isTintEnabled: boolean;
  44687. /**
  44688. * Defines the clear coat tint of the material.
  44689. * This is only use if tint is enabled
  44690. */
  44691. tintColor: Color3;
  44692. /**
  44693. * Defines the distance at which the tint color should be found in the
  44694. * clear coat media.
  44695. * This is only use if tint is enabled
  44696. */
  44697. tintColorAtDistance: number;
  44698. /**
  44699. * Defines the clear coat layer thickness.
  44700. * This is only use if tint is enabled
  44701. */
  44702. tintThickness: number;
  44703. private _tintTexture;
  44704. /**
  44705. * Stores the clear tint values in a texture.
  44706. * rgb is tint
  44707. * a is a thickness factor
  44708. */
  44709. tintTexture: Nullable<BaseTexture>;
  44710. /** @hidden */
  44711. private _internalMarkAllSubMeshesAsTexturesDirty;
  44712. /** @hidden */
  44713. _markAllSubMeshesAsTexturesDirty(): void;
  44714. /**
  44715. * Instantiate a new istance of clear coat configuration.
  44716. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44717. */
  44718. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44719. /**
  44720. * Gets wehter the submesh is ready to be used or not.
  44721. * @param defines the list of "defines" to update.
  44722. * @param scene defines the scene the material belongs to.
  44723. * @param engine defines the engine the material belongs to.
  44724. * @param disableBumpMap defines wether the material disables bump or not.
  44725. * @returns - boolean indicating that the submesh is ready or not.
  44726. */
  44727. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44728. /**
  44729. * Checks to see if a texture is used in the material.
  44730. * @param defines the list of "defines" to update.
  44731. * @param scene defines the scene to the material belongs to.
  44732. */
  44733. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44734. /**
  44735. * Binds the material data.
  44736. * @param uniformBuffer defines the Uniform buffer to fill in.
  44737. * @param scene defines the scene the material belongs to.
  44738. * @param engine defines the engine the material belongs to.
  44739. * @param disableBumpMap defines wether the material disables bump or not.
  44740. * @param isFrozen defines wether the material is frozen or not.
  44741. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44742. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44743. */
  44744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44745. /**
  44746. * Checks to see if a texture is used in the material.
  44747. * @param texture - Base texture to use.
  44748. * @returns - Boolean specifying if a texture is used in the material.
  44749. */
  44750. hasTexture(texture: BaseTexture): boolean;
  44751. /**
  44752. * Returns an array of the actively used textures.
  44753. * @param activeTextures Array of BaseTextures
  44754. */
  44755. getActiveTextures(activeTextures: BaseTexture[]): void;
  44756. /**
  44757. * Returns the animatable textures.
  44758. * @param animatables Array of animatable textures.
  44759. */
  44760. getAnimatables(animatables: IAnimatable[]): void;
  44761. /**
  44762. * Disposes the resources of the material.
  44763. * @param forceDisposeTextures - Forces the disposal of all textures.
  44764. */
  44765. dispose(forceDisposeTextures?: boolean): void;
  44766. /**
  44767. * Get the current class name of the texture useful for serialization or dynamic coding.
  44768. * @returns "PBRClearCoatConfiguration"
  44769. */
  44770. getClassName(): string;
  44771. /**
  44772. * Add fallbacks to the effect fallbacks list.
  44773. * @param defines defines the Base texture to use.
  44774. * @param fallbacks defines the current fallback list.
  44775. * @param currentRank defines the current fallback rank.
  44776. * @returns the new fallback rank.
  44777. */
  44778. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44779. /**
  44780. * Add the required uniforms to the current list.
  44781. * @param uniforms defines the current uniform list.
  44782. */
  44783. static AddUniforms(uniforms: string[]): void;
  44784. /**
  44785. * Add the required samplers to the current list.
  44786. * @param samplers defines the current sampler list.
  44787. */
  44788. static AddSamplers(samplers: string[]): void;
  44789. /**
  44790. * Add the required uniforms to the current buffer.
  44791. * @param uniformBuffer defines the current uniform buffer.
  44792. */
  44793. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44794. /**
  44795. * Makes a duplicate of the current configuration into another one.
  44796. * @param clearCoatConfiguration define the config where to copy the info
  44797. */
  44798. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44799. /**
  44800. * Serializes this clear coat configuration.
  44801. * @returns - An object with the serialized config.
  44802. */
  44803. serialize(): any;
  44804. /**
  44805. * Parses a anisotropy Configuration from a serialized object.
  44806. * @param source - Serialized object.
  44807. * @param scene Defines the scene we are parsing for
  44808. * @param rootUrl Defines the rootUrl to load from
  44809. */
  44810. parse(source: any, scene: Scene, rootUrl: string): void;
  44811. }
  44812. }
  44813. declare module BABYLON {
  44814. /**
  44815. * @hidden
  44816. */
  44817. export interface IMaterialAnisotropicDefines {
  44818. ANISOTROPIC: boolean;
  44819. ANISOTROPIC_TEXTURE: boolean;
  44820. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44821. MAINUV1: boolean;
  44822. _areTexturesDirty: boolean;
  44823. _needUVs: boolean;
  44824. }
  44825. /**
  44826. * Define the code related to the anisotropic parameters of the pbr material.
  44827. */
  44828. export class PBRAnisotropicConfiguration {
  44829. private _isEnabled;
  44830. /**
  44831. * Defines if the anisotropy is enabled in the material.
  44832. */
  44833. isEnabled: boolean;
  44834. /**
  44835. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44836. */
  44837. intensity: number;
  44838. /**
  44839. * Defines if the effect is along the tangents, bitangents or in between.
  44840. * By default, the effect is "strectching" the highlights along the tangents.
  44841. */
  44842. direction: Vector2;
  44843. private _texture;
  44844. /**
  44845. * Stores the anisotropy values in a texture.
  44846. * rg is direction (like normal from -1 to 1)
  44847. * b is a intensity
  44848. */
  44849. texture: Nullable<BaseTexture>;
  44850. /** @hidden */
  44851. private _internalMarkAllSubMeshesAsTexturesDirty;
  44852. /** @hidden */
  44853. _markAllSubMeshesAsTexturesDirty(): void;
  44854. /**
  44855. * Instantiate a new istance of anisotropy configuration.
  44856. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44857. */
  44858. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44859. /**
  44860. * Specifies that the submesh is ready to be used.
  44861. * @param defines the list of "defines" to update.
  44862. * @param scene defines the scene the material belongs to.
  44863. * @returns - boolean indicating that the submesh is ready or not.
  44864. */
  44865. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44866. /**
  44867. * Checks to see if a texture is used in the material.
  44868. * @param defines the list of "defines" to update.
  44869. * @param mesh the mesh we are preparing the defines for.
  44870. * @param scene defines the scene the material belongs to.
  44871. */
  44872. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44873. /**
  44874. * Binds the material data.
  44875. * @param uniformBuffer defines the Uniform buffer to fill in.
  44876. * @param scene defines the scene the material belongs to.
  44877. * @param isFrozen defines wether the material is frozen or not.
  44878. */
  44879. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44880. /**
  44881. * Checks to see if a texture is used in the material.
  44882. * @param texture - Base texture to use.
  44883. * @returns - Boolean specifying if a texture is used in the material.
  44884. */
  44885. hasTexture(texture: BaseTexture): boolean;
  44886. /**
  44887. * Returns an array of the actively used textures.
  44888. * @param activeTextures Array of BaseTextures
  44889. */
  44890. getActiveTextures(activeTextures: BaseTexture[]): void;
  44891. /**
  44892. * Returns the animatable textures.
  44893. * @param animatables Array of animatable textures.
  44894. */
  44895. getAnimatables(animatables: IAnimatable[]): void;
  44896. /**
  44897. * Disposes the resources of the material.
  44898. * @param forceDisposeTextures - Forces the disposal of all textures.
  44899. */
  44900. dispose(forceDisposeTextures?: boolean): void;
  44901. /**
  44902. * Get the current class name of the texture useful for serialization or dynamic coding.
  44903. * @returns "PBRAnisotropicConfiguration"
  44904. */
  44905. getClassName(): string;
  44906. /**
  44907. * Add fallbacks to the effect fallbacks list.
  44908. * @param defines defines the Base texture to use.
  44909. * @param fallbacks defines the current fallback list.
  44910. * @param currentRank defines the current fallback rank.
  44911. * @returns the new fallback rank.
  44912. */
  44913. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44914. /**
  44915. * Add the required uniforms to the current list.
  44916. * @param uniforms defines the current uniform list.
  44917. */
  44918. static AddUniforms(uniforms: string[]): void;
  44919. /**
  44920. * Add the required uniforms to the current buffer.
  44921. * @param uniformBuffer defines the current uniform buffer.
  44922. */
  44923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44924. /**
  44925. * Add the required samplers to the current list.
  44926. * @param samplers defines the current sampler list.
  44927. */
  44928. static AddSamplers(samplers: string[]): void;
  44929. /**
  44930. * Makes a duplicate of the current configuration into another one.
  44931. * @param anisotropicConfiguration define the config where to copy the info
  44932. */
  44933. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44934. /**
  44935. * Serializes this anisotropy configuration.
  44936. * @returns - An object with the serialized config.
  44937. */
  44938. serialize(): any;
  44939. /**
  44940. * Parses a anisotropy Configuration from a serialized object.
  44941. * @param source - Serialized object.
  44942. * @param scene Defines the scene we are parsing for
  44943. * @param rootUrl Defines the rootUrl to load from
  44944. */
  44945. parse(source: any, scene: Scene, rootUrl: string): void;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /**
  44950. * @hidden
  44951. */
  44952. export interface IMaterialBRDFDefines {
  44953. BRDF_V_HEIGHT_CORRELATED: boolean;
  44954. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44955. SPHERICAL_HARMONICS: boolean;
  44956. /** @hidden */
  44957. _areMiscDirty: boolean;
  44958. }
  44959. /**
  44960. * Define the code related to the BRDF parameters of the pbr material.
  44961. */
  44962. export class PBRBRDFConfiguration {
  44963. /**
  44964. * Default value used for the energy conservation.
  44965. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44966. */
  44967. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44968. /**
  44969. * Default value used for the Smith Visibility Height Correlated mode.
  44970. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44971. */
  44972. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44973. /**
  44974. * Default value used for the IBL diffuse part.
  44975. * This can help switching back to the polynomials mode globally which is a tiny bit
  44976. * less GPU intensive at the drawback of a lower quality.
  44977. */
  44978. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44979. private _useEnergyConservation;
  44980. /**
  44981. * Defines if the material uses energy conservation.
  44982. */
  44983. useEnergyConservation: boolean;
  44984. private _useSmithVisibilityHeightCorrelated;
  44985. /**
  44986. * LEGACY Mode set to false
  44987. * Defines if the material uses height smith correlated visibility term.
  44988. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44989. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44990. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44991. * Not relying on height correlated will also disable energy conservation.
  44992. */
  44993. useSmithVisibilityHeightCorrelated: boolean;
  44994. private _useSphericalHarmonics;
  44995. /**
  44996. * LEGACY Mode set to false
  44997. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44998. * diffuse part of the IBL.
  44999. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45000. * to the ground truth.
  45001. */
  45002. useSphericalHarmonics: boolean;
  45003. /** @hidden */
  45004. private _internalMarkAllSubMeshesAsMiscDirty;
  45005. /** @hidden */
  45006. _markAllSubMeshesAsMiscDirty(): void;
  45007. /**
  45008. * Instantiate a new istance of clear coat configuration.
  45009. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45010. */
  45011. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45012. /**
  45013. * Checks to see if a texture is used in the material.
  45014. * @param defines the list of "defines" to update.
  45015. */
  45016. prepareDefines(defines: IMaterialBRDFDefines): void;
  45017. /**
  45018. * Get the current class name of the texture useful for serialization or dynamic coding.
  45019. * @returns "PBRClearCoatConfiguration"
  45020. */
  45021. getClassName(): string;
  45022. /**
  45023. * Makes a duplicate of the current configuration into another one.
  45024. * @param brdfConfiguration define the config where to copy the info
  45025. */
  45026. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45027. /**
  45028. * Serializes this BRDF configuration.
  45029. * @returns - An object with the serialized config.
  45030. */
  45031. serialize(): any;
  45032. /**
  45033. * Parses a anisotropy Configuration from a serialized object.
  45034. * @param source - Serialized object.
  45035. * @param scene Defines the scene we are parsing for
  45036. * @param rootUrl Defines the rootUrl to load from
  45037. */
  45038. parse(source: any, scene: Scene, rootUrl: string): void;
  45039. }
  45040. }
  45041. declare module BABYLON {
  45042. /**
  45043. * @hidden
  45044. */
  45045. export interface IMaterialSheenDefines {
  45046. SHEEN: boolean;
  45047. SHEEN_TEXTURE: boolean;
  45048. SHEEN_TEXTUREDIRECTUV: number;
  45049. SHEEN_LINKWITHALBEDO: boolean;
  45050. /** @hidden */
  45051. _areTexturesDirty: boolean;
  45052. }
  45053. /**
  45054. * Define the code related to the Sheen parameters of the pbr material.
  45055. */
  45056. export class PBRSheenConfiguration {
  45057. private _isEnabled;
  45058. /**
  45059. * Defines if the material uses sheen.
  45060. */
  45061. isEnabled: boolean;
  45062. private _linkSheenWithAlbedo;
  45063. /**
  45064. * Defines if the sheen is linked to the sheen color.
  45065. */
  45066. linkSheenWithAlbedo: boolean;
  45067. /**
  45068. * Defines the sheen intensity.
  45069. */
  45070. intensity: number;
  45071. /**
  45072. * Defines the sheen color.
  45073. */
  45074. color: Color3;
  45075. private _texture;
  45076. /**
  45077. * Stores the sheen tint values in a texture.
  45078. * rgb is tint
  45079. * a is a intensity
  45080. */
  45081. texture: Nullable<BaseTexture>;
  45082. /** @hidden */
  45083. private _internalMarkAllSubMeshesAsTexturesDirty;
  45084. /** @hidden */
  45085. _markAllSubMeshesAsTexturesDirty(): void;
  45086. /**
  45087. * Instantiate a new istance of clear coat configuration.
  45088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45089. */
  45090. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45091. /**
  45092. * Specifies that the submesh is ready to be used.
  45093. * @param defines the list of "defines" to update.
  45094. * @param scene defines the scene the material belongs to.
  45095. * @returns - boolean indicating that the submesh is ready or not.
  45096. */
  45097. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45098. /**
  45099. * Checks to see if a texture is used in the material.
  45100. * @param defines the list of "defines" to update.
  45101. * @param scene defines the scene the material belongs to.
  45102. */
  45103. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45104. /**
  45105. * Binds the material data.
  45106. * @param uniformBuffer defines the Uniform buffer to fill in.
  45107. * @param scene defines the scene the material belongs to.
  45108. * @param isFrozen defines wether the material is frozen or not.
  45109. */
  45110. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45111. /**
  45112. * Checks to see if a texture is used in the material.
  45113. * @param texture - Base texture to use.
  45114. * @returns - Boolean specifying if a texture is used in the material.
  45115. */
  45116. hasTexture(texture: BaseTexture): boolean;
  45117. /**
  45118. * Returns an array of the actively used textures.
  45119. * @param activeTextures Array of BaseTextures
  45120. */
  45121. getActiveTextures(activeTextures: BaseTexture[]): void;
  45122. /**
  45123. * Returns the animatable textures.
  45124. * @param animatables Array of animatable textures.
  45125. */
  45126. getAnimatables(animatables: IAnimatable[]): void;
  45127. /**
  45128. * Disposes the resources of the material.
  45129. * @param forceDisposeTextures - Forces the disposal of all textures.
  45130. */
  45131. dispose(forceDisposeTextures?: boolean): void;
  45132. /**
  45133. * Get the current class name of the texture useful for serialization or dynamic coding.
  45134. * @returns "PBRSheenConfiguration"
  45135. */
  45136. getClassName(): string;
  45137. /**
  45138. * Add fallbacks to the effect fallbacks list.
  45139. * @param defines defines the Base texture to use.
  45140. * @param fallbacks defines the current fallback list.
  45141. * @param currentRank defines the current fallback rank.
  45142. * @returns the new fallback rank.
  45143. */
  45144. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45145. /**
  45146. * Add the required uniforms to the current list.
  45147. * @param uniforms defines the current uniform list.
  45148. */
  45149. static AddUniforms(uniforms: string[]): void;
  45150. /**
  45151. * Add the required uniforms to the current buffer.
  45152. * @param uniformBuffer defines the current uniform buffer.
  45153. */
  45154. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45155. /**
  45156. * Add the required samplers to the current list.
  45157. * @param samplers defines the current sampler list.
  45158. */
  45159. static AddSamplers(samplers: string[]): void;
  45160. /**
  45161. * Makes a duplicate of the current configuration into another one.
  45162. * @param sheenConfiguration define the config where to copy the info
  45163. */
  45164. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45165. /**
  45166. * Serializes this BRDF configuration.
  45167. * @returns - An object with the serialized config.
  45168. */
  45169. serialize(): any;
  45170. /**
  45171. * Parses a anisotropy Configuration from a serialized object.
  45172. * @param source - Serialized object.
  45173. * @param scene Defines the scene we are parsing for
  45174. * @param rootUrl Defines the rootUrl to load from
  45175. */
  45176. parse(source: any, scene: Scene, rootUrl: string): void;
  45177. }
  45178. }
  45179. declare module BABYLON {
  45180. /**
  45181. * @hidden
  45182. */
  45183. export interface IMaterialSubSurfaceDefines {
  45184. SUBSURFACE: boolean;
  45185. SS_REFRACTION: boolean;
  45186. SS_TRANSLUCENCY: boolean;
  45187. SS_SCATERRING: boolean;
  45188. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45189. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45190. SS_REFRACTIONMAP_3D: boolean;
  45191. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45192. SS_LODINREFRACTIONALPHA: boolean;
  45193. SS_GAMMAREFRACTION: boolean;
  45194. SS_RGBDREFRACTION: boolean;
  45195. SS_LINEARSPECULARREFRACTION: boolean;
  45196. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45198. /** @hidden */
  45199. _areTexturesDirty: boolean;
  45200. }
  45201. /**
  45202. * Define the code related to the sub surface parameters of the pbr material.
  45203. */
  45204. export class PBRSubSurfaceConfiguration {
  45205. private _isRefractionEnabled;
  45206. /**
  45207. * Defines if the refraction is enabled in the material.
  45208. */
  45209. isRefractionEnabled: boolean;
  45210. private _isTranslucencyEnabled;
  45211. /**
  45212. * Defines if the translucency is enabled in the material.
  45213. */
  45214. isTranslucencyEnabled: boolean;
  45215. private _isScatteringEnabled;
  45216. /**
  45217. * Defines the refraction intensity of the material.
  45218. * The refraction when enabled replaces the Diffuse part of the material.
  45219. * The intensity helps transitionning between diffuse and refraction.
  45220. */
  45221. refractionIntensity: number;
  45222. /**
  45223. * Defines the translucency intensity of the material.
  45224. * When translucency has been enabled, this defines how much of the "translucency"
  45225. * is addded to the diffuse part of the material.
  45226. */
  45227. translucencyIntensity: number;
  45228. /**
  45229. * Defines the scattering intensity of the material.
  45230. * When scattering has been enabled, this defines how much of the "scattered light"
  45231. * is addded to the diffuse part of the material.
  45232. */
  45233. scatteringIntensity: number;
  45234. private _thicknessTexture;
  45235. /**
  45236. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45237. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45238. * 0 would mean minimumThickness
  45239. * 1 would mean maximumThickness
  45240. * The other channels might be use as a mask to vary the different effects intensity.
  45241. */
  45242. thicknessTexture: Nullable<BaseTexture>;
  45243. private _refractionTexture;
  45244. /**
  45245. * Defines the texture to use for refraction.
  45246. */
  45247. refractionTexture: Nullable<BaseTexture>;
  45248. private _indexOfRefraction;
  45249. /**
  45250. * Defines the index of refraction used in the material.
  45251. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45252. */
  45253. indexOfRefraction: number;
  45254. private _invertRefractionY;
  45255. /**
  45256. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45257. */
  45258. invertRefractionY: boolean;
  45259. private _linkRefractionWithTransparency;
  45260. /**
  45261. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45262. * Materials half opaque for instance using refraction could benefit from this control.
  45263. */
  45264. linkRefractionWithTransparency: boolean;
  45265. /**
  45266. * Defines the minimum thickness stored in the thickness map.
  45267. * If no thickness map is defined, this value will be used to simulate thickness.
  45268. */
  45269. minimumThickness: number;
  45270. /**
  45271. * Defines the maximum thickness stored in the thickness map.
  45272. */
  45273. maximumThickness: number;
  45274. /**
  45275. * Defines the volume tint of the material.
  45276. * This is used for both translucency and scattering.
  45277. */
  45278. tintColor: Color3;
  45279. /**
  45280. * Defines the distance at which the tint color should be found in the media.
  45281. * This is used for refraction only.
  45282. */
  45283. tintColorAtDistance: number;
  45284. /**
  45285. * Defines how far each channel transmit through the media.
  45286. * It is defined as a color to simplify it selection.
  45287. */
  45288. diffusionDistance: Color3;
  45289. private _useMaskFromThicknessTexture;
  45290. /**
  45291. * Stores the intensity of the different subsurface effects in the thickness texture.
  45292. * * the green channel is the translucency intensity.
  45293. * * the blue channel is the scattering intensity.
  45294. * * the alpha channel is the refraction intensity.
  45295. */
  45296. useMaskFromThicknessTexture: boolean;
  45297. /** @hidden */
  45298. private _internalMarkAllSubMeshesAsTexturesDirty;
  45299. /** @hidden */
  45300. _markAllSubMeshesAsTexturesDirty(): void;
  45301. /**
  45302. * Instantiate a new istance of sub surface configuration.
  45303. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45304. */
  45305. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45306. /**
  45307. * Gets wehter the submesh is ready to be used or not.
  45308. * @param defines the list of "defines" to update.
  45309. * @param scene defines the scene the material belongs to.
  45310. * @returns - boolean indicating that the submesh is ready or not.
  45311. */
  45312. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45313. /**
  45314. * Checks to see if a texture is used in the material.
  45315. * @param defines the list of "defines" to update.
  45316. * @param scene defines the scene to the material belongs to.
  45317. */
  45318. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45319. /**
  45320. * Binds the material data.
  45321. * @param uniformBuffer defines the Uniform buffer to fill in.
  45322. * @param scene defines the scene the material belongs to.
  45323. * @param engine defines the engine the material belongs to.
  45324. * @param isFrozen defines wether the material is frozen or not.
  45325. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45326. */
  45327. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45328. /**
  45329. * Unbinds the material from the mesh.
  45330. * @param activeEffect defines the effect that should be unbound from.
  45331. * @returns true if unbound, otherwise false
  45332. */
  45333. unbind(activeEffect: Effect): boolean;
  45334. /**
  45335. * Returns the texture used for refraction or null if none is used.
  45336. * @param scene defines the scene the material belongs to.
  45337. * @returns - Refraction texture if present. If no refraction texture and refraction
  45338. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45339. */
  45340. private _getRefractionTexture;
  45341. /**
  45342. * Returns true if alpha blending should be disabled.
  45343. */
  45344. readonly disableAlphaBlending: boolean;
  45345. /**
  45346. * Fills the list of render target textures.
  45347. * @param renderTargets the list of render targets to update
  45348. */
  45349. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45350. /**
  45351. * Checks to see if a texture is used in the material.
  45352. * @param texture - Base texture to use.
  45353. * @returns - Boolean specifying if a texture is used in the material.
  45354. */
  45355. hasTexture(texture: BaseTexture): boolean;
  45356. /**
  45357. * Gets a boolean indicating that current material needs to register RTT
  45358. * @returns true if this uses a render target otherwise false.
  45359. */
  45360. hasRenderTargetTextures(): boolean;
  45361. /**
  45362. * Returns an array of the actively used textures.
  45363. * @param activeTextures Array of BaseTextures
  45364. */
  45365. getActiveTextures(activeTextures: BaseTexture[]): void;
  45366. /**
  45367. * Returns the animatable textures.
  45368. * @param animatables Array of animatable textures.
  45369. */
  45370. getAnimatables(animatables: IAnimatable[]): void;
  45371. /**
  45372. * Disposes the resources of the material.
  45373. * @param forceDisposeTextures - Forces the disposal of all textures.
  45374. */
  45375. dispose(forceDisposeTextures?: boolean): void;
  45376. /**
  45377. * Get the current class name of the texture useful for serialization or dynamic coding.
  45378. * @returns "PBRSubSurfaceConfiguration"
  45379. */
  45380. getClassName(): string;
  45381. /**
  45382. * Add fallbacks to the effect fallbacks list.
  45383. * @param defines defines the Base texture to use.
  45384. * @param fallbacks defines the current fallback list.
  45385. * @param currentRank defines the current fallback rank.
  45386. * @returns the new fallback rank.
  45387. */
  45388. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45389. /**
  45390. * Add the required uniforms to the current list.
  45391. * @param uniforms defines the current uniform list.
  45392. */
  45393. static AddUniforms(uniforms: string[]): void;
  45394. /**
  45395. * Add the required samplers to the current list.
  45396. * @param samplers defines the current sampler list.
  45397. */
  45398. static AddSamplers(samplers: string[]): void;
  45399. /**
  45400. * Add the required uniforms to the current buffer.
  45401. * @param uniformBuffer defines the current uniform buffer.
  45402. */
  45403. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45404. /**
  45405. * Makes a duplicate of the current configuration into another one.
  45406. * @param configuration define the config where to copy the info
  45407. */
  45408. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45409. /**
  45410. * Serializes this Sub Surface configuration.
  45411. * @returns - An object with the serialized config.
  45412. */
  45413. serialize(): any;
  45414. /**
  45415. * Parses a anisotropy Configuration from a serialized object.
  45416. * @param source - Serialized object.
  45417. * @param scene Defines the scene we are parsing for
  45418. * @param rootUrl Defines the rootUrl to load from
  45419. */
  45420. parse(source: any, scene: Scene, rootUrl: string): void;
  45421. }
  45422. }
  45423. declare module BABYLON {
  45424. /** @hidden */
  45425. export var pbrFragmentDeclaration: {
  45426. name: string;
  45427. shader: string;
  45428. };
  45429. }
  45430. declare module BABYLON {
  45431. /** @hidden */
  45432. export var pbrUboDeclaration: {
  45433. name: string;
  45434. shader: string;
  45435. };
  45436. }
  45437. declare module BABYLON {
  45438. /** @hidden */
  45439. export var pbrFragmentExtraDeclaration: {
  45440. name: string;
  45441. shader: string;
  45442. };
  45443. }
  45444. declare module BABYLON {
  45445. /** @hidden */
  45446. export var pbrFragmentSamplersDeclaration: {
  45447. name: string;
  45448. shader: string;
  45449. };
  45450. }
  45451. declare module BABYLON {
  45452. /** @hidden */
  45453. export var pbrHelperFunctions: {
  45454. name: string;
  45455. shader: string;
  45456. };
  45457. }
  45458. declare module BABYLON {
  45459. /** @hidden */
  45460. export var harmonicsFunctions: {
  45461. name: string;
  45462. shader: string;
  45463. };
  45464. }
  45465. declare module BABYLON {
  45466. /** @hidden */
  45467. export var pbrDirectLightingSetupFunctions: {
  45468. name: string;
  45469. shader: string;
  45470. };
  45471. }
  45472. declare module BABYLON {
  45473. /** @hidden */
  45474. export var pbrDirectLightingFalloffFunctions: {
  45475. name: string;
  45476. shader: string;
  45477. };
  45478. }
  45479. declare module BABYLON {
  45480. /** @hidden */
  45481. export var pbrBRDFFunctions: {
  45482. name: string;
  45483. shader: string;
  45484. };
  45485. }
  45486. declare module BABYLON {
  45487. /** @hidden */
  45488. export var pbrDirectLightingFunctions: {
  45489. name: string;
  45490. shader: string;
  45491. };
  45492. }
  45493. declare module BABYLON {
  45494. /** @hidden */
  45495. export var pbrIBLFunctions: {
  45496. name: string;
  45497. shader: string;
  45498. };
  45499. }
  45500. declare module BABYLON {
  45501. /** @hidden */
  45502. export var pbrDebug: {
  45503. name: string;
  45504. shader: string;
  45505. };
  45506. }
  45507. declare module BABYLON {
  45508. /** @hidden */
  45509. export var pbrPixelShader: {
  45510. name: string;
  45511. shader: string;
  45512. };
  45513. }
  45514. declare module BABYLON {
  45515. /** @hidden */
  45516. export var pbrVertexDeclaration: {
  45517. name: string;
  45518. shader: string;
  45519. };
  45520. }
  45521. declare module BABYLON {
  45522. /** @hidden */
  45523. export var pbrVertexShader: {
  45524. name: string;
  45525. shader: string;
  45526. };
  45527. }
  45528. declare module BABYLON {
  45529. /**
  45530. * Manages the defines for the PBR Material.
  45531. * @hidden
  45532. */
  45533. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45534. PBR: boolean;
  45535. MAINUV1: boolean;
  45536. MAINUV2: boolean;
  45537. UV1: boolean;
  45538. UV2: boolean;
  45539. ALBEDO: boolean;
  45540. ALBEDODIRECTUV: number;
  45541. VERTEXCOLOR: boolean;
  45542. AMBIENT: boolean;
  45543. AMBIENTDIRECTUV: number;
  45544. AMBIENTINGRAYSCALE: boolean;
  45545. OPACITY: boolean;
  45546. VERTEXALPHA: boolean;
  45547. OPACITYDIRECTUV: number;
  45548. OPACITYRGB: boolean;
  45549. ALPHATEST: boolean;
  45550. DEPTHPREPASS: boolean;
  45551. ALPHABLEND: boolean;
  45552. ALPHAFROMALBEDO: boolean;
  45553. ALPHATESTVALUE: string;
  45554. SPECULAROVERALPHA: boolean;
  45555. RADIANCEOVERALPHA: boolean;
  45556. ALPHAFRESNEL: boolean;
  45557. LINEARALPHAFRESNEL: boolean;
  45558. PREMULTIPLYALPHA: boolean;
  45559. EMISSIVE: boolean;
  45560. EMISSIVEDIRECTUV: number;
  45561. REFLECTIVITY: boolean;
  45562. REFLECTIVITYDIRECTUV: number;
  45563. SPECULARTERM: boolean;
  45564. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45565. MICROSURFACEAUTOMATIC: boolean;
  45566. LODBASEDMICROSFURACE: boolean;
  45567. MICROSURFACEMAP: boolean;
  45568. MICROSURFACEMAPDIRECTUV: number;
  45569. METALLICWORKFLOW: boolean;
  45570. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45571. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45572. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45573. AOSTOREINMETALMAPRED: boolean;
  45574. ENVIRONMENTBRDF: boolean;
  45575. ENVIRONMENTBRDF_RGBD: boolean;
  45576. NORMAL: boolean;
  45577. TANGENT: boolean;
  45578. BUMP: boolean;
  45579. BUMPDIRECTUV: number;
  45580. OBJECTSPACE_NORMALMAP: boolean;
  45581. PARALLAX: boolean;
  45582. PARALLAXOCCLUSION: boolean;
  45583. NORMALXYSCALE: boolean;
  45584. LIGHTMAP: boolean;
  45585. LIGHTMAPDIRECTUV: number;
  45586. USELIGHTMAPASSHADOWMAP: boolean;
  45587. GAMMALIGHTMAP: boolean;
  45588. REFLECTION: boolean;
  45589. REFLECTIONMAP_3D: boolean;
  45590. REFLECTIONMAP_SPHERICAL: boolean;
  45591. REFLECTIONMAP_PLANAR: boolean;
  45592. REFLECTIONMAP_CUBIC: boolean;
  45593. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45594. REFLECTIONMAP_PROJECTION: boolean;
  45595. REFLECTIONMAP_SKYBOX: boolean;
  45596. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45597. REFLECTIONMAP_EXPLICIT: boolean;
  45598. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45599. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45600. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45601. INVERTCUBICMAP: boolean;
  45602. USESPHERICALFROMREFLECTIONMAP: boolean;
  45603. USEIRRADIANCEMAP: boolean;
  45604. SPHERICAL_HARMONICS: boolean;
  45605. USESPHERICALINVERTEX: boolean;
  45606. REFLECTIONMAP_OPPOSITEZ: boolean;
  45607. LODINREFLECTIONALPHA: boolean;
  45608. GAMMAREFLECTION: boolean;
  45609. RGBDREFLECTION: boolean;
  45610. LINEARSPECULARREFLECTION: boolean;
  45611. RADIANCEOCCLUSION: boolean;
  45612. HORIZONOCCLUSION: boolean;
  45613. INSTANCES: boolean;
  45614. NUM_BONE_INFLUENCERS: number;
  45615. BonesPerMesh: number;
  45616. BONETEXTURE: boolean;
  45617. NONUNIFORMSCALING: boolean;
  45618. MORPHTARGETS: boolean;
  45619. MORPHTARGETS_NORMAL: boolean;
  45620. MORPHTARGETS_TANGENT: boolean;
  45621. MORPHTARGETS_UV: boolean;
  45622. NUM_MORPH_INFLUENCERS: number;
  45623. IMAGEPROCESSING: boolean;
  45624. VIGNETTE: boolean;
  45625. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45626. VIGNETTEBLENDMODEOPAQUE: boolean;
  45627. TONEMAPPING: boolean;
  45628. TONEMAPPING_ACES: boolean;
  45629. CONTRAST: boolean;
  45630. COLORCURVES: boolean;
  45631. COLORGRADING: boolean;
  45632. COLORGRADING3D: boolean;
  45633. SAMPLER3DGREENDEPTH: boolean;
  45634. SAMPLER3DBGRMAP: boolean;
  45635. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45636. EXPOSURE: boolean;
  45637. MULTIVIEW: boolean;
  45638. USEPHYSICALLIGHTFALLOFF: boolean;
  45639. USEGLTFLIGHTFALLOFF: boolean;
  45640. TWOSIDEDLIGHTING: boolean;
  45641. SHADOWFLOAT: boolean;
  45642. CLIPPLANE: boolean;
  45643. CLIPPLANE2: boolean;
  45644. CLIPPLANE3: boolean;
  45645. CLIPPLANE4: boolean;
  45646. POINTSIZE: boolean;
  45647. FOG: boolean;
  45648. LOGARITHMICDEPTH: boolean;
  45649. FORCENORMALFORWARD: boolean;
  45650. SPECULARAA: boolean;
  45651. CLEARCOAT: boolean;
  45652. CLEARCOAT_DEFAULTIOR: boolean;
  45653. CLEARCOAT_TEXTURE: boolean;
  45654. CLEARCOAT_TEXTUREDIRECTUV: number;
  45655. CLEARCOAT_BUMP: boolean;
  45656. CLEARCOAT_BUMPDIRECTUV: number;
  45657. CLEARCOAT_TINT: boolean;
  45658. CLEARCOAT_TINT_TEXTURE: boolean;
  45659. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45660. ANISOTROPIC: boolean;
  45661. ANISOTROPIC_TEXTURE: boolean;
  45662. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45663. BRDF_V_HEIGHT_CORRELATED: boolean;
  45664. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45665. SHEEN: boolean;
  45666. SHEEN_TEXTURE: boolean;
  45667. SHEEN_TEXTUREDIRECTUV: number;
  45668. SHEEN_LINKWITHALBEDO: boolean;
  45669. SUBSURFACE: boolean;
  45670. SS_REFRACTION: boolean;
  45671. SS_TRANSLUCENCY: boolean;
  45672. SS_SCATERRING: boolean;
  45673. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45674. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45675. SS_REFRACTIONMAP_3D: boolean;
  45676. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45677. SS_LODINREFRACTIONALPHA: boolean;
  45678. SS_GAMMAREFRACTION: boolean;
  45679. SS_RGBDREFRACTION: boolean;
  45680. SS_LINEARSPECULARREFRACTION: boolean;
  45681. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45682. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45683. UNLIT: boolean;
  45684. DEBUGMODE: number;
  45685. /**
  45686. * Initializes the PBR Material defines.
  45687. */
  45688. constructor();
  45689. /**
  45690. * Resets the PBR Material defines.
  45691. */
  45692. reset(): void;
  45693. }
  45694. /**
  45695. * The Physically based material base class of BJS.
  45696. *
  45697. * This offers the main features of a standard PBR material.
  45698. * For more information, please refer to the documentation :
  45699. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45700. */
  45701. export abstract class PBRBaseMaterial extends PushMaterial {
  45702. /**
  45703. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45704. */
  45705. static readonly PBRMATERIAL_OPAQUE: number;
  45706. /**
  45707. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45708. */
  45709. static readonly PBRMATERIAL_ALPHATEST: number;
  45710. /**
  45711. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45712. */
  45713. static readonly PBRMATERIAL_ALPHABLEND: number;
  45714. /**
  45715. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45716. * They are also discarded below the alpha cutoff threshold to improve performances.
  45717. */
  45718. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45719. /**
  45720. * Defines the default value of how much AO map is occluding the analytical lights
  45721. * (point spot...).
  45722. */
  45723. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45724. /**
  45725. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45726. */
  45727. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45728. /**
  45729. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45730. * to enhance interoperability with other engines.
  45731. */
  45732. static readonly LIGHTFALLOFF_GLTF: number;
  45733. /**
  45734. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45735. * to enhance interoperability with other materials.
  45736. */
  45737. static readonly LIGHTFALLOFF_STANDARD: number;
  45738. /**
  45739. * Intensity of the direct lights e.g. the four lights available in your scene.
  45740. * This impacts both the direct diffuse and specular highlights.
  45741. */
  45742. protected _directIntensity: number;
  45743. /**
  45744. * Intensity of the emissive part of the material.
  45745. * This helps controlling the emissive effect without modifying the emissive color.
  45746. */
  45747. protected _emissiveIntensity: number;
  45748. /**
  45749. * Intensity of the environment e.g. how much the environment will light the object
  45750. * either through harmonics for rough material or through the refelction for shiny ones.
  45751. */
  45752. protected _environmentIntensity: number;
  45753. /**
  45754. * This is a special control allowing the reduction of the specular highlights coming from the
  45755. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45756. */
  45757. protected _specularIntensity: number;
  45758. /**
  45759. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45760. */
  45761. private _lightingInfos;
  45762. /**
  45763. * Debug Control allowing disabling the bump map on this material.
  45764. */
  45765. protected _disableBumpMap: boolean;
  45766. /**
  45767. * AKA Diffuse Texture in standard nomenclature.
  45768. */
  45769. protected _albedoTexture: Nullable<BaseTexture>;
  45770. /**
  45771. * AKA Occlusion Texture in other nomenclature.
  45772. */
  45773. protected _ambientTexture: Nullable<BaseTexture>;
  45774. /**
  45775. * AKA Occlusion Texture Intensity in other nomenclature.
  45776. */
  45777. protected _ambientTextureStrength: number;
  45778. /**
  45779. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45780. * 1 means it completely occludes it
  45781. * 0 mean it has no impact
  45782. */
  45783. protected _ambientTextureImpactOnAnalyticalLights: number;
  45784. /**
  45785. * Stores the alpha values in a texture.
  45786. */
  45787. protected _opacityTexture: Nullable<BaseTexture>;
  45788. /**
  45789. * Stores the reflection values in a texture.
  45790. */
  45791. protected _reflectionTexture: Nullable<BaseTexture>;
  45792. /**
  45793. * Stores the emissive values in a texture.
  45794. */
  45795. protected _emissiveTexture: Nullable<BaseTexture>;
  45796. /**
  45797. * AKA Specular texture in other nomenclature.
  45798. */
  45799. protected _reflectivityTexture: Nullable<BaseTexture>;
  45800. /**
  45801. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45802. */
  45803. protected _metallicTexture: Nullable<BaseTexture>;
  45804. /**
  45805. * Specifies the metallic scalar of the metallic/roughness workflow.
  45806. * Can also be used to scale the metalness values of the metallic texture.
  45807. */
  45808. protected _metallic: Nullable<number>;
  45809. /**
  45810. * Specifies the roughness scalar of the metallic/roughness workflow.
  45811. * Can also be used to scale the roughness values of the metallic texture.
  45812. */
  45813. protected _roughness: Nullable<number>;
  45814. /**
  45815. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45816. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45817. */
  45818. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45819. /**
  45820. * Stores surface normal data used to displace a mesh in a texture.
  45821. */
  45822. protected _bumpTexture: Nullable<BaseTexture>;
  45823. /**
  45824. * Stores the pre-calculated light information of a mesh in a texture.
  45825. */
  45826. protected _lightmapTexture: Nullable<BaseTexture>;
  45827. /**
  45828. * The color of a material in ambient lighting.
  45829. */
  45830. protected _ambientColor: Color3;
  45831. /**
  45832. * AKA Diffuse Color in other nomenclature.
  45833. */
  45834. protected _albedoColor: Color3;
  45835. /**
  45836. * AKA Specular Color in other nomenclature.
  45837. */
  45838. protected _reflectivityColor: Color3;
  45839. /**
  45840. * The color applied when light is reflected from a material.
  45841. */
  45842. protected _reflectionColor: Color3;
  45843. /**
  45844. * The color applied when light is emitted from a material.
  45845. */
  45846. protected _emissiveColor: Color3;
  45847. /**
  45848. * AKA Glossiness in other nomenclature.
  45849. */
  45850. protected _microSurface: number;
  45851. /**
  45852. * Specifies that the material will use the light map as a show map.
  45853. */
  45854. protected _useLightmapAsShadowmap: boolean;
  45855. /**
  45856. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45857. * makes the reflect vector face the model (under horizon).
  45858. */
  45859. protected _useHorizonOcclusion: boolean;
  45860. /**
  45861. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45862. * too much the area relying on ambient texture to define their ambient occlusion.
  45863. */
  45864. protected _useRadianceOcclusion: boolean;
  45865. /**
  45866. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45867. */
  45868. protected _useAlphaFromAlbedoTexture: boolean;
  45869. /**
  45870. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45871. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45872. */
  45873. protected _useSpecularOverAlpha: boolean;
  45874. /**
  45875. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45876. */
  45877. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45878. /**
  45879. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45880. */
  45881. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45882. /**
  45883. * Specifies if the metallic texture contains the roughness information in its green channel.
  45884. */
  45885. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45886. /**
  45887. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45888. */
  45889. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45890. /**
  45891. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45892. */
  45893. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45894. /**
  45895. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45896. */
  45897. protected _useAmbientInGrayScale: boolean;
  45898. /**
  45899. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45900. * The material will try to infer what glossiness each pixel should be.
  45901. */
  45902. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45903. /**
  45904. * Defines the falloff type used in this material.
  45905. * It by default is Physical.
  45906. */
  45907. protected _lightFalloff: number;
  45908. /**
  45909. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45910. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45911. */
  45912. protected _useRadianceOverAlpha: boolean;
  45913. /**
  45914. * Allows using an object space normal map (instead of tangent space).
  45915. */
  45916. protected _useObjectSpaceNormalMap: boolean;
  45917. /**
  45918. * Allows using the bump map in parallax mode.
  45919. */
  45920. protected _useParallax: boolean;
  45921. /**
  45922. * Allows using the bump map in parallax occlusion mode.
  45923. */
  45924. protected _useParallaxOcclusion: boolean;
  45925. /**
  45926. * Controls the scale bias of the parallax mode.
  45927. */
  45928. protected _parallaxScaleBias: number;
  45929. /**
  45930. * If sets to true, disables all the lights affecting the material.
  45931. */
  45932. protected _disableLighting: boolean;
  45933. /**
  45934. * Number of Simultaneous lights allowed on the material.
  45935. */
  45936. protected _maxSimultaneousLights: number;
  45937. /**
  45938. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45939. */
  45940. protected _invertNormalMapX: boolean;
  45941. /**
  45942. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45943. */
  45944. protected _invertNormalMapY: boolean;
  45945. /**
  45946. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45947. */
  45948. protected _twoSidedLighting: boolean;
  45949. /**
  45950. * Defines the alpha limits in alpha test mode.
  45951. */
  45952. protected _alphaCutOff: number;
  45953. /**
  45954. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45955. */
  45956. protected _forceAlphaTest: boolean;
  45957. /**
  45958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45959. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45960. */
  45961. protected _useAlphaFresnel: boolean;
  45962. /**
  45963. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45964. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45965. */
  45966. protected _useLinearAlphaFresnel: boolean;
  45967. /**
  45968. * The transparency mode of the material.
  45969. */
  45970. protected _transparencyMode: Nullable<number>;
  45971. /**
  45972. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45973. * from cos thetav and roughness:
  45974. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45975. */
  45976. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45977. /**
  45978. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45979. */
  45980. protected _forceIrradianceInFragment: boolean;
  45981. /**
  45982. * Force normal to face away from face.
  45983. */
  45984. protected _forceNormalForward: boolean;
  45985. /**
  45986. * Enables specular anti aliasing in the PBR shader.
  45987. * It will both interacts on the Geometry for analytical and IBL lighting.
  45988. * It also prefilter the roughness map based on the bump values.
  45989. */
  45990. protected _enableSpecularAntiAliasing: boolean;
  45991. /**
  45992. * Default configuration related to image processing available in the PBR Material.
  45993. */
  45994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45995. /**
  45996. * Keep track of the image processing observer to allow dispose and replace.
  45997. */
  45998. private _imageProcessingObserver;
  45999. /**
  46000. * Attaches a new image processing configuration to the PBR Material.
  46001. * @param configuration
  46002. */
  46003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46004. /**
  46005. * Stores the available render targets.
  46006. */
  46007. private _renderTargets;
  46008. /**
  46009. * Sets the global ambient color for the material used in lighting calculations.
  46010. */
  46011. private _globalAmbientColor;
  46012. /**
  46013. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46014. */
  46015. private _useLogarithmicDepth;
  46016. /**
  46017. * If set to true, no lighting calculations will be applied.
  46018. */
  46019. private _unlit;
  46020. private _debugMode;
  46021. /**
  46022. * @hidden
  46023. * This is reserved for the inspector.
  46024. * Defines the material debug mode.
  46025. * It helps seeing only some components of the material while troubleshooting.
  46026. */
  46027. debugMode: number;
  46028. /**
  46029. * @hidden
  46030. * This is reserved for the inspector.
  46031. * Specify from where on screen the debug mode should start.
  46032. * The value goes from -1 (full screen) to 1 (not visible)
  46033. * It helps with side by side comparison against the final render
  46034. * This defaults to -1
  46035. */
  46036. private debugLimit;
  46037. /**
  46038. * @hidden
  46039. * This is reserved for the inspector.
  46040. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46041. * You can use the factor to better multiply the final value.
  46042. */
  46043. private debugFactor;
  46044. /**
  46045. * Defines the clear coat layer parameters for the material.
  46046. */
  46047. readonly clearCoat: PBRClearCoatConfiguration;
  46048. /**
  46049. * Defines the anisotropic parameters for the material.
  46050. */
  46051. readonly anisotropy: PBRAnisotropicConfiguration;
  46052. /**
  46053. * Defines the BRDF parameters for the material.
  46054. */
  46055. readonly brdf: PBRBRDFConfiguration;
  46056. /**
  46057. * Defines the Sheen parameters for the material.
  46058. */
  46059. readonly sheen: PBRSheenConfiguration;
  46060. /**
  46061. * Defines the SubSurface parameters for the material.
  46062. */
  46063. readonly subSurface: PBRSubSurfaceConfiguration;
  46064. /**
  46065. * Custom callback helping to override the default shader used in the material.
  46066. */
  46067. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46068. /**
  46069. * Instantiates a new PBRMaterial instance.
  46070. *
  46071. * @param name The material name
  46072. * @param scene The scene the material will be use in.
  46073. */
  46074. constructor(name: string, scene: Scene);
  46075. /**
  46076. * Gets a boolean indicating that current material needs to register RTT
  46077. */
  46078. readonly hasRenderTargetTextures: boolean;
  46079. /**
  46080. * Gets the name of the material class.
  46081. */
  46082. getClassName(): string;
  46083. /**
  46084. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46085. */
  46086. /**
  46087. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46088. */
  46089. useLogarithmicDepth: boolean;
  46090. /**
  46091. * Gets the current transparency mode.
  46092. */
  46093. /**
  46094. * Sets the transparency mode of the material.
  46095. *
  46096. * | Value | Type | Description |
  46097. * | ----- | ----------------------------------- | ----------- |
  46098. * | 0 | OPAQUE | |
  46099. * | 1 | ALPHATEST | |
  46100. * | 2 | ALPHABLEND | |
  46101. * | 3 | ALPHATESTANDBLEND | |
  46102. *
  46103. */
  46104. transparencyMode: Nullable<number>;
  46105. /**
  46106. * Returns true if alpha blending should be disabled.
  46107. */
  46108. private readonly _disableAlphaBlending;
  46109. /**
  46110. * Specifies whether or not this material should be rendered in alpha blend mode.
  46111. */
  46112. needAlphaBlending(): boolean;
  46113. /**
  46114. * Specifies if the mesh will require alpha blending.
  46115. * @param mesh - BJS mesh.
  46116. */
  46117. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46118. /**
  46119. * Specifies whether or not this material should be rendered in alpha test mode.
  46120. */
  46121. needAlphaTesting(): boolean;
  46122. /**
  46123. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46124. */
  46125. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46126. /**
  46127. * Gets the texture used for the alpha test.
  46128. */
  46129. getAlphaTestTexture(): Nullable<BaseTexture>;
  46130. /**
  46131. * Specifies that the submesh is ready to be used.
  46132. * @param mesh - BJS mesh.
  46133. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46134. * @param useInstances - Specifies that instances should be used.
  46135. * @returns - boolean indicating that the submesh is ready or not.
  46136. */
  46137. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46138. /**
  46139. * Specifies if the material uses metallic roughness workflow.
  46140. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46141. */
  46142. isMetallicWorkflow(): boolean;
  46143. private _prepareEffect;
  46144. private _prepareDefines;
  46145. /**
  46146. * Force shader compilation
  46147. */
  46148. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46149. clipPlane: boolean;
  46150. }>): void;
  46151. /**
  46152. * Initializes the uniform buffer layout for the shader.
  46153. */
  46154. buildUniformLayout(): void;
  46155. /**
  46156. * Unbinds the material from the mesh
  46157. */
  46158. unbind(): void;
  46159. /**
  46160. * Binds the submesh data.
  46161. * @param world - The world matrix.
  46162. * @param mesh - The BJS mesh.
  46163. * @param subMesh - A submesh of the BJS mesh.
  46164. */
  46165. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46166. /**
  46167. * Returns the animatable textures.
  46168. * @returns - Array of animatable textures.
  46169. */
  46170. getAnimatables(): IAnimatable[];
  46171. /**
  46172. * Returns the texture used for reflections.
  46173. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46174. */
  46175. private _getReflectionTexture;
  46176. /**
  46177. * Returns an array of the actively used textures.
  46178. * @returns - Array of BaseTextures
  46179. */
  46180. getActiveTextures(): BaseTexture[];
  46181. /**
  46182. * Checks to see if a texture is used in the material.
  46183. * @param texture - Base texture to use.
  46184. * @returns - Boolean specifying if a texture is used in the material.
  46185. */
  46186. hasTexture(texture: BaseTexture): boolean;
  46187. /**
  46188. * Disposes the resources of the material.
  46189. * @param forceDisposeEffect - Forces the disposal of effects.
  46190. * @param forceDisposeTextures - Forces the disposal of all textures.
  46191. */
  46192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * The Physically based material of BJS.
  46198. *
  46199. * This offers the main features of a standard PBR material.
  46200. * For more information, please refer to the documentation :
  46201. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46202. */
  46203. export class PBRMaterial extends PBRBaseMaterial {
  46204. /**
  46205. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46206. */
  46207. static readonly PBRMATERIAL_OPAQUE: number;
  46208. /**
  46209. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46210. */
  46211. static readonly PBRMATERIAL_ALPHATEST: number;
  46212. /**
  46213. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46214. */
  46215. static readonly PBRMATERIAL_ALPHABLEND: number;
  46216. /**
  46217. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46218. * They are also discarded below the alpha cutoff threshold to improve performances.
  46219. */
  46220. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46221. /**
  46222. * Defines the default value of how much AO map is occluding the analytical lights
  46223. * (point spot...).
  46224. */
  46225. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46226. /**
  46227. * Intensity of the direct lights e.g. the four lights available in your scene.
  46228. * This impacts both the direct diffuse and specular highlights.
  46229. */
  46230. directIntensity: number;
  46231. /**
  46232. * Intensity of the emissive part of the material.
  46233. * This helps controlling the emissive effect without modifying the emissive color.
  46234. */
  46235. emissiveIntensity: number;
  46236. /**
  46237. * Intensity of the environment e.g. how much the environment will light the object
  46238. * either through harmonics for rough material or through the refelction for shiny ones.
  46239. */
  46240. environmentIntensity: number;
  46241. /**
  46242. * This is a special control allowing the reduction of the specular highlights coming from the
  46243. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46244. */
  46245. specularIntensity: number;
  46246. /**
  46247. * Debug Control allowing disabling the bump map on this material.
  46248. */
  46249. disableBumpMap: boolean;
  46250. /**
  46251. * AKA Diffuse Texture in standard nomenclature.
  46252. */
  46253. albedoTexture: BaseTexture;
  46254. /**
  46255. * AKA Occlusion Texture in other nomenclature.
  46256. */
  46257. ambientTexture: BaseTexture;
  46258. /**
  46259. * AKA Occlusion Texture Intensity in other nomenclature.
  46260. */
  46261. ambientTextureStrength: number;
  46262. /**
  46263. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46264. * 1 means it completely occludes it
  46265. * 0 mean it has no impact
  46266. */
  46267. ambientTextureImpactOnAnalyticalLights: number;
  46268. /**
  46269. * Stores the alpha values in a texture.
  46270. */
  46271. opacityTexture: BaseTexture;
  46272. /**
  46273. * Stores the reflection values in a texture.
  46274. */
  46275. reflectionTexture: Nullable<BaseTexture>;
  46276. /**
  46277. * Stores the emissive values in a texture.
  46278. */
  46279. emissiveTexture: BaseTexture;
  46280. /**
  46281. * AKA Specular texture in other nomenclature.
  46282. */
  46283. reflectivityTexture: BaseTexture;
  46284. /**
  46285. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46286. */
  46287. metallicTexture: BaseTexture;
  46288. /**
  46289. * Specifies the metallic scalar of the metallic/roughness workflow.
  46290. * Can also be used to scale the metalness values of the metallic texture.
  46291. */
  46292. metallic: Nullable<number>;
  46293. /**
  46294. * Specifies the roughness scalar of the metallic/roughness workflow.
  46295. * Can also be used to scale the roughness values of the metallic texture.
  46296. */
  46297. roughness: Nullable<number>;
  46298. /**
  46299. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46300. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46301. */
  46302. microSurfaceTexture: BaseTexture;
  46303. /**
  46304. * Stores surface normal data used to displace a mesh in a texture.
  46305. */
  46306. bumpTexture: BaseTexture;
  46307. /**
  46308. * Stores the pre-calculated light information of a mesh in a texture.
  46309. */
  46310. lightmapTexture: BaseTexture;
  46311. /**
  46312. * Stores the refracted light information in a texture.
  46313. */
  46314. refractionTexture: Nullable<BaseTexture>;
  46315. /**
  46316. * The color of a material in ambient lighting.
  46317. */
  46318. ambientColor: Color3;
  46319. /**
  46320. * AKA Diffuse Color in other nomenclature.
  46321. */
  46322. albedoColor: Color3;
  46323. /**
  46324. * AKA Specular Color in other nomenclature.
  46325. */
  46326. reflectivityColor: Color3;
  46327. /**
  46328. * The color reflected from the material.
  46329. */
  46330. reflectionColor: Color3;
  46331. /**
  46332. * The color emitted from the material.
  46333. */
  46334. emissiveColor: Color3;
  46335. /**
  46336. * AKA Glossiness in other nomenclature.
  46337. */
  46338. microSurface: number;
  46339. /**
  46340. * source material index of refraction (IOR)' / 'destination material IOR.
  46341. */
  46342. indexOfRefraction: number;
  46343. /**
  46344. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46345. */
  46346. invertRefractionY: boolean;
  46347. /**
  46348. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46349. * Materials half opaque for instance using refraction could benefit from this control.
  46350. */
  46351. linkRefractionWithTransparency: boolean;
  46352. /**
  46353. * If true, the light map contains occlusion information instead of lighting info.
  46354. */
  46355. useLightmapAsShadowmap: boolean;
  46356. /**
  46357. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46358. */
  46359. useAlphaFromAlbedoTexture: boolean;
  46360. /**
  46361. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46362. */
  46363. forceAlphaTest: boolean;
  46364. /**
  46365. * Defines the alpha limits in alpha test mode.
  46366. */
  46367. alphaCutOff: number;
  46368. /**
  46369. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46370. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46371. */
  46372. useSpecularOverAlpha: boolean;
  46373. /**
  46374. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46375. */
  46376. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46377. /**
  46378. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46379. */
  46380. useRoughnessFromMetallicTextureAlpha: boolean;
  46381. /**
  46382. * Specifies if the metallic texture contains the roughness information in its green channel.
  46383. */
  46384. useRoughnessFromMetallicTextureGreen: boolean;
  46385. /**
  46386. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46387. */
  46388. useMetallnessFromMetallicTextureBlue: boolean;
  46389. /**
  46390. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46391. */
  46392. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46393. /**
  46394. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46395. */
  46396. useAmbientInGrayScale: boolean;
  46397. /**
  46398. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46399. * The material will try to infer what glossiness each pixel should be.
  46400. */
  46401. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46402. /**
  46403. * BJS is using an harcoded light falloff based on a manually sets up range.
  46404. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46405. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46406. */
  46407. /**
  46408. * BJS is using an harcoded light falloff based on a manually sets up range.
  46409. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46410. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46411. */
  46412. usePhysicalLightFalloff: boolean;
  46413. /**
  46414. * In order to support the falloff compatibility with gltf, a special mode has been added
  46415. * to reproduce the gltf light falloff.
  46416. */
  46417. /**
  46418. * In order to support the falloff compatibility with gltf, a special mode has been added
  46419. * to reproduce the gltf light falloff.
  46420. */
  46421. useGLTFLightFalloff: boolean;
  46422. /**
  46423. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46424. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46425. */
  46426. useRadianceOverAlpha: boolean;
  46427. /**
  46428. * Allows using an object space normal map (instead of tangent space).
  46429. */
  46430. useObjectSpaceNormalMap: boolean;
  46431. /**
  46432. * Allows using the bump map in parallax mode.
  46433. */
  46434. useParallax: boolean;
  46435. /**
  46436. * Allows using the bump map in parallax occlusion mode.
  46437. */
  46438. useParallaxOcclusion: boolean;
  46439. /**
  46440. * Controls the scale bias of the parallax mode.
  46441. */
  46442. parallaxScaleBias: number;
  46443. /**
  46444. * If sets to true, disables all the lights affecting the material.
  46445. */
  46446. disableLighting: boolean;
  46447. /**
  46448. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46449. */
  46450. forceIrradianceInFragment: boolean;
  46451. /**
  46452. * Number of Simultaneous lights allowed on the material.
  46453. */
  46454. maxSimultaneousLights: number;
  46455. /**
  46456. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46457. */
  46458. invertNormalMapX: boolean;
  46459. /**
  46460. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46461. */
  46462. invertNormalMapY: boolean;
  46463. /**
  46464. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46465. */
  46466. twoSidedLighting: boolean;
  46467. /**
  46468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46469. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46470. */
  46471. useAlphaFresnel: boolean;
  46472. /**
  46473. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46474. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46475. */
  46476. useLinearAlphaFresnel: boolean;
  46477. /**
  46478. * Let user defines the brdf lookup texture used for IBL.
  46479. * A default 8bit version is embedded but you could point at :
  46480. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46481. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46482. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46483. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46484. */
  46485. environmentBRDFTexture: Nullable<BaseTexture>;
  46486. /**
  46487. * Force normal to face away from face.
  46488. */
  46489. forceNormalForward: boolean;
  46490. /**
  46491. * Enables specular anti aliasing in the PBR shader.
  46492. * It will both interacts on the Geometry for analytical and IBL lighting.
  46493. * It also prefilter the roughness map based on the bump values.
  46494. */
  46495. enableSpecularAntiAliasing: boolean;
  46496. /**
  46497. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46498. * makes the reflect vector face the model (under horizon).
  46499. */
  46500. useHorizonOcclusion: boolean;
  46501. /**
  46502. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46503. * too much the area relying on ambient texture to define their ambient occlusion.
  46504. */
  46505. useRadianceOcclusion: boolean;
  46506. /**
  46507. * If set to true, no lighting calculations will be applied.
  46508. */
  46509. unlit: boolean;
  46510. /**
  46511. * Gets the image processing configuration used either in this material.
  46512. */
  46513. /**
  46514. * Sets the Default image processing configuration used either in the this material.
  46515. *
  46516. * If sets to null, the scene one is in use.
  46517. */
  46518. imageProcessingConfiguration: ImageProcessingConfiguration;
  46519. /**
  46520. * Gets wether the color curves effect is enabled.
  46521. */
  46522. /**
  46523. * Sets wether the color curves effect is enabled.
  46524. */
  46525. cameraColorCurvesEnabled: boolean;
  46526. /**
  46527. * Gets wether the color grading effect is enabled.
  46528. */
  46529. /**
  46530. * Gets wether the color grading effect is enabled.
  46531. */
  46532. cameraColorGradingEnabled: boolean;
  46533. /**
  46534. * Gets wether tonemapping is enabled or not.
  46535. */
  46536. /**
  46537. * Sets wether tonemapping is enabled or not
  46538. */
  46539. cameraToneMappingEnabled: boolean;
  46540. /**
  46541. * The camera exposure used on this material.
  46542. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46543. * This corresponds to a photographic exposure.
  46544. */
  46545. /**
  46546. * The camera exposure used on this material.
  46547. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46548. * This corresponds to a photographic exposure.
  46549. */
  46550. cameraExposure: number;
  46551. /**
  46552. * Gets The camera contrast used on this material.
  46553. */
  46554. /**
  46555. * Sets The camera contrast used on this material.
  46556. */
  46557. cameraContrast: number;
  46558. /**
  46559. * Gets the Color Grading 2D Lookup Texture.
  46560. */
  46561. /**
  46562. * Sets the Color Grading 2D Lookup Texture.
  46563. */
  46564. cameraColorGradingTexture: Nullable<BaseTexture>;
  46565. /**
  46566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46568. * 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;
  46569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46570. */
  46571. /**
  46572. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46573. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46574. * 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;
  46575. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46576. */
  46577. cameraColorCurves: Nullable<ColorCurves>;
  46578. /**
  46579. * Instantiates a new PBRMaterial instance.
  46580. *
  46581. * @param name The material name
  46582. * @param scene The scene the material will be use in.
  46583. */
  46584. constructor(name: string, scene: Scene);
  46585. /**
  46586. * Returns the name of this material class.
  46587. */
  46588. getClassName(): string;
  46589. /**
  46590. * Makes a duplicate of the current material.
  46591. * @param name - name to use for the new material.
  46592. */
  46593. clone(name: string): PBRMaterial;
  46594. /**
  46595. * Serializes this PBR Material.
  46596. * @returns - An object with the serialized material.
  46597. */
  46598. serialize(): any;
  46599. /**
  46600. * Parses a PBR Material from a serialized object.
  46601. * @param source - Serialized object.
  46602. * @param scene - BJS scene instance.
  46603. * @param rootUrl - url for the scene object
  46604. * @returns - PBRMaterial
  46605. */
  46606. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46607. }
  46608. }
  46609. declare module BABYLON {
  46610. /**
  46611. * Direct draw surface info
  46612. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46613. */
  46614. export interface DDSInfo {
  46615. /**
  46616. * Width of the texture
  46617. */
  46618. width: number;
  46619. /**
  46620. * Width of the texture
  46621. */
  46622. height: number;
  46623. /**
  46624. * Number of Mipmaps for the texture
  46625. * @see https://en.wikipedia.org/wiki/Mipmap
  46626. */
  46627. mipmapCount: number;
  46628. /**
  46629. * If the textures format is a known fourCC format
  46630. * @see https://www.fourcc.org/
  46631. */
  46632. isFourCC: boolean;
  46633. /**
  46634. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46635. */
  46636. isRGB: boolean;
  46637. /**
  46638. * If the texture is a lumincance format
  46639. */
  46640. isLuminance: boolean;
  46641. /**
  46642. * If this is a cube texture
  46643. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46644. */
  46645. isCube: boolean;
  46646. /**
  46647. * If the texture is a compressed format eg. FOURCC_DXT1
  46648. */
  46649. isCompressed: boolean;
  46650. /**
  46651. * The dxgiFormat of the texture
  46652. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46653. */
  46654. dxgiFormat: number;
  46655. /**
  46656. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46657. */
  46658. textureType: number;
  46659. /**
  46660. * Sphericle polynomial created for the dds texture
  46661. */
  46662. sphericalPolynomial?: SphericalPolynomial;
  46663. }
  46664. /**
  46665. * Class used to provide DDS decompression tools
  46666. */
  46667. export class DDSTools {
  46668. /**
  46669. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46670. */
  46671. static StoreLODInAlphaChannel: boolean;
  46672. /**
  46673. * Gets DDS information from an array buffer
  46674. * @param arrayBuffer defines the array buffer to read data from
  46675. * @returns the DDS information
  46676. */
  46677. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46678. private static _FloatView;
  46679. private static _Int32View;
  46680. private static _ToHalfFloat;
  46681. private static _FromHalfFloat;
  46682. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46683. private static _GetHalfFloatRGBAArrayBuffer;
  46684. private static _GetFloatRGBAArrayBuffer;
  46685. private static _GetFloatAsUIntRGBAArrayBuffer;
  46686. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46687. private static _GetRGBAArrayBuffer;
  46688. private static _ExtractLongWordOrder;
  46689. private static _GetRGBArrayBuffer;
  46690. private static _GetLuminanceArrayBuffer;
  46691. /**
  46692. * Uploads DDS Levels to a Babylon Texture
  46693. * @hidden
  46694. */
  46695. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46696. }
  46697. interface Engine {
  46698. /**
  46699. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46700. * @param rootUrl defines the url where the file to load is located
  46701. * @param scene defines the current scene
  46702. * @param lodScale defines scale to apply to the mip map selection
  46703. * @param lodOffset defines offset to apply to the mip map selection
  46704. * @param onLoad defines an optional callback raised when the texture is loaded
  46705. * @param onError defines an optional callback raised if there is an issue to load the texture
  46706. * @param format defines the format of the data
  46707. * @param forcedExtension defines the extension to use to pick the right loader
  46708. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46709. * @returns the cube texture as an InternalTexture
  46710. */
  46711. 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;
  46712. }
  46713. }
  46714. declare module BABYLON {
  46715. /**
  46716. * Implementation of the DDS Texture Loader.
  46717. * @hidden
  46718. */
  46719. export class _DDSTextureLoader implements IInternalTextureLoader {
  46720. /**
  46721. * Defines wether the loader supports cascade loading the different faces.
  46722. */
  46723. readonly supportCascades: boolean;
  46724. /**
  46725. * This returns if the loader support the current file information.
  46726. * @param extension defines the file extension of the file being loaded
  46727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46728. * @param fallback defines the fallback internal texture if any
  46729. * @param isBase64 defines whether the texture is encoded as a base64
  46730. * @param isBuffer defines whether the texture data are stored as a buffer
  46731. * @returns true if the loader can load the specified file
  46732. */
  46733. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46734. /**
  46735. * Transform the url before loading if required.
  46736. * @param rootUrl the url of the texture
  46737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46738. * @returns the transformed texture
  46739. */
  46740. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46741. /**
  46742. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46743. * @param rootUrl the url of the texture
  46744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46745. * @returns the fallback texture
  46746. */
  46747. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46748. /**
  46749. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46750. * @param data contains the texture data
  46751. * @param texture defines the BabylonJS internal texture
  46752. * @param createPolynomials will be true if polynomials have been requested
  46753. * @param onLoad defines the callback to trigger once the texture is ready
  46754. * @param onError defines the callback to trigger in case of error
  46755. */
  46756. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46757. /**
  46758. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46759. * @param data contains the texture data
  46760. * @param texture defines the BabylonJS internal texture
  46761. * @param callback defines the method to call once ready to upload
  46762. */
  46763. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46764. }
  46765. }
  46766. declare module BABYLON {
  46767. /** @hidden */
  46768. export var rgbdEncodePixelShader: {
  46769. name: string;
  46770. shader: string;
  46771. };
  46772. }
  46773. declare module BABYLON {
  46774. /**
  46775. * Raw texture data and descriptor sufficient for WebGL texture upload
  46776. */
  46777. export interface EnvironmentTextureInfo {
  46778. /**
  46779. * Version of the environment map
  46780. */
  46781. version: number;
  46782. /**
  46783. * Width of image
  46784. */
  46785. width: number;
  46786. /**
  46787. * Irradiance information stored in the file.
  46788. */
  46789. irradiance: any;
  46790. /**
  46791. * Specular information stored in the file.
  46792. */
  46793. specular: any;
  46794. }
  46795. /**
  46796. * Sets of helpers addressing the serialization and deserialization of environment texture
  46797. * stored in a BabylonJS env file.
  46798. * Those files are usually stored as .env files.
  46799. */
  46800. export class EnvironmentTextureTools {
  46801. /**
  46802. * Magic number identifying the env file.
  46803. */
  46804. private static _MagicBytes;
  46805. /**
  46806. * Gets the environment info from an env file.
  46807. * @param data The array buffer containing the .env bytes.
  46808. * @returns the environment file info (the json header) if successfully parsed.
  46809. */
  46810. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46811. /**
  46812. * Creates an environment texture from a loaded cube texture.
  46813. * @param texture defines the cube texture to convert in env file
  46814. * @return a promise containing the environment data if succesfull.
  46815. */
  46816. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46817. /**
  46818. * Creates a JSON representation of the spherical data.
  46819. * @param texture defines the texture containing the polynomials
  46820. * @return the JSON representation of the spherical info
  46821. */
  46822. private static _CreateEnvTextureIrradiance;
  46823. /**
  46824. * Uploads the texture info contained in the env file to the GPU.
  46825. * @param texture defines the internal texture to upload to
  46826. * @param arrayBuffer defines the buffer cotaining the data to load
  46827. * @param info defines the texture info retrieved through the GetEnvInfo method
  46828. * @returns a promise
  46829. */
  46830. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46831. /**
  46832. * Uploads the levels of image data to the GPU.
  46833. * @param texture defines the internal texture to upload to
  46834. * @param imageData defines the array buffer views of image data [mipmap][face]
  46835. * @returns a promise
  46836. */
  46837. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46838. /**
  46839. * Uploads spherical polynomials information to the texture.
  46840. * @param texture defines the texture we are trying to upload the information to
  46841. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46842. */
  46843. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46844. /** @hidden */
  46845. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46846. }
  46847. }
  46848. declare module BABYLON {
  46849. /**
  46850. * Implementation of the ENV Texture Loader.
  46851. * @hidden
  46852. */
  46853. export class _ENVTextureLoader implements IInternalTextureLoader {
  46854. /**
  46855. * Defines wether the loader supports cascade loading the different faces.
  46856. */
  46857. readonly supportCascades: boolean;
  46858. /**
  46859. * This returns if the loader support the current file information.
  46860. * @param extension defines the file extension of the file being loaded
  46861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46862. * @param fallback defines the fallback internal texture if any
  46863. * @param isBase64 defines whether the texture is encoded as a base64
  46864. * @param isBuffer defines whether the texture data are stored as a buffer
  46865. * @returns true if the loader can load the specified file
  46866. */
  46867. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46868. /**
  46869. * Transform the url before loading if required.
  46870. * @param rootUrl the url of the texture
  46871. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46872. * @returns the transformed texture
  46873. */
  46874. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46875. /**
  46876. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46877. * @param rootUrl the url of the texture
  46878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46879. * @returns the fallback texture
  46880. */
  46881. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46882. /**
  46883. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46884. * @param data contains the texture data
  46885. * @param texture defines the BabylonJS internal texture
  46886. * @param createPolynomials will be true if polynomials have been requested
  46887. * @param onLoad defines the callback to trigger once the texture is ready
  46888. * @param onError defines the callback to trigger in case of error
  46889. */
  46890. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46891. /**
  46892. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46893. * @param data contains the texture data
  46894. * @param texture defines the BabylonJS internal texture
  46895. * @param callback defines the method to call once ready to upload
  46896. */
  46897. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46898. }
  46899. }
  46900. declare module BABYLON {
  46901. /**
  46902. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46903. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46904. */
  46905. export class KhronosTextureContainer {
  46906. /** contents of the KTX container file */
  46907. arrayBuffer: any;
  46908. private static HEADER_LEN;
  46909. private static COMPRESSED_2D;
  46910. private static COMPRESSED_3D;
  46911. private static TEX_2D;
  46912. private static TEX_3D;
  46913. /**
  46914. * Gets the openGL type
  46915. */
  46916. glType: number;
  46917. /**
  46918. * Gets the openGL type size
  46919. */
  46920. glTypeSize: number;
  46921. /**
  46922. * Gets the openGL format
  46923. */
  46924. glFormat: number;
  46925. /**
  46926. * Gets the openGL internal format
  46927. */
  46928. glInternalFormat: number;
  46929. /**
  46930. * Gets the base internal format
  46931. */
  46932. glBaseInternalFormat: number;
  46933. /**
  46934. * Gets image width in pixel
  46935. */
  46936. pixelWidth: number;
  46937. /**
  46938. * Gets image height in pixel
  46939. */
  46940. pixelHeight: number;
  46941. /**
  46942. * Gets image depth in pixels
  46943. */
  46944. pixelDepth: number;
  46945. /**
  46946. * Gets the number of array elements
  46947. */
  46948. numberOfArrayElements: number;
  46949. /**
  46950. * Gets the number of faces
  46951. */
  46952. numberOfFaces: number;
  46953. /**
  46954. * Gets the number of mipmap levels
  46955. */
  46956. numberOfMipmapLevels: number;
  46957. /**
  46958. * Gets the bytes of key value data
  46959. */
  46960. bytesOfKeyValueData: number;
  46961. /**
  46962. * Gets the load type
  46963. */
  46964. loadType: number;
  46965. /**
  46966. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46967. */
  46968. isInvalid: boolean;
  46969. /**
  46970. * Creates a new KhronosTextureContainer
  46971. * @param arrayBuffer contents of the KTX container file
  46972. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46973. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46974. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46975. */
  46976. constructor(
  46977. /** contents of the KTX container file */
  46978. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46979. /**
  46980. * Uploads KTX content to a Babylon Texture.
  46981. * It is assumed that the texture has already been created & is currently bound
  46982. * @hidden
  46983. */
  46984. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46985. private _upload2DCompressedLevels;
  46986. }
  46987. }
  46988. declare module BABYLON {
  46989. /**
  46990. * Implementation of the KTX Texture Loader.
  46991. * @hidden
  46992. */
  46993. export class _KTXTextureLoader implements IInternalTextureLoader {
  46994. /**
  46995. * Defines wether the loader supports cascade loading the different faces.
  46996. */
  46997. readonly supportCascades: boolean;
  46998. /**
  46999. * This returns if the loader support the current file information.
  47000. * @param extension defines the file extension of the file being loaded
  47001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47002. * @param fallback defines the fallback internal texture if any
  47003. * @param isBase64 defines whether the texture is encoded as a base64
  47004. * @param isBuffer defines whether the texture data are stored as a buffer
  47005. * @returns true if the loader can load the specified file
  47006. */
  47007. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47008. /**
  47009. * Transform the url before loading if required.
  47010. * @param rootUrl the url of the texture
  47011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47012. * @returns the transformed texture
  47013. */
  47014. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47015. /**
  47016. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47017. * @param rootUrl the url of the texture
  47018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47019. * @returns the fallback texture
  47020. */
  47021. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47022. /**
  47023. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47024. * @param data contains the texture data
  47025. * @param texture defines the BabylonJS internal texture
  47026. * @param createPolynomials will be true if polynomials have been requested
  47027. * @param onLoad defines the callback to trigger once the texture is ready
  47028. * @param onError defines the callback to trigger in case of error
  47029. */
  47030. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47031. /**
  47032. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47033. * @param data contains the texture data
  47034. * @param texture defines the BabylonJS internal texture
  47035. * @param callback defines the method to call once ready to upload
  47036. */
  47037. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47038. }
  47039. }
  47040. declare module BABYLON {
  47041. /** @hidden */
  47042. export var _forceSceneHelpersToBundle: boolean;
  47043. interface Scene {
  47044. /**
  47045. * Creates a default light for the scene.
  47046. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47047. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47048. */
  47049. createDefaultLight(replace?: boolean): void;
  47050. /**
  47051. * Creates a default camera for the scene.
  47052. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47053. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47054. * @param replace has default false, when true replaces the active camera in the scene
  47055. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47056. */
  47057. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47058. /**
  47059. * Creates a default camera and a default light.
  47060. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47061. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47062. * @param replace has the default false, when true replaces the active camera/light in the scene
  47063. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47064. */
  47065. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47066. /**
  47067. * Creates a new sky box
  47068. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47069. * @param environmentTexture defines the texture to use as environment texture
  47070. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47071. * @param scale defines the overall scale of the skybox
  47072. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47073. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47074. * @returns a new mesh holding the sky box
  47075. */
  47076. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47077. /**
  47078. * Creates a new environment
  47079. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47080. * @param options defines the options you can use to configure the environment
  47081. * @returns the new EnvironmentHelper
  47082. */
  47083. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47084. /**
  47085. * Creates a new VREXperienceHelper
  47086. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47087. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47088. * @returns a new VREXperienceHelper
  47089. */
  47090. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47091. /**
  47092. * Creates a new XREXperienceHelper
  47093. * @see http://doc.babylonjs.com/how_to/webxr
  47094. * @returns a promise for a new XREXperienceHelper
  47095. */
  47096. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47097. }
  47098. }
  47099. declare module BABYLON {
  47100. /**
  47101. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47102. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47103. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47104. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47105. */
  47106. export class VideoDome extends TransformNode {
  47107. /**
  47108. * Define the video source as a Monoscopic panoramic 360 video.
  47109. */
  47110. static readonly MODE_MONOSCOPIC: number;
  47111. /**
  47112. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47113. */
  47114. static readonly MODE_TOPBOTTOM: number;
  47115. /**
  47116. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47117. */
  47118. static readonly MODE_SIDEBYSIDE: number;
  47119. private _useDirectMapping;
  47120. /**
  47121. * The video texture being displayed on the sphere
  47122. */
  47123. protected _videoTexture: VideoTexture;
  47124. /**
  47125. * Gets the video texture being displayed on the sphere
  47126. */
  47127. readonly videoTexture: VideoTexture;
  47128. /**
  47129. * The skybox material
  47130. */
  47131. protected _material: BackgroundMaterial;
  47132. /**
  47133. * The surface used for the skybox
  47134. */
  47135. protected _mesh: Mesh;
  47136. /**
  47137. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47138. * Also see the options.resolution property.
  47139. */
  47140. fovMultiplier: number;
  47141. private _videoMode;
  47142. /**
  47143. * Gets or set the current video mode for the video. It can be:
  47144. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47145. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47146. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47147. */
  47148. videoMode: number;
  47149. /**
  47150. * Oberserver used in Stereoscopic VR Mode.
  47151. */
  47152. private _onBeforeCameraRenderObserver;
  47153. /**
  47154. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47155. * @param name Element's name, child elements will append suffixes for their own names.
  47156. * @param urlsOrVideo defines the url(s) or the video element to use
  47157. * @param options An object containing optional or exposed sub element properties
  47158. */
  47159. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47160. resolution?: number;
  47161. clickToPlay?: boolean;
  47162. autoPlay?: boolean;
  47163. loop?: boolean;
  47164. size?: number;
  47165. poster?: string;
  47166. faceForward?: boolean;
  47167. useDirectMapping?: boolean;
  47168. }, scene: Scene);
  47169. private _changeVideoMode;
  47170. /**
  47171. * Releases resources associated with this node.
  47172. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47173. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47174. */
  47175. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47176. }
  47177. }
  47178. declare module BABYLON {
  47179. /**
  47180. * This class can be used to get instrumentation data from a Babylon engine
  47181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47182. */
  47183. export class EngineInstrumentation implements IDisposable {
  47184. /**
  47185. * Define the instrumented engine.
  47186. */
  47187. engine: Engine;
  47188. private _captureGPUFrameTime;
  47189. private _gpuFrameTimeToken;
  47190. private _gpuFrameTime;
  47191. private _captureShaderCompilationTime;
  47192. private _shaderCompilationTime;
  47193. private _onBeginFrameObserver;
  47194. private _onEndFrameObserver;
  47195. private _onBeforeShaderCompilationObserver;
  47196. private _onAfterShaderCompilationObserver;
  47197. /**
  47198. * Gets the perf counter used for GPU frame time
  47199. */
  47200. readonly gpuFrameTimeCounter: PerfCounter;
  47201. /**
  47202. * Gets the GPU frame time capture status
  47203. */
  47204. /**
  47205. * Enable or disable the GPU frame time capture
  47206. */
  47207. captureGPUFrameTime: boolean;
  47208. /**
  47209. * Gets the perf counter used for shader compilation time
  47210. */
  47211. readonly shaderCompilationTimeCounter: PerfCounter;
  47212. /**
  47213. * Gets the shader compilation time capture status
  47214. */
  47215. /**
  47216. * Enable or disable the shader compilation time capture
  47217. */
  47218. captureShaderCompilationTime: boolean;
  47219. /**
  47220. * Instantiates a new engine instrumentation.
  47221. * This class can be used to get instrumentation data from a Babylon engine
  47222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47223. * @param engine Defines the engine to instrument
  47224. */
  47225. constructor(
  47226. /**
  47227. * Define the instrumented engine.
  47228. */
  47229. engine: Engine);
  47230. /**
  47231. * Dispose and release associated resources.
  47232. */
  47233. dispose(): void;
  47234. }
  47235. }
  47236. declare module BABYLON {
  47237. /**
  47238. * This class can be used to get instrumentation data from a Babylon engine
  47239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47240. */
  47241. export class SceneInstrumentation implements IDisposable {
  47242. /**
  47243. * Defines the scene to instrument
  47244. */
  47245. scene: Scene;
  47246. private _captureActiveMeshesEvaluationTime;
  47247. private _activeMeshesEvaluationTime;
  47248. private _captureRenderTargetsRenderTime;
  47249. private _renderTargetsRenderTime;
  47250. private _captureFrameTime;
  47251. private _frameTime;
  47252. private _captureRenderTime;
  47253. private _renderTime;
  47254. private _captureInterFrameTime;
  47255. private _interFrameTime;
  47256. private _captureParticlesRenderTime;
  47257. private _particlesRenderTime;
  47258. private _captureSpritesRenderTime;
  47259. private _spritesRenderTime;
  47260. private _capturePhysicsTime;
  47261. private _physicsTime;
  47262. private _captureAnimationsTime;
  47263. private _animationsTime;
  47264. private _captureCameraRenderTime;
  47265. private _cameraRenderTime;
  47266. private _onBeforeActiveMeshesEvaluationObserver;
  47267. private _onAfterActiveMeshesEvaluationObserver;
  47268. private _onBeforeRenderTargetsRenderObserver;
  47269. private _onAfterRenderTargetsRenderObserver;
  47270. private _onAfterRenderObserver;
  47271. private _onBeforeDrawPhaseObserver;
  47272. private _onAfterDrawPhaseObserver;
  47273. private _onBeforeAnimationsObserver;
  47274. private _onBeforeParticlesRenderingObserver;
  47275. private _onAfterParticlesRenderingObserver;
  47276. private _onBeforeSpritesRenderingObserver;
  47277. private _onAfterSpritesRenderingObserver;
  47278. private _onBeforePhysicsObserver;
  47279. private _onAfterPhysicsObserver;
  47280. private _onAfterAnimationsObserver;
  47281. private _onBeforeCameraRenderObserver;
  47282. private _onAfterCameraRenderObserver;
  47283. /**
  47284. * Gets the perf counter used for active meshes evaluation time
  47285. */
  47286. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47287. /**
  47288. * Gets the active meshes evaluation time capture status
  47289. */
  47290. /**
  47291. * Enable or disable the active meshes evaluation time capture
  47292. */
  47293. captureActiveMeshesEvaluationTime: boolean;
  47294. /**
  47295. * Gets the perf counter used for render targets render time
  47296. */
  47297. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47298. /**
  47299. * Gets the render targets render time capture status
  47300. */
  47301. /**
  47302. * Enable or disable the render targets render time capture
  47303. */
  47304. captureRenderTargetsRenderTime: boolean;
  47305. /**
  47306. * Gets the perf counter used for particles render time
  47307. */
  47308. readonly particlesRenderTimeCounter: PerfCounter;
  47309. /**
  47310. * Gets the particles render time capture status
  47311. */
  47312. /**
  47313. * Enable or disable the particles render time capture
  47314. */
  47315. captureParticlesRenderTime: boolean;
  47316. /**
  47317. * Gets the perf counter used for sprites render time
  47318. */
  47319. readonly spritesRenderTimeCounter: PerfCounter;
  47320. /**
  47321. * Gets the sprites render time capture status
  47322. */
  47323. /**
  47324. * Enable or disable the sprites render time capture
  47325. */
  47326. captureSpritesRenderTime: boolean;
  47327. /**
  47328. * Gets the perf counter used for physics time
  47329. */
  47330. readonly physicsTimeCounter: PerfCounter;
  47331. /**
  47332. * Gets the physics time capture status
  47333. */
  47334. /**
  47335. * Enable or disable the physics time capture
  47336. */
  47337. capturePhysicsTime: boolean;
  47338. /**
  47339. * Gets the perf counter used for animations time
  47340. */
  47341. readonly animationsTimeCounter: PerfCounter;
  47342. /**
  47343. * Gets the animations time capture status
  47344. */
  47345. /**
  47346. * Enable or disable the animations time capture
  47347. */
  47348. captureAnimationsTime: boolean;
  47349. /**
  47350. * Gets the perf counter used for frame time capture
  47351. */
  47352. readonly frameTimeCounter: PerfCounter;
  47353. /**
  47354. * Gets the frame time capture status
  47355. */
  47356. /**
  47357. * Enable or disable the frame time capture
  47358. */
  47359. captureFrameTime: boolean;
  47360. /**
  47361. * Gets the perf counter used for inter-frames time capture
  47362. */
  47363. readonly interFrameTimeCounter: PerfCounter;
  47364. /**
  47365. * Gets the inter-frames time capture status
  47366. */
  47367. /**
  47368. * Enable or disable the inter-frames time capture
  47369. */
  47370. captureInterFrameTime: boolean;
  47371. /**
  47372. * Gets the perf counter used for render time capture
  47373. */
  47374. readonly renderTimeCounter: PerfCounter;
  47375. /**
  47376. * Gets the render time capture status
  47377. */
  47378. /**
  47379. * Enable or disable the render time capture
  47380. */
  47381. captureRenderTime: boolean;
  47382. /**
  47383. * Gets the perf counter used for camera render time capture
  47384. */
  47385. readonly cameraRenderTimeCounter: PerfCounter;
  47386. /**
  47387. * Gets the camera render time capture status
  47388. */
  47389. /**
  47390. * Enable or disable the camera render time capture
  47391. */
  47392. captureCameraRenderTime: boolean;
  47393. /**
  47394. * Gets the perf counter used for draw calls
  47395. */
  47396. readonly drawCallsCounter: PerfCounter;
  47397. /**
  47398. * Instantiates a new scene instrumentation.
  47399. * This class can be used to get instrumentation data from a Babylon engine
  47400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47401. * @param scene Defines the scene to instrument
  47402. */
  47403. constructor(
  47404. /**
  47405. * Defines the scene to instrument
  47406. */
  47407. scene: Scene);
  47408. /**
  47409. * Dispose and release associated resources.
  47410. */
  47411. dispose(): void;
  47412. }
  47413. }
  47414. declare module BABYLON {
  47415. /** @hidden */
  47416. export var glowMapGenerationPixelShader: {
  47417. name: string;
  47418. shader: string;
  47419. };
  47420. }
  47421. declare module BABYLON {
  47422. /** @hidden */
  47423. export var glowMapGenerationVertexShader: {
  47424. name: string;
  47425. shader: string;
  47426. };
  47427. }
  47428. declare module BABYLON {
  47429. /**
  47430. * Effect layer options. This helps customizing the behaviour
  47431. * of the effect layer.
  47432. */
  47433. export interface IEffectLayerOptions {
  47434. /**
  47435. * Multiplication factor apply to the canvas size to compute the render target size
  47436. * used to generated the objects (the smaller the faster).
  47437. */
  47438. mainTextureRatio: number;
  47439. /**
  47440. * Enforces a fixed size texture to ensure effect stability across devices.
  47441. */
  47442. mainTextureFixedSize?: number;
  47443. /**
  47444. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47445. */
  47446. alphaBlendingMode: number;
  47447. /**
  47448. * The camera attached to the layer.
  47449. */
  47450. camera: Nullable<Camera>;
  47451. /**
  47452. * The rendering group to draw the layer in.
  47453. */
  47454. renderingGroupId: number;
  47455. }
  47456. /**
  47457. * The effect layer Helps adding post process effect blended with the main pass.
  47458. *
  47459. * This can be for instance use to generate glow or higlight effects on the scene.
  47460. *
  47461. * The effect layer class can not be used directly and is intented to inherited from to be
  47462. * customized per effects.
  47463. */
  47464. export abstract class EffectLayer {
  47465. private _vertexBuffers;
  47466. private _indexBuffer;
  47467. private _cachedDefines;
  47468. private _effectLayerMapGenerationEffect;
  47469. private _effectLayerOptions;
  47470. private _mergeEffect;
  47471. protected _scene: Scene;
  47472. protected _engine: Engine;
  47473. protected _maxSize: number;
  47474. protected _mainTextureDesiredSize: ISize;
  47475. protected _mainTexture: RenderTargetTexture;
  47476. protected _shouldRender: boolean;
  47477. protected _postProcesses: PostProcess[];
  47478. protected _textures: BaseTexture[];
  47479. protected _emissiveTextureAndColor: {
  47480. texture: Nullable<BaseTexture>;
  47481. color: Color4;
  47482. };
  47483. /**
  47484. * The name of the layer
  47485. */
  47486. name: string;
  47487. /**
  47488. * The clear color of the texture used to generate the glow map.
  47489. */
  47490. neutralColor: Color4;
  47491. /**
  47492. * Specifies wether the highlight layer is enabled or not.
  47493. */
  47494. isEnabled: boolean;
  47495. /**
  47496. * Gets the camera attached to the layer.
  47497. */
  47498. readonly camera: Nullable<Camera>;
  47499. /**
  47500. * Gets the rendering group id the layer should render in.
  47501. */
  47502. readonly renderingGroupId: number;
  47503. /**
  47504. * An event triggered when the effect layer has been disposed.
  47505. */
  47506. onDisposeObservable: Observable<EffectLayer>;
  47507. /**
  47508. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47509. */
  47510. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47511. /**
  47512. * An event triggered when the generated texture is being merged in the scene.
  47513. */
  47514. onBeforeComposeObservable: Observable<EffectLayer>;
  47515. /**
  47516. * An event triggered when the generated texture has been merged in the scene.
  47517. */
  47518. onAfterComposeObservable: Observable<EffectLayer>;
  47519. /**
  47520. * An event triggered when the efffect layer changes its size.
  47521. */
  47522. onSizeChangedObservable: Observable<EffectLayer>;
  47523. /** @hidden */
  47524. static _SceneComponentInitialization: (scene: Scene) => void;
  47525. /**
  47526. * Instantiates a new effect Layer and references it in the scene.
  47527. * @param name The name of the layer
  47528. * @param scene The scene to use the layer in
  47529. */
  47530. constructor(
  47531. /** The Friendly of the effect in the scene */
  47532. name: string, scene: Scene);
  47533. /**
  47534. * Get the effect name of the layer.
  47535. * @return The effect name
  47536. */
  47537. abstract getEffectName(): string;
  47538. /**
  47539. * Checks for the readiness of the element composing the layer.
  47540. * @param subMesh the mesh to check for
  47541. * @param useInstances specify wether or not to use instances to render the mesh
  47542. * @return true if ready otherwise, false
  47543. */
  47544. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47545. /**
  47546. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47547. * @returns true if the effect requires stencil during the main canvas render pass.
  47548. */
  47549. abstract needStencil(): boolean;
  47550. /**
  47551. * Create the merge effect. This is the shader use to blit the information back
  47552. * to the main canvas at the end of the scene rendering.
  47553. * @returns The effect containing the shader used to merge the effect on the main canvas
  47554. */
  47555. protected abstract _createMergeEffect(): Effect;
  47556. /**
  47557. * Creates the render target textures and post processes used in the effect layer.
  47558. */
  47559. protected abstract _createTextureAndPostProcesses(): void;
  47560. /**
  47561. * Implementation specific of rendering the generating effect on the main canvas.
  47562. * @param effect The effect used to render through
  47563. */
  47564. protected abstract _internalRender(effect: Effect): void;
  47565. /**
  47566. * Sets the required values for both the emissive texture and and the main color.
  47567. */
  47568. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47569. /**
  47570. * Free any resources and references associated to a mesh.
  47571. * Internal use
  47572. * @param mesh The mesh to free.
  47573. */
  47574. abstract _disposeMesh(mesh: Mesh): void;
  47575. /**
  47576. * Serializes this layer (Glow or Highlight for example)
  47577. * @returns a serialized layer object
  47578. */
  47579. abstract serialize?(): any;
  47580. /**
  47581. * Initializes the effect layer with the required options.
  47582. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47583. */
  47584. protected _init(options: Partial<IEffectLayerOptions>): void;
  47585. /**
  47586. * Generates the index buffer of the full screen quad blending to the main canvas.
  47587. */
  47588. private _generateIndexBuffer;
  47589. /**
  47590. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47591. */
  47592. private _generateVertexBuffer;
  47593. /**
  47594. * Sets the main texture desired size which is the closest power of two
  47595. * of the engine canvas size.
  47596. */
  47597. private _setMainTextureSize;
  47598. /**
  47599. * Creates the main texture for the effect layer.
  47600. */
  47601. protected _createMainTexture(): void;
  47602. /**
  47603. * Adds specific effects defines.
  47604. * @param defines The defines to add specifics to.
  47605. */
  47606. protected _addCustomEffectDefines(defines: string[]): void;
  47607. /**
  47608. * Checks for the readiness of the element composing the layer.
  47609. * @param subMesh the mesh to check for
  47610. * @param useInstances specify wether or not to use instances to render the mesh
  47611. * @param emissiveTexture the associated emissive texture used to generate the glow
  47612. * @return true if ready otherwise, false
  47613. */
  47614. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47615. /**
  47616. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47617. */
  47618. render(): void;
  47619. /**
  47620. * Determine if a given mesh will be used in the current effect.
  47621. * @param mesh mesh to test
  47622. * @returns true if the mesh will be used
  47623. */
  47624. hasMesh(mesh: AbstractMesh): boolean;
  47625. /**
  47626. * Returns true if the layer contains information to display, otherwise false.
  47627. * @returns true if the glow layer should be rendered
  47628. */
  47629. shouldRender(): boolean;
  47630. /**
  47631. * Returns true if the mesh should render, otherwise false.
  47632. * @param mesh The mesh to render
  47633. * @returns true if it should render otherwise false
  47634. */
  47635. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47636. /**
  47637. * Returns true if the mesh can be rendered, otherwise false.
  47638. * @param mesh The mesh to render
  47639. * @param material The material used on the mesh
  47640. * @returns true if it can be rendered otherwise false
  47641. */
  47642. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47643. /**
  47644. * Returns true if the mesh should render, otherwise false.
  47645. * @param mesh The mesh to render
  47646. * @returns true if it should render otherwise false
  47647. */
  47648. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47649. /**
  47650. * Renders the submesh passed in parameter to the generation map.
  47651. */
  47652. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47653. /**
  47654. * Rebuild the required buffers.
  47655. * @hidden Internal use only.
  47656. */
  47657. _rebuild(): void;
  47658. /**
  47659. * Dispose only the render target textures and post process.
  47660. */
  47661. private _disposeTextureAndPostProcesses;
  47662. /**
  47663. * Dispose the highlight layer and free resources.
  47664. */
  47665. dispose(): void;
  47666. /**
  47667. * Gets the class name of the effect layer
  47668. * @returns the string with the class name of the effect layer
  47669. */
  47670. getClassName(): string;
  47671. /**
  47672. * Creates an effect layer from parsed effect layer data
  47673. * @param parsedEffectLayer defines effect layer data
  47674. * @param scene defines the current scene
  47675. * @param rootUrl defines the root URL containing the effect layer information
  47676. * @returns a parsed effect Layer
  47677. */
  47678. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47679. }
  47680. }
  47681. declare module BABYLON {
  47682. interface AbstractScene {
  47683. /**
  47684. * The list of effect layers (highlights/glow) added to the scene
  47685. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47686. * @see http://doc.babylonjs.com/how_to/glow_layer
  47687. */
  47688. effectLayers: Array<EffectLayer>;
  47689. /**
  47690. * Removes the given effect layer from this scene.
  47691. * @param toRemove defines the effect layer to remove
  47692. * @returns the index of the removed effect layer
  47693. */
  47694. removeEffectLayer(toRemove: EffectLayer): number;
  47695. /**
  47696. * Adds the given effect layer to this scene
  47697. * @param newEffectLayer defines the effect layer to add
  47698. */
  47699. addEffectLayer(newEffectLayer: EffectLayer): void;
  47700. }
  47701. /**
  47702. * Defines the layer scene component responsible to manage any effect layers
  47703. * in a given scene.
  47704. */
  47705. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47706. /**
  47707. * The component name helpfull to identify the component in the list of scene components.
  47708. */
  47709. readonly name: string;
  47710. /**
  47711. * The scene the component belongs to.
  47712. */
  47713. scene: Scene;
  47714. private _engine;
  47715. private _renderEffects;
  47716. private _needStencil;
  47717. private _previousStencilState;
  47718. /**
  47719. * Creates a new instance of the component for the given scene
  47720. * @param scene Defines the scene to register the component in
  47721. */
  47722. constructor(scene: Scene);
  47723. /**
  47724. * Registers the component in a given scene
  47725. */
  47726. register(): void;
  47727. /**
  47728. * Rebuilds the elements related to this component in case of
  47729. * context lost for instance.
  47730. */
  47731. rebuild(): void;
  47732. /**
  47733. * Serializes the component data to the specified json object
  47734. * @param serializationObject The object to serialize to
  47735. */
  47736. serialize(serializationObject: any): void;
  47737. /**
  47738. * Adds all the elements from the container to the scene
  47739. * @param container the container holding the elements
  47740. */
  47741. addFromContainer(container: AbstractScene): void;
  47742. /**
  47743. * Removes all the elements in the container from the scene
  47744. * @param container contains the elements to remove
  47745. * @param dispose if the removed element should be disposed (default: false)
  47746. */
  47747. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47748. /**
  47749. * Disposes the component and the associated ressources.
  47750. */
  47751. dispose(): void;
  47752. private _isReadyForMesh;
  47753. private _renderMainTexture;
  47754. private _setStencil;
  47755. private _setStencilBack;
  47756. private _draw;
  47757. private _drawCamera;
  47758. private _drawRenderingGroup;
  47759. }
  47760. }
  47761. declare module BABYLON {
  47762. /** @hidden */
  47763. export var glowMapMergePixelShader: {
  47764. name: string;
  47765. shader: string;
  47766. };
  47767. }
  47768. declare module BABYLON {
  47769. /** @hidden */
  47770. export var glowMapMergeVertexShader: {
  47771. name: string;
  47772. shader: string;
  47773. };
  47774. }
  47775. declare module BABYLON {
  47776. interface AbstractScene {
  47777. /**
  47778. * Return a the first highlight layer of the scene with a given name.
  47779. * @param name The name of the highlight layer to look for.
  47780. * @return The highlight layer if found otherwise null.
  47781. */
  47782. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47783. }
  47784. /**
  47785. * Glow layer options. This helps customizing the behaviour
  47786. * of the glow layer.
  47787. */
  47788. export interface IGlowLayerOptions {
  47789. /**
  47790. * Multiplication factor apply to the canvas size to compute the render target size
  47791. * used to generated the glowing objects (the smaller the faster).
  47792. */
  47793. mainTextureRatio: number;
  47794. /**
  47795. * Enforces a fixed size texture to ensure resize independant blur.
  47796. */
  47797. mainTextureFixedSize?: number;
  47798. /**
  47799. * How big is the kernel of the blur texture.
  47800. */
  47801. blurKernelSize: number;
  47802. /**
  47803. * The camera attached to the layer.
  47804. */
  47805. camera: Nullable<Camera>;
  47806. /**
  47807. * Enable MSAA by chosing the number of samples.
  47808. */
  47809. mainTextureSamples?: number;
  47810. /**
  47811. * The rendering group to draw the layer in.
  47812. */
  47813. renderingGroupId: number;
  47814. }
  47815. /**
  47816. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47817. *
  47818. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47819. * glowy meshes to your scene.
  47820. *
  47821. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47822. */
  47823. export class GlowLayer extends EffectLayer {
  47824. /**
  47825. * Effect Name of the layer.
  47826. */
  47827. static readonly EffectName: string;
  47828. /**
  47829. * The default blur kernel size used for the glow.
  47830. */
  47831. static DefaultBlurKernelSize: number;
  47832. /**
  47833. * The default texture size ratio used for the glow.
  47834. */
  47835. static DefaultTextureRatio: number;
  47836. /**
  47837. * Sets the kernel size of the blur.
  47838. */
  47839. /**
  47840. * Gets the kernel size of the blur.
  47841. */
  47842. blurKernelSize: number;
  47843. /**
  47844. * Sets the glow intensity.
  47845. */
  47846. /**
  47847. * Gets the glow intensity.
  47848. */
  47849. intensity: number;
  47850. private _options;
  47851. private _intensity;
  47852. private _horizontalBlurPostprocess1;
  47853. private _verticalBlurPostprocess1;
  47854. private _horizontalBlurPostprocess2;
  47855. private _verticalBlurPostprocess2;
  47856. private _blurTexture1;
  47857. private _blurTexture2;
  47858. private _postProcesses1;
  47859. private _postProcesses2;
  47860. private _includedOnlyMeshes;
  47861. private _excludedMeshes;
  47862. /**
  47863. * Callback used to let the user override the color selection on a per mesh basis
  47864. */
  47865. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47866. /**
  47867. * Callback used to let the user override the texture selection on a per mesh basis
  47868. */
  47869. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47870. /**
  47871. * Instantiates a new glow Layer and references it to the scene.
  47872. * @param name The name of the layer
  47873. * @param scene The scene to use the layer in
  47874. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47875. */
  47876. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47877. /**
  47878. * Get the effect name of the layer.
  47879. * @return The effect name
  47880. */
  47881. getEffectName(): string;
  47882. /**
  47883. * Create the merge effect. This is the shader use to blit the information back
  47884. * to the main canvas at the end of the scene rendering.
  47885. */
  47886. protected _createMergeEffect(): Effect;
  47887. /**
  47888. * Creates the render target textures and post processes used in the glow layer.
  47889. */
  47890. protected _createTextureAndPostProcesses(): void;
  47891. /**
  47892. * Checks for the readiness of the element composing the layer.
  47893. * @param subMesh the mesh to check for
  47894. * @param useInstances specify wether or not to use instances to render the mesh
  47895. * @param emissiveTexture the associated emissive texture used to generate the glow
  47896. * @return true if ready otherwise, false
  47897. */
  47898. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47899. /**
  47900. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47901. */
  47902. needStencil(): boolean;
  47903. /**
  47904. * Returns true if the mesh can be rendered, otherwise false.
  47905. * @param mesh The mesh to render
  47906. * @param material The material used on the mesh
  47907. * @returns true if it can be rendered otherwise false
  47908. */
  47909. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47910. /**
  47911. * Implementation specific of rendering the generating effect on the main canvas.
  47912. * @param effect The effect used to render through
  47913. */
  47914. protected _internalRender(effect: Effect): void;
  47915. /**
  47916. * Sets the required values for both the emissive texture and and the main color.
  47917. */
  47918. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47919. /**
  47920. * Returns true if the mesh should render, otherwise false.
  47921. * @param mesh The mesh to render
  47922. * @returns true if it should render otherwise false
  47923. */
  47924. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47925. /**
  47926. * Adds specific effects defines.
  47927. * @param defines The defines to add specifics to.
  47928. */
  47929. protected _addCustomEffectDefines(defines: string[]): void;
  47930. /**
  47931. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47932. * @param mesh The mesh to exclude from the glow layer
  47933. */
  47934. addExcludedMesh(mesh: Mesh): void;
  47935. /**
  47936. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47937. * @param mesh The mesh to remove
  47938. */
  47939. removeExcludedMesh(mesh: Mesh): void;
  47940. /**
  47941. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47942. * @param mesh The mesh to include in the glow layer
  47943. */
  47944. addIncludedOnlyMesh(mesh: Mesh): void;
  47945. /**
  47946. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47947. * @param mesh The mesh to remove
  47948. */
  47949. removeIncludedOnlyMesh(mesh: Mesh): void;
  47950. /**
  47951. * Determine if a given mesh will be used in the glow layer
  47952. * @param mesh The mesh to test
  47953. * @returns true if the mesh will be highlighted by the current glow layer
  47954. */
  47955. hasMesh(mesh: AbstractMesh): boolean;
  47956. /**
  47957. * Free any resources and references associated to a mesh.
  47958. * Internal use
  47959. * @param mesh The mesh to free.
  47960. * @hidden
  47961. */
  47962. _disposeMesh(mesh: Mesh): void;
  47963. /**
  47964. * Gets the class name of the effect layer
  47965. * @returns the string with the class name of the effect layer
  47966. */
  47967. getClassName(): string;
  47968. /**
  47969. * Serializes this glow layer
  47970. * @returns a serialized glow layer object
  47971. */
  47972. serialize(): any;
  47973. /**
  47974. * Creates a Glow Layer from parsed glow layer data
  47975. * @param parsedGlowLayer defines glow layer data
  47976. * @param scene defines the current scene
  47977. * @param rootUrl defines the root URL containing the glow layer information
  47978. * @returns a parsed Glow Layer
  47979. */
  47980. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47981. }
  47982. }
  47983. declare module BABYLON {
  47984. /** @hidden */
  47985. export var glowBlurPostProcessPixelShader: {
  47986. name: string;
  47987. shader: string;
  47988. };
  47989. }
  47990. declare module BABYLON {
  47991. interface AbstractScene {
  47992. /**
  47993. * Return a the first highlight layer of the scene with a given name.
  47994. * @param name The name of the highlight layer to look for.
  47995. * @return The highlight layer if found otherwise null.
  47996. */
  47997. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47998. }
  47999. /**
  48000. * Highlight layer options. This helps customizing the behaviour
  48001. * of the highlight layer.
  48002. */
  48003. export interface IHighlightLayerOptions {
  48004. /**
  48005. * Multiplication factor apply to the canvas size to compute the render target size
  48006. * used to generated the glowing objects (the smaller the faster).
  48007. */
  48008. mainTextureRatio: number;
  48009. /**
  48010. * Enforces a fixed size texture to ensure resize independant blur.
  48011. */
  48012. mainTextureFixedSize?: number;
  48013. /**
  48014. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48015. * of the picture to blur (the smaller the faster).
  48016. */
  48017. blurTextureSizeRatio: number;
  48018. /**
  48019. * How big in texel of the blur texture is the vertical blur.
  48020. */
  48021. blurVerticalSize: number;
  48022. /**
  48023. * How big in texel of the blur texture is the horizontal blur.
  48024. */
  48025. blurHorizontalSize: number;
  48026. /**
  48027. * Alpha blending mode used to apply the blur. Default is combine.
  48028. */
  48029. alphaBlendingMode: number;
  48030. /**
  48031. * The camera attached to the layer.
  48032. */
  48033. camera: Nullable<Camera>;
  48034. /**
  48035. * Should we display highlight as a solid stroke?
  48036. */
  48037. isStroke?: boolean;
  48038. /**
  48039. * The rendering group to draw the layer in.
  48040. */
  48041. renderingGroupId: number;
  48042. }
  48043. /**
  48044. * The highlight layer Helps adding a glow effect around a mesh.
  48045. *
  48046. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48047. * glowy meshes to your scene.
  48048. *
  48049. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48050. */
  48051. export class HighlightLayer extends EffectLayer {
  48052. name: string;
  48053. /**
  48054. * Effect Name of the highlight layer.
  48055. */
  48056. static readonly EffectName: string;
  48057. /**
  48058. * The neutral color used during the preparation of the glow effect.
  48059. * This is black by default as the blend operation is a blend operation.
  48060. */
  48061. static NeutralColor: Color4;
  48062. /**
  48063. * Stencil value used for glowing meshes.
  48064. */
  48065. static GlowingMeshStencilReference: number;
  48066. /**
  48067. * Stencil value used for the other meshes in the scene.
  48068. */
  48069. static NormalMeshStencilReference: number;
  48070. /**
  48071. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48072. */
  48073. innerGlow: boolean;
  48074. /**
  48075. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48076. */
  48077. outerGlow: boolean;
  48078. /**
  48079. * Specifies the horizontal size of the blur.
  48080. */
  48081. /**
  48082. * Gets the horizontal size of the blur.
  48083. */
  48084. blurHorizontalSize: number;
  48085. /**
  48086. * Specifies the vertical size of the blur.
  48087. */
  48088. /**
  48089. * Gets the vertical size of the blur.
  48090. */
  48091. blurVerticalSize: number;
  48092. /**
  48093. * An event triggered when the highlight layer is being blurred.
  48094. */
  48095. onBeforeBlurObservable: Observable<HighlightLayer>;
  48096. /**
  48097. * An event triggered when the highlight layer has been blurred.
  48098. */
  48099. onAfterBlurObservable: Observable<HighlightLayer>;
  48100. private _instanceGlowingMeshStencilReference;
  48101. private _options;
  48102. private _downSamplePostprocess;
  48103. private _horizontalBlurPostprocess;
  48104. private _verticalBlurPostprocess;
  48105. private _blurTexture;
  48106. private _meshes;
  48107. private _excludedMeshes;
  48108. /**
  48109. * Instantiates a new highlight Layer and references it to the scene..
  48110. * @param name The name of the layer
  48111. * @param scene The scene to use the layer in
  48112. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48113. */
  48114. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48115. /**
  48116. * Get the effect name of the layer.
  48117. * @return The effect name
  48118. */
  48119. getEffectName(): string;
  48120. /**
  48121. * Create the merge effect. This is the shader use to blit the information back
  48122. * to the main canvas at the end of the scene rendering.
  48123. */
  48124. protected _createMergeEffect(): Effect;
  48125. /**
  48126. * Creates the render target textures and post processes used in the highlight layer.
  48127. */
  48128. protected _createTextureAndPostProcesses(): void;
  48129. /**
  48130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48131. */
  48132. needStencil(): boolean;
  48133. /**
  48134. * Checks for the readiness of the element composing the layer.
  48135. * @param subMesh the mesh to check for
  48136. * @param useInstances specify wether or not to use instances to render the mesh
  48137. * @param emissiveTexture the associated emissive texture used to generate the glow
  48138. * @return true if ready otherwise, false
  48139. */
  48140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48141. /**
  48142. * Implementation specific of rendering the generating effect on the main canvas.
  48143. * @param effect The effect used to render through
  48144. */
  48145. protected _internalRender(effect: Effect): void;
  48146. /**
  48147. * Returns true if the layer contains information to display, otherwise false.
  48148. */
  48149. shouldRender(): boolean;
  48150. /**
  48151. * Returns true if the mesh should render, otherwise false.
  48152. * @param mesh The mesh to render
  48153. * @returns true if it should render otherwise false
  48154. */
  48155. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48156. /**
  48157. * Sets the required values for both the emissive texture and and the main color.
  48158. */
  48159. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48160. /**
  48161. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48162. * @param mesh The mesh to exclude from the highlight layer
  48163. */
  48164. addExcludedMesh(mesh: Mesh): void;
  48165. /**
  48166. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48167. * @param mesh The mesh to highlight
  48168. */
  48169. removeExcludedMesh(mesh: Mesh): void;
  48170. /**
  48171. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48172. * @param mesh mesh to test
  48173. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48174. */
  48175. hasMesh(mesh: AbstractMesh): boolean;
  48176. /**
  48177. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48178. * @param mesh The mesh to highlight
  48179. * @param color The color of the highlight
  48180. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48181. */
  48182. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48183. /**
  48184. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48185. * @param mesh The mesh to highlight
  48186. */
  48187. removeMesh(mesh: Mesh): void;
  48188. /**
  48189. * Force the stencil to the normal expected value for none glowing parts
  48190. */
  48191. private _defaultStencilReference;
  48192. /**
  48193. * Free any resources and references associated to a mesh.
  48194. * Internal use
  48195. * @param mesh The mesh to free.
  48196. * @hidden
  48197. */
  48198. _disposeMesh(mesh: Mesh): void;
  48199. /**
  48200. * Dispose the highlight layer and free resources.
  48201. */
  48202. dispose(): void;
  48203. /**
  48204. * Gets the class name of the effect layer
  48205. * @returns the string with the class name of the effect layer
  48206. */
  48207. getClassName(): string;
  48208. /**
  48209. * Serializes this Highlight layer
  48210. * @returns a serialized Highlight layer object
  48211. */
  48212. serialize(): any;
  48213. /**
  48214. * Creates a Highlight layer from parsed Highlight layer data
  48215. * @param parsedHightlightLayer defines the Highlight layer data
  48216. * @param scene defines the current scene
  48217. * @param rootUrl defines the root URL containing the Highlight layer information
  48218. * @returns a parsed Highlight layer
  48219. */
  48220. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48221. }
  48222. }
  48223. declare module BABYLON {
  48224. interface AbstractScene {
  48225. /**
  48226. * The list of layers (background and foreground) of the scene
  48227. */
  48228. layers: Array<Layer>;
  48229. }
  48230. /**
  48231. * Defines the layer scene component responsible to manage any layers
  48232. * in a given scene.
  48233. */
  48234. export class LayerSceneComponent implements ISceneComponent {
  48235. /**
  48236. * The component name helpfull to identify the component in the list of scene components.
  48237. */
  48238. readonly name: string;
  48239. /**
  48240. * The scene the component belongs to.
  48241. */
  48242. scene: Scene;
  48243. private _engine;
  48244. /**
  48245. * Creates a new instance of the component for the given scene
  48246. * @param scene Defines the scene to register the component in
  48247. */
  48248. constructor(scene: Scene);
  48249. /**
  48250. * Registers the component in a given scene
  48251. */
  48252. register(): void;
  48253. /**
  48254. * Rebuilds the elements related to this component in case of
  48255. * context lost for instance.
  48256. */
  48257. rebuild(): void;
  48258. /**
  48259. * Disposes the component and the associated ressources.
  48260. */
  48261. dispose(): void;
  48262. private _draw;
  48263. private _drawCameraPredicate;
  48264. private _drawCameraBackground;
  48265. private _drawCameraForeground;
  48266. private _drawRenderTargetPredicate;
  48267. private _drawRenderTargetBackground;
  48268. private _drawRenderTargetForeground;
  48269. /**
  48270. * Adds all the elements from the container to the scene
  48271. * @param container the container holding the elements
  48272. */
  48273. addFromContainer(container: AbstractScene): void;
  48274. /**
  48275. * Removes all the elements in the container from the scene
  48276. * @param container contains the elements to remove
  48277. * @param dispose if the removed element should be disposed (default: false)
  48278. */
  48279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. /** @hidden */
  48284. export var layerPixelShader: {
  48285. name: string;
  48286. shader: string;
  48287. };
  48288. }
  48289. declare module BABYLON {
  48290. /** @hidden */
  48291. export var layerVertexShader: {
  48292. name: string;
  48293. shader: string;
  48294. };
  48295. }
  48296. declare module BABYLON {
  48297. /**
  48298. * This represents a full screen 2d layer.
  48299. * This can be useful to display a picture in the background of your scene for instance.
  48300. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48301. */
  48302. export class Layer {
  48303. /**
  48304. * Define the name of the layer.
  48305. */
  48306. name: string;
  48307. /**
  48308. * Define the texture the layer should display.
  48309. */
  48310. texture: Nullable<Texture>;
  48311. /**
  48312. * Is the layer in background or foreground.
  48313. */
  48314. isBackground: boolean;
  48315. /**
  48316. * Define the color of the layer (instead of texture).
  48317. */
  48318. color: Color4;
  48319. /**
  48320. * Define the scale of the layer in order to zoom in out of the texture.
  48321. */
  48322. scale: Vector2;
  48323. /**
  48324. * Define an offset for the layer in order to shift the texture.
  48325. */
  48326. offset: Vector2;
  48327. /**
  48328. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48329. */
  48330. alphaBlendingMode: number;
  48331. /**
  48332. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48333. * Alpha test will not mix with the background color in case of transparency.
  48334. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48335. */
  48336. alphaTest: boolean;
  48337. /**
  48338. * Define a mask to restrict the layer to only some of the scene cameras.
  48339. */
  48340. layerMask: number;
  48341. /**
  48342. * Define the list of render target the layer is visible into.
  48343. */
  48344. renderTargetTextures: RenderTargetTexture[];
  48345. /**
  48346. * Define if the layer is only used in renderTarget or if it also
  48347. * renders in the main frame buffer of the canvas.
  48348. */
  48349. renderOnlyInRenderTargetTextures: boolean;
  48350. private _scene;
  48351. private _vertexBuffers;
  48352. private _indexBuffer;
  48353. private _effect;
  48354. private _alphaTestEffect;
  48355. /**
  48356. * An event triggered when the layer is disposed.
  48357. */
  48358. onDisposeObservable: Observable<Layer>;
  48359. private _onDisposeObserver;
  48360. /**
  48361. * Back compatibility with callback before the onDisposeObservable existed.
  48362. * The set callback will be triggered when the layer has been disposed.
  48363. */
  48364. onDispose: () => void;
  48365. /**
  48366. * An event triggered before rendering the scene
  48367. */
  48368. onBeforeRenderObservable: Observable<Layer>;
  48369. private _onBeforeRenderObserver;
  48370. /**
  48371. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48372. * The set callback will be triggered just before rendering the layer.
  48373. */
  48374. onBeforeRender: () => void;
  48375. /**
  48376. * An event triggered after rendering the scene
  48377. */
  48378. onAfterRenderObservable: Observable<Layer>;
  48379. private _onAfterRenderObserver;
  48380. /**
  48381. * Back compatibility with callback before the onAfterRenderObservable existed.
  48382. * The set callback will be triggered just after rendering the layer.
  48383. */
  48384. onAfterRender: () => void;
  48385. /**
  48386. * Instantiates a new layer.
  48387. * This represents a full screen 2d layer.
  48388. * This can be useful to display a picture in the background of your scene for instance.
  48389. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48390. * @param name Define the name of the layer in the scene
  48391. * @param imgUrl Define the url of the texture to display in the layer
  48392. * @param scene Define the scene the layer belongs to
  48393. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48394. * @param color Defines a color for the layer
  48395. */
  48396. constructor(
  48397. /**
  48398. * Define the name of the layer.
  48399. */
  48400. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48401. private _createIndexBuffer;
  48402. /** @hidden */
  48403. _rebuild(): void;
  48404. /**
  48405. * Renders the layer in the scene.
  48406. */
  48407. render(): void;
  48408. /**
  48409. * Disposes and releases the associated ressources.
  48410. */
  48411. dispose(): void;
  48412. }
  48413. }
  48414. declare module BABYLON {
  48415. /** @hidden */
  48416. export var lensFlarePixelShader: {
  48417. name: string;
  48418. shader: string;
  48419. };
  48420. }
  48421. declare module BABYLON {
  48422. /** @hidden */
  48423. export var lensFlareVertexShader: {
  48424. name: string;
  48425. shader: string;
  48426. };
  48427. }
  48428. declare module BABYLON {
  48429. /**
  48430. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48431. * It is usually composed of several `lensFlare`.
  48432. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48433. */
  48434. export class LensFlareSystem {
  48435. /**
  48436. * Define the name of the lens flare system
  48437. */
  48438. name: string;
  48439. /**
  48440. * List of lens flares used in this system.
  48441. */
  48442. lensFlares: LensFlare[];
  48443. /**
  48444. * Define a limit from the border the lens flare can be visible.
  48445. */
  48446. borderLimit: number;
  48447. /**
  48448. * Define a viewport border we do not want to see the lens flare in.
  48449. */
  48450. viewportBorder: number;
  48451. /**
  48452. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48453. */
  48454. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48455. /**
  48456. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48457. */
  48458. layerMask: number;
  48459. /**
  48460. * Define the id of the lens flare system in the scene.
  48461. * (equal to name by default)
  48462. */
  48463. id: string;
  48464. private _scene;
  48465. private _emitter;
  48466. private _vertexBuffers;
  48467. private _indexBuffer;
  48468. private _effect;
  48469. private _positionX;
  48470. private _positionY;
  48471. private _isEnabled;
  48472. /** @hidden */
  48473. static _SceneComponentInitialization: (scene: Scene) => void;
  48474. /**
  48475. * Instantiates a lens flare system.
  48476. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48477. * It is usually composed of several `lensFlare`.
  48478. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48479. * @param name Define the name of the lens flare system in the scene
  48480. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48481. * @param scene Define the scene the lens flare system belongs to
  48482. */
  48483. constructor(
  48484. /**
  48485. * Define the name of the lens flare system
  48486. */
  48487. name: string, emitter: any, scene: Scene);
  48488. /**
  48489. * Define if the lens flare system is enabled.
  48490. */
  48491. isEnabled: boolean;
  48492. /**
  48493. * Get the scene the effects belongs to.
  48494. * @returns the scene holding the lens flare system
  48495. */
  48496. getScene(): Scene;
  48497. /**
  48498. * Get the emitter of the lens flare system.
  48499. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48500. * @returns the emitter of the lens flare system
  48501. */
  48502. getEmitter(): any;
  48503. /**
  48504. * Set the emitter of the lens flare system.
  48505. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48506. * @param newEmitter Define the new emitter of the system
  48507. */
  48508. setEmitter(newEmitter: any): void;
  48509. /**
  48510. * Get the lens flare system emitter position.
  48511. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48512. * @returns the position
  48513. */
  48514. getEmitterPosition(): Vector3;
  48515. /**
  48516. * @hidden
  48517. */
  48518. computeEffectivePosition(globalViewport: Viewport): boolean;
  48519. /** @hidden */
  48520. _isVisible(): boolean;
  48521. /**
  48522. * @hidden
  48523. */
  48524. render(): boolean;
  48525. /**
  48526. * Dispose and release the lens flare with its associated resources.
  48527. */
  48528. dispose(): void;
  48529. /**
  48530. * Parse a lens flare system from a JSON repressentation
  48531. * @param parsedLensFlareSystem Define the JSON to parse
  48532. * @param scene Define the scene the parsed system should be instantiated in
  48533. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48534. * @returns the parsed system
  48535. */
  48536. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48537. /**
  48538. * Serialize the current Lens Flare System into a JSON representation.
  48539. * @returns the serialized JSON
  48540. */
  48541. serialize(): any;
  48542. }
  48543. }
  48544. declare module BABYLON {
  48545. /**
  48546. * This represents one of the lens effect in a `lensFlareSystem`.
  48547. * It controls one of the indiviual texture used in the effect.
  48548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48549. */
  48550. export class LensFlare {
  48551. /**
  48552. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48553. */
  48554. size: number;
  48555. /**
  48556. * 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.
  48557. */
  48558. position: number;
  48559. /**
  48560. * Define the lens color.
  48561. */
  48562. color: Color3;
  48563. /**
  48564. * Define the lens texture.
  48565. */
  48566. texture: Nullable<Texture>;
  48567. /**
  48568. * Define the alpha mode to render this particular lens.
  48569. */
  48570. alphaMode: number;
  48571. private _system;
  48572. /**
  48573. * Creates a new Lens Flare.
  48574. * This represents one of the lens effect in a `lensFlareSystem`.
  48575. * It controls one of the indiviual texture used in the effect.
  48576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48577. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48578. * @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.
  48579. * @param color Define the lens color
  48580. * @param imgUrl Define the lens texture url
  48581. * @param system Define the `lensFlareSystem` this flare is part of
  48582. * @returns The newly created Lens Flare
  48583. */
  48584. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48585. /**
  48586. * Instantiates a new Lens Flare.
  48587. * This represents one of the lens effect in a `lensFlareSystem`.
  48588. * It controls one of the indiviual texture used in the effect.
  48589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48590. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48591. * @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.
  48592. * @param color Define the lens color
  48593. * @param imgUrl Define the lens texture url
  48594. * @param system Define the `lensFlareSystem` this flare is part of
  48595. */
  48596. constructor(
  48597. /**
  48598. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48599. */
  48600. size: number,
  48601. /**
  48602. * 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.
  48603. */
  48604. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48605. /**
  48606. * Dispose and release the lens flare with its associated resources.
  48607. */
  48608. dispose(): void;
  48609. }
  48610. }
  48611. declare module BABYLON {
  48612. interface AbstractScene {
  48613. /**
  48614. * The list of lens flare system added to the scene
  48615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48616. */
  48617. lensFlareSystems: Array<LensFlareSystem>;
  48618. /**
  48619. * Removes the given lens flare system from this scene.
  48620. * @param toRemove The lens flare system to remove
  48621. * @returns The index of the removed lens flare system
  48622. */
  48623. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48624. /**
  48625. * Adds the given lens flare system to this scene
  48626. * @param newLensFlareSystem The lens flare system to add
  48627. */
  48628. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48629. /**
  48630. * Gets a lens flare system using its name
  48631. * @param name defines the name to look for
  48632. * @returns the lens flare system or null if not found
  48633. */
  48634. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48635. /**
  48636. * Gets a lens flare system using its id
  48637. * @param id defines the id to look for
  48638. * @returns the lens flare system or null if not found
  48639. */
  48640. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48641. }
  48642. /**
  48643. * Defines the lens flare scene component responsible to manage any lens flares
  48644. * in a given scene.
  48645. */
  48646. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48647. /**
  48648. * The component name helpfull to identify the component in the list of scene components.
  48649. */
  48650. readonly name: string;
  48651. /**
  48652. * The scene the component belongs to.
  48653. */
  48654. scene: Scene;
  48655. /**
  48656. * Creates a new instance of the component for the given scene
  48657. * @param scene Defines the scene to register the component in
  48658. */
  48659. constructor(scene: Scene);
  48660. /**
  48661. * Registers the component in a given scene
  48662. */
  48663. register(): void;
  48664. /**
  48665. * Rebuilds the elements related to this component in case of
  48666. * context lost for instance.
  48667. */
  48668. rebuild(): void;
  48669. /**
  48670. * Adds all the elements from the container to the scene
  48671. * @param container the container holding the elements
  48672. */
  48673. addFromContainer(container: AbstractScene): void;
  48674. /**
  48675. * Removes all the elements in the container from the scene
  48676. * @param container contains the elements to remove
  48677. * @param dispose if the removed element should be disposed (default: false)
  48678. */
  48679. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48680. /**
  48681. * Serializes the component data to the specified json object
  48682. * @param serializationObject The object to serialize to
  48683. */
  48684. serialize(serializationObject: any): void;
  48685. /**
  48686. * Disposes the component and the associated ressources.
  48687. */
  48688. dispose(): void;
  48689. private _draw;
  48690. }
  48691. }
  48692. declare module BABYLON {
  48693. /**
  48694. * Defines the shadow generator component responsible to manage any shadow generators
  48695. * in a given scene.
  48696. */
  48697. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48698. /**
  48699. * The component name helpfull to identify the component in the list of scene components.
  48700. */
  48701. readonly name: string;
  48702. /**
  48703. * The scene the component belongs to.
  48704. */
  48705. scene: Scene;
  48706. /**
  48707. * Creates a new instance of the component for the given scene
  48708. * @param scene Defines the scene to register the component in
  48709. */
  48710. constructor(scene: Scene);
  48711. /**
  48712. * Registers the component in a given scene
  48713. */
  48714. register(): void;
  48715. /**
  48716. * Rebuilds the elements related to this component in case of
  48717. * context lost for instance.
  48718. */
  48719. rebuild(): void;
  48720. /**
  48721. * Serializes the component data to the specified json object
  48722. * @param serializationObject The object to serialize to
  48723. */
  48724. serialize(serializationObject: any): void;
  48725. /**
  48726. * Adds all the elements from the container to the scene
  48727. * @param container the container holding the elements
  48728. */
  48729. addFromContainer(container: AbstractScene): void;
  48730. /**
  48731. * Removes all the elements in the container from the scene
  48732. * @param container contains the elements to remove
  48733. * @param dispose if the removed element should be disposed (default: false)
  48734. */
  48735. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48736. /**
  48737. * Rebuilds the elements related to this component in case of
  48738. * context lost for instance.
  48739. */
  48740. dispose(): void;
  48741. private _gatherRenderTargets;
  48742. }
  48743. }
  48744. declare module BABYLON {
  48745. /**
  48746. * A point light is a light defined by an unique point in world space.
  48747. * The light is emitted in every direction from this point.
  48748. * A good example of a point light is a standard light bulb.
  48749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48750. */
  48751. export class PointLight extends ShadowLight {
  48752. private _shadowAngle;
  48753. /**
  48754. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48755. * This specifies what angle the shadow will use to be created.
  48756. *
  48757. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48758. */
  48759. /**
  48760. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48761. * This specifies what angle the shadow will use to be created.
  48762. *
  48763. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48764. */
  48765. shadowAngle: number;
  48766. /**
  48767. * Gets the direction if it has been set.
  48768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48769. */
  48770. /**
  48771. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48772. */
  48773. direction: Vector3;
  48774. /**
  48775. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48776. * A PointLight emits the light in every direction.
  48777. * It can cast shadows.
  48778. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48779. * ```javascript
  48780. * var pointLight = new PointLight("pl", camera.position, scene);
  48781. * ```
  48782. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48783. * @param name The light friendly name
  48784. * @param position The position of the point light in the scene
  48785. * @param scene The scene the lights belongs to
  48786. */
  48787. constructor(name: string, position: Vector3, scene: Scene);
  48788. /**
  48789. * Returns the string "PointLight"
  48790. * @returns the class name
  48791. */
  48792. getClassName(): string;
  48793. /**
  48794. * Returns the integer 0.
  48795. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48796. */
  48797. getTypeID(): number;
  48798. /**
  48799. * Specifies wether or not the shadowmap should be a cube texture.
  48800. * @returns true if the shadowmap needs to be a cube texture.
  48801. */
  48802. needCube(): boolean;
  48803. /**
  48804. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48805. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48806. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48807. */
  48808. getShadowDirection(faceIndex?: number): Vector3;
  48809. /**
  48810. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48811. * - fov = PI / 2
  48812. * - aspect ratio : 1.0
  48813. * - z-near and far equal to the active camera minZ and maxZ.
  48814. * Returns the PointLight.
  48815. */
  48816. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48817. protected _buildUniformLayout(): void;
  48818. /**
  48819. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48820. * @param effect The effect to update
  48821. * @param lightIndex The index of the light in the effect to update
  48822. * @returns The point light
  48823. */
  48824. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48825. /**
  48826. * Prepares the list of defines specific to the light type.
  48827. * @param defines the list of defines
  48828. * @param lightIndex defines the index of the light for the effect
  48829. */
  48830. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * Header information of HDR texture files.
  48836. */
  48837. export interface HDRInfo {
  48838. /**
  48839. * The height of the texture in pixels.
  48840. */
  48841. height: number;
  48842. /**
  48843. * The width of the texture in pixels.
  48844. */
  48845. width: number;
  48846. /**
  48847. * The index of the beginning of the data in the binary file.
  48848. */
  48849. dataPosition: number;
  48850. }
  48851. /**
  48852. * This groups tools to convert HDR texture to native colors array.
  48853. */
  48854. export class HDRTools {
  48855. private static Ldexp;
  48856. private static Rgbe2float;
  48857. private static readStringLine;
  48858. /**
  48859. * Reads header information from an RGBE texture stored in a native array.
  48860. * More information on this format are available here:
  48861. * https://en.wikipedia.org/wiki/RGBE_image_format
  48862. *
  48863. * @param uint8array The binary file stored in native array.
  48864. * @return The header information.
  48865. */
  48866. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48867. /**
  48868. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48869. * This RGBE texture needs to store the information as a panorama.
  48870. *
  48871. * More information on this format are available here:
  48872. * https://en.wikipedia.org/wiki/RGBE_image_format
  48873. *
  48874. * @param buffer The binary file stored in an array buffer.
  48875. * @param size The expected size of the extracted cubemap.
  48876. * @return The Cube Map information.
  48877. */
  48878. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48879. /**
  48880. * Returns the pixels data extracted from an RGBE texture.
  48881. * This pixels will be stored left to right up to down in the R G B order in one array.
  48882. *
  48883. * More information on this format are available here:
  48884. * https://en.wikipedia.org/wiki/RGBE_image_format
  48885. *
  48886. * @param uint8array The binary file stored in an array buffer.
  48887. * @param hdrInfo The header information of the file.
  48888. * @return The pixels data in RGB right to left up to down order.
  48889. */
  48890. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48891. private static RGBE_ReadPixels_RLE;
  48892. }
  48893. }
  48894. declare module BABYLON {
  48895. /**
  48896. * This represents a texture coming from an HDR input.
  48897. *
  48898. * The only supported format is currently panorama picture stored in RGBE format.
  48899. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48900. */
  48901. export class HDRCubeTexture extends BaseTexture {
  48902. private static _facesMapping;
  48903. private _generateHarmonics;
  48904. private _noMipmap;
  48905. private _textureMatrix;
  48906. private _size;
  48907. private _onLoad;
  48908. private _onError;
  48909. /**
  48910. * The texture URL.
  48911. */
  48912. url: string;
  48913. /**
  48914. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48915. */
  48916. coordinatesMode: number;
  48917. protected _isBlocking: boolean;
  48918. /**
  48919. * Sets wether or not the texture is blocking during loading.
  48920. */
  48921. /**
  48922. * Gets wether or not the texture is blocking during loading.
  48923. */
  48924. isBlocking: boolean;
  48925. protected _rotationY: number;
  48926. /**
  48927. * Sets texture matrix rotation angle around Y axis in radians.
  48928. */
  48929. /**
  48930. * Gets texture matrix rotation angle around Y axis radians.
  48931. */
  48932. rotationY: number;
  48933. /**
  48934. * Gets or sets the center of the bounding box associated with the cube texture
  48935. * It must define where the camera used to render the texture was set
  48936. */
  48937. boundingBoxPosition: Vector3;
  48938. private _boundingBoxSize;
  48939. /**
  48940. * Gets or sets the size of the bounding box associated with the cube texture
  48941. * When defined, the cubemap will switch to local mode
  48942. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48943. * @example https://www.babylonjs-playground.com/#RNASML
  48944. */
  48945. boundingBoxSize: Vector3;
  48946. /**
  48947. * Instantiates an HDRTexture from the following parameters.
  48948. *
  48949. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48950. * @param scene The scene the texture will be used in
  48951. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48952. * @param noMipmap Forces to not generate the mipmap if true
  48953. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48954. * @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)
  48955. * @param reserved Reserved flag for internal use.
  48956. */
  48957. 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>);
  48958. /**
  48959. * Get the current class name of the texture useful for serialization or dynamic coding.
  48960. * @returns "HDRCubeTexture"
  48961. */
  48962. getClassName(): string;
  48963. /**
  48964. * Occurs when the file is raw .hdr file.
  48965. */
  48966. private loadTexture;
  48967. clone(): HDRCubeTexture;
  48968. delayLoad(): void;
  48969. /**
  48970. * Get the texture reflection matrix used to rotate/transform the reflection.
  48971. * @returns the reflection matrix
  48972. */
  48973. getReflectionTextureMatrix(): Matrix;
  48974. /**
  48975. * Set the texture reflection matrix used to rotate/transform the reflection.
  48976. * @param value Define the reflection matrix to set
  48977. */
  48978. setReflectionTextureMatrix(value: Matrix): void;
  48979. /**
  48980. * Parses a JSON representation of an HDR Texture in order to create the texture
  48981. * @param parsedTexture Define the JSON representation
  48982. * @param scene Define the scene the texture should be created in
  48983. * @param rootUrl Define the root url in case we need to load relative dependencies
  48984. * @returns the newly created texture after parsing
  48985. */
  48986. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48987. serialize(): any;
  48988. }
  48989. }
  48990. declare module BABYLON {
  48991. /**
  48992. * Class used to control physics engine
  48993. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48994. */
  48995. export class PhysicsEngine implements IPhysicsEngine {
  48996. private _physicsPlugin;
  48997. /**
  48998. * Global value used to control the smallest number supported by the simulation
  48999. */
  49000. static Epsilon: number;
  49001. private _impostors;
  49002. private _joints;
  49003. /**
  49004. * Gets the gravity vector used by the simulation
  49005. */
  49006. gravity: Vector3;
  49007. /**
  49008. * Factory used to create the default physics plugin.
  49009. * @returns The default physics plugin
  49010. */
  49011. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49012. /**
  49013. * Creates a new Physics Engine
  49014. * @param gravity defines the gravity vector used by the simulation
  49015. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49016. */
  49017. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49018. /**
  49019. * Sets the gravity vector used by the simulation
  49020. * @param gravity defines the gravity vector to use
  49021. */
  49022. setGravity(gravity: Vector3): void;
  49023. /**
  49024. * Set the time step of the physics engine.
  49025. * Default is 1/60.
  49026. * To slow it down, enter 1/600 for example.
  49027. * To speed it up, 1/30
  49028. * @param newTimeStep defines the new timestep to apply to this world.
  49029. */
  49030. setTimeStep(newTimeStep?: number): void;
  49031. /**
  49032. * Get the time step of the physics engine.
  49033. * @returns the current time step
  49034. */
  49035. getTimeStep(): number;
  49036. /**
  49037. * Release all resources
  49038. */
  49039. dispose(): void;
  49040. /**
  49041. * Gets the name of the current physics plugin
  49042. * @returns the name of the plugin
  49043. */
  49044. getPhysicsPluginName(): string;
  49045. /**
  49046. * Adding a new impostor for the impostor tracking.
  49047. * This will be done by the impostor itself.
  49048. * @param impostor the impostor to add
  49049. */
  49050. addImpostor(impostor: PhysicsImpostor): void;
  49051. /**
  49052. * Remove an impostor from the engine.
  49053. * This impostor and its mesh will not longer be updated by the physics engine.
  49054. * @param impostor the impostor to remove
  49055. */
  49056. removeImpostor(impostor: PhysicsImpostor): void;
  49057. /**
  49058. * Add a joint to the physics engine
  49059. * @param mainImpostor defines the main impostor to which the joint is added.
  49060. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49061. * @param joint defines the joint that will connect both impostors.
  49062. */
  49063. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49064. /**
  49065. * Removes a joint from the simulation
  49066. * @param mainImpostor defines the impostor used with the joint
  49067. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49068. * @param joint defines the joint to remove
  49069. */
  49070. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49071. /**
  49072. * Called by the scene. No need to call it.
  49073. * @param delta defines the timespam between frames
  49074. */
  49075. _step(delta: number): void;
  49076. /**
  49077. * Gets the current plugin used to run the simulation
  49078. * @returns current plugin
  49079. */
  49080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49081. /**
  49082. * Gets the list of physic impostors
  49083. * @returns an array of PhysicsImpostor
  49084. */
  49085. getImpostors(): Array<PhysicsImpostor>;
  49086. /**
  49087. * Gets the impostor for a physics enabled object
  49088. * @param object defines the object impersonated by the impostor
  49089. * @returns the PhysicsImpostor or null if not found
  49090. */
  49091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49092. /**
  49093. * Gets the impostor for a physics body object
  49094. * @param body defines physics body used by the impostor
  49095. * @returns the PhysicsImpostor or null if not found
  49096. */
  49097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49098. /**
  49099. * Does a raycast in the physics world
  49100. * @param from when should the ray start?
  49101. * @param to when should the ray end?
  49102. * @returns PhysicsRaycastResult
  49103. */
  49104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49105. }
  49106. }
  49107. declare module BABYLON {
  49108. /** @hidden */
  49109. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49110. private _useDeltaForWorldStep;
  49111. world: any;
  49112. name: string;
  49113. private _physicsMaterials;
  49114. private _fixedTimeStep;
  49115. private _cannonRaycastResult;
  49116. private _raycastResult;
  49117. private _physicsBodysToRemoveAfterStep;
  49118. BJSCANNON: any;
  49119. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49120. setGravity(gravity: Vector3): void;
  49121. setTimeStep(timeStep: number): void;
  49122. getTimeStep(): number;
  49123. executeStep(delta: number): void;
  49124. private _removeMarkedPhysicsBodiesFromWorld;
  49125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49128. private _processChildMeshes;
  49129. removePhysicsBody(impostor: PhysicsImpostor): void;
  49130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49131. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49132. private _addMaterial;
  49133. private _checkWithEpsilon;
  49134. private _createShape;
  49135. private _createHeightmap;
  49136. private _minus90X;
  49137. private _plus90X;
  49138. private _tmpPosition;
  49139. private _tmpDeltaPosition;
  49140. private _tmpUnityRotation;
  49141. private _updatePhysicsBodyTransformation;
  49142. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49143. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49144. isSupported(): boolean;
  49145. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49147. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49148. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49150. getBodyMass(impostor: PhysicsImpostor): number;
  49151. getBodyFriction(impostor: PhysicsImpostor): number;
  49152. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49153. getBodyRestitution(impostor: PhysicsImpostor): number;
  49154. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49155. sleepBody(impostor: PhysicsImpostor): void;
  49156. wakeUpBody(impostor: PhysicsImpostor): void;
  49157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49158. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49159. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49160. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49161. getRadius(impostor: PhysicsImpostor): number;
  49162. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49163. dispose(): void;
  49164. private _extendNamespace;
  49165. /**
  49166. * Does a raycast in the physics world
  49167. * @param from when should the ray start?
  49168. * @param to when should the ray end?
  49169. * @returns PhysicsRaycastResult
  49170. */
  49171. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49172. }
  49173. }
  49174. declare module BABYLON {
  49175. /** @hidden */
  49176. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49177. world: any;
  49178. name: string;
  49179. BJSOIMO: any;
  49180. private _raycastResult;
  49181. constructor(iterations?: number, oimoInjection?: any);
  49182. setGravity(gravity: Vector3): void;
  49183. setTimeStep(timeStep: number): void;
  49184. getTimeStep(): number;
  49185. private _tmpImpostorsArray;
  49186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49190. private _tmpPositionVector;
  49191. removePhysicsBody(impostor: PhysicsImpostor): void;
  49192. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49194. isSupported(): boolean;
  49195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49202. getBodyMass(impostor: PhysicsImpostor): number;
  49203. getBodyFriction(impostor: PhysicsImpostor): number;
  49204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49205. getBodyRestitution(impostor: PhysicsImpostor): number;
  49206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49207. sleepBody(impostor: PhysicsImpostor): void;
  49208. wakeUpBody(impostor: PhysicsImpostor): void;
  49209. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49210. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49211. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49213. getRadius(impostor: PhysicsImpostor): number;
  49214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49215. dispose(): void;
  49216. /**
  49217. * Does a raycast in the physics world
  49218. * @param from when should the ray start?
  49219. * @param to when should the ray end?
  49220. * @returns PhysicsRaycastResult
  49221. */
  49222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49223. }
  49224. }
  49225. declare module BABYLON {
  49226. /**
  49227. * Class containing static functions to help procedurally build meshes
  49228. */
  49229. export class RibbonBuilder {
  49230. /**
  49231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49235. * * 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
  49236. * * 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
  49237. * * 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
  49238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49239. * * 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
  49240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49241. * * 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
  49242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49243. * * 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
  49244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49246. * @param name defines the name of the mesh
  49247. * @param options defines the options used to create the mesh
  49248. * @param scene defines the hosting scene
  49249. * @returns the ribbon mesh
  49250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49252. */
  49253. static CreateRibbon(name: string, options: {
  49254. pathArray: Vector3[][];
  49255. closeArray?: boolean;
  49256. closePath?: boolean;
  49257. offset?: number;
  49258. updatable?: boolean;
  49259. sideOrientation?: number;
  49260. frontUVs?: Vector4;
  49261. backUVs?: Vector4;
  49262. instance?: Mesh;
  49263. invertUV?: boolean;
  49264. uvs?: Vector2[];
  49265. colors?: Color4[];
  49266. }, scene?: Nullable<Scene>): Mesh;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /**
  49271. * Class containing static functions to help procedurally build meshes
  49272. */
  49273. export class ShapeBuilder {
  49274. /**
  49275. * 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.
  49276. * * 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.
  49277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49278. * * 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.
  49279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49280. * * 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
  49281. * * 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
  49282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49284. * * 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
  49285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49287. * @param name defines the name of the mesh
  49288. * @param options defines the options used to create the mesh
  49289. * @param scene defines the hosting scene
  49290. * @returns the extruded shape mesh
  49291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49293. */
  49294. static ExtrudeShape(name: string, options: {
  49295. shape: Vector3[];
  49296. path: Vector3[];
  49297. scale?: number;
  49298. rotation?: number;
  49299. cap?: number;
  49300. updatable?: boolean;
  49301. sideOrientation?: number;
  49302. frontUVs?: Vector4;
  49303. backUVs?: Vector4;
  49304. instance?: Mesh;
  49305. invertUV?: boolean;
  49306. }, scene?: Nullable<Scene>): Mesh;
  49307. /**
  49308. * Creates an custom extruded shape mesh.
  49309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49310. * * 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.
  49311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49312. * * 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
  49313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49314. * * 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
  49315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49318. * * 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
  49319. * * 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
  49320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49322. * * 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
  49323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49325. * @param name defines the name of the mesh
  49326. * @param options defines the options used to create the mesh
  49327. * @param scene defines the hosting scene
  49328. * @returns the custom extruded shape mesh
  49329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49332. */
  49333. static ExtrudeShapeCustom(name: string, options: {
  49334. shape: Vector3[];
  49335. path: Vector3[];
  49336. scaleFunction?: any;
  49337. rotationFunction?: any;
  49338. ribbonCloseArray?: boolean;
  49339. ribbonClosePath?: boolean;
  49340. cap?: number;
  49341. updatable?: boolean;
  49342. sideOrientation?: number;
  49343. frontUVs?: Vector4;
  49344. backUVs?: Vector4;
  49345. instance?: Mesh;
  49346. invertUV?: boolean;
  49347. }, scene?: Nullable<Scene>): Mesh;
  49348. private static _ExtrudeShapeGeneric;
  49349. }
  49350. }
  49351. declare module BABYLON {
  49352. /**
  49353. * AmmoJS Physics plugin
  49354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49355. * @see https://github.com/kripken/ammo.js/
  49356. */
  49357. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49358. private _useDeltaForWorldStep;
  49359. /**
  49360. * Reference to the Ammo library
  49361. */
  49362. bjsAMMO: any;
  49363. /**
  49364. * Created ammoJS world which physics bodies are added to
  49365. */
  49366. world: any;
  49367. /**
  49368. * Name of the plugin
  49369. */
  49370. name: string;
  49371. private _timeStep;
  49372. private _fixedTimeStep;
  49373. private _maxSteps;
  49374. private _tmpQuaternion;
  49375. private _tmpAmmoTransform;
  49376. private _tmpAmmoQuaternion;
  49377. private _tmpAmmoConcreteContactResultCallback;
  49378. private _collisionConfiguration;
  49379. private _dispatcher;
  49380. private _overlappingPairCache;
  49381. private _solver;
  49382. private _softBodySolver;
  49383. private _tmpAmmoVectorA;
  49384. private _tmpAmmoVectorB;
  49385. private _tmpAmmoVectorC;
  49386. private _tmpAmmoVectorD;
  49387. private _tmpContactCallbackResult;
  49388. private _tmpAmmoVectorRCA;
  49389. private _tmpAmmoVectorRCB;
  49390. private _raycastResult;
  49391. private static readonly DISABLE_COLLISION_FLAG;
  49392. private static readonly KINEMATIC_FLAG;
  49393. private static readonly DISABLE_DEACTIVATION_FLAG;
  49394. /**
  49395. * Initializes the ammoJS plugin
  49396. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49397. * @param ammoInjection can be used to inject your own ammo reference
  49398. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49399. */
  49400. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49401. /**
  49402. * Sets the gravity of the physics world (m/(s^2))
  49403. * @param gravity Gravity to set
  49404. */
  49405. setGravity(gravity: Vector3): void;
  49406. /**
  49407. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49408. * @param timeStep timestep to use in seconds
  49409. */
  49410. setTimeStep(timeStep: number): void;
  49411. /**
  49412. * 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)
  49413. * @param fixedTimeStep fixedTimeStep to use in seconds
  49414. */
  49415. setFixedTimeStep(fixedTimeStep: number): void;
  49416. /**
  49417. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49418. * @param maxSteps the maximum number of steps by the physics engine per frame
  49419. */
  49420. setMaxSteps(maxSteps: number): void;
  49421. /**
  49422. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49423. * @returns the current timestep in seconds
  49424. */
  49425. getTimeStep(): number;
  49426. private _isImpostorInContact;
  49427. private _isImpostorPairInContact;
  49428. private _stepSimulation;
  49429. /**
  49430. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49431. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49432. * After the step the babylon meshes are set to the position of the physics imposters
  49433. * @param delta amount of time to step forward
  49434. * @param impostors array of imposters to update before/after the step
  49435. */
  49436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49437. /**
  49438. * Update babylon mesh to match physics world object
  49439. * @param impostor imposter to match
  49440. */
  49441. private _afterSoftStep;
  49442. /**
  49443. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49444. * @param impostor imposter to match
  49445. */
  49446. private _ropeStep;
  49447. /**
  49448. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49449. * @param impostor imposter to match
  49450. */
  49451. private _softbodyOrClothStep;
  49452. private _tmpVector;
  49453. private _tmpMatrix;
  49454. /**
  49455. * Applies an impulse on the imposter
  49456. * @param impostor imposter to apply impulse to
  49457. * @param force amount of force to be applied to the imposter
  49458. * @param contactPoint the location to apply the impulse on the imposter
  49459. */
  49460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49461. /**
  49462. * Applies a force on the imposter
  49463. * @param impostor imposter to apply force
  49464. * @param force amount of force to be applied to the imposter
  49465. * @param contactPoint the location to apply the force on the imposter
  49466. */
  49467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49468. /**
  49469. * Creates a physics body using the plugin
  49470. * @param impostor the imposter to create the physics body on
  49471. */
  49472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49473. /**
  49474. * Removes the physics body from the imposter and disposes of the body's memory
  49475. * @param impostor imposter to remove the physics body from
  49476. */
  49477. removePhysicsBody(impostor: PhysicsImpostor): void;
  49478. /**
  49479. * Generates a joint
  49480. * @param impostorJoint the imposter joint to create the joint with
  49481. */
  49482. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49483. /**
  49484. * Removes a joint
  49485. * @param impostorJoint the imposter joint to remove the joint from
  49486. */
  49487. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49488. private _addMeshVerts;
  49489. /**
  49490. * Initialise the soft body vertices to match its object's (mesh) vertices
  49491. * Softbody vertices (nodes) are in world space and to match this
  49492. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49493. * @param impostor to create the softbody for
  49494. */
  49495. private _softVertexData;
  49496. /**
  49497. * Create an impostor's soft body
  49498. * @param impostor to create the softbody for
  49499. */
  49500. private _createSoftbody;
  49501. /**
  49502. * Create cloth for an impostor
  49503. * @param impostor to create the softbody for
  49504. */
  49505. private _createCloth;
  49506. /**
  49507. * Create rope for an impostor
  49508. * @param impostor to create the softbody for
  49509. */
  49510. private _createRope;
  49511. private _addHullVerts;
  49512. private _createShape;
  49513. /**
  49514. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49515. * @param impostor imposter containing the physics body and babylon object
  49516. */
  49517. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49518. /**
  49519. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49520. * @param impostor imposter containing the physics body and babylon object
  49521. * @param newPosition new position
  49522. * @param newRotation new rotation
  49523. */
  49524. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49525. /**
  49526. * If this plugin is supported
  49527. * @returns true if its supported
  49528. */
  49529. isSupported(): boolean;
  49530. /**
  49531. * Sets the linear velocity of the physics body
  49532. * @param impostor imposter to set the velocity on
  49533. * @param velocity velocity to set
  49534. */
  49535. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49536. /**
  49537. * Sets the angular velocity of the physics body
  49538. * @param impostor imposter to set the velocity on
  49539. * @param velocity velocity to set
  49540. */
  49541. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49542. /**
  49543. * gets the linear velocity
  49544. * @param impostor imposter to get linear velocity from
  49545. * @returns linear velocity
  49546. */
  49547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49548. /**
  49549. * gets the angular velocity
  49550. * @param impostor imposter to get angular velocity from
  49551. * @returns angular velocity
  49552. */
  49553. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49554. /**
  49555. * Sets the mass of physics body
  49556. * @param impostor imposter to set the mass on
  49557. * @param mass mass to set
  49558. */
  49559. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49560. /**
  49561. * Gets the mass of the physics body
  49562. * @param impostor imposter to get the mass from
  49563. * @returns mass
  49564. */
  49565. getBodyMass(impostor: PhysicsImpostor): number;
  49566. /**
  49567. * Gets friction of the impostor
  49568. * @param impostor impostor to get friction from
  49569. * @returns friction value
  49570. */
  49571. getBodyFriction(impostor: PhysicsImpostor): number;
  49572. /**
  49573. * Sets friction of the impostor
  49574. * @param impostor impostor to set friction on
  49575. * @param friction friction value
  49576. */
  49577. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49578. /**
  49579. * Gets restitution of the impostor
  49580. * @param impostor impostor to get restitution from
  49581. * @returns restitution value
  49582. */
  49583. getBodyRestitution(impostor: PhysicsImpostor): number;
  49584. /**
  49585. * Sets resitution of the impostor
  49586. * @param impostor impostor to set resitution on
  49587. * @param restitution resitution value
  49588. */
  49589. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49590. /**
  49591. * Gets pressure inside the impostor
  49592. * @param impostor impostor to get pressure from
  49593. * @returns pressure value
  49594. */
  49595. getBodyPressure(impostor: PhysicsImpostor): number;
  49596. /**
  49597. * Sets pressure inside a soft body impostor
  49598. * Cloth and rope must remain 0 pressure
  49599. * @param impostor impostor to set pressure on
  49600. * @param pressure pressure value
  49601. */
  49602. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49603. /**
  49604. * Gets stiffness of the impostor
  49605. * @param impostor impostor to get stiffness from
  49606. * @returns pressure value
  49607. */
  49608. getBodyStiffness(impostor: PhysicsImpostor): number;
  49609. /**
  49610. * Sets stiffness of the impostor
  49611. * @param impostor impostor to set stiffness on
  49612. * @param stiffness stiffness value from 0 to 1
  49613. */
  49614. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49615. /**
  49616. * Gets velocityIterations of the impostor
  49617. * @param impostor impostor to get velocity iterations from
  49618. * @returns velocityIterations value
  49619. */
  49620. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49621. /**
  49622. * Sets velocityIterations of the impostor
  49623. * @param impostor impostor to set velocity iterations on
  49624. * @param velocityIterations velocityIterations value
  49625. */
  49626. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49627. /**
  49628. * Gets positionIterations of the impostor
  49629. * @param impostor impostor to get position iterations from
  49630. * @returns positionIterations value
  49631. */
  49632. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49633. /**
  49634. * Sets positionIterations of the impostor
  49635. * @param impostor impostor to set position on
  49636. * @param positionIterations positionIterations value
  49637. */
  49638. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49639. /**
  49640. * Append an anchor to a cloth object
  49641. * @param impostor is the cloth impostor to add anchor to
  49642. * @param otherImpostor is the rigid impostor to anchor to
  49643. * @param width ratio across width from 0 to 1
  49644. * @param height ratio up height from 0 to 1
  49645. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49646. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49647. */
  49648. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49649. /**
  49650. * Append an hook to a rope object
  49651. * @param impostor is the rope impostor to add hook to
  49652. * @param otherImpostor is the rigid impostor to hook to
  49653. * @param length ratio along the rope from 0 to 1
  49654. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49655. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49656. */
  49657. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49658. /**
  49659. * Sleeps the physics body and stops it from being active
  49660. * @param impostor impostor to sleep
  49661. */
  49662. sleepBody(impostor: PhysicsImpostor): void;
  49663. /**
  49664. * Activates the physics body
  49665. * @param impostor impostor to activate
  49666. */
  49667. wakeUpBody(impostor: PhysicsImpostor): void;
  49668. /**
  49669. * Updates the distance parameters of the joint
  49670. * @param joint joint to update
  49671. * @param maxDistance maximum distance of the joint
  49672. * @param minDistance minimum distance of the joint
  49673. */
  49674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49675. /**
  49676. * Sets a motor on the joint
  49677. * @param joint joint to set motor on
  49678. * @param speed speed of the motor
  49679. * @param maxForce maximum force of the motor
  49680. * @param motorIndex index of the motor
  49681. */
  49682. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49683. /**
  49684. * Sets the motors limit
  49685. * @param joint joint to set limit on
  49686. * @param upperLimit upper limit
  49687. * @param lowerLimit lower limit
  49688. */
  49689. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49690. /**
  49691. * Syncs the position and rotation of a mesh with the impostor
  49692. * @param mesh mesh to sync
  49693. * @param impostor impostor to update the mesh with
  49694. */
  49695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49696. /**
  49697. * Gets the radius of the impostor
  49698. * @param impostor impostor to get radius from
  49699. * @returns the radius
  49700. */
  49701. getRadius(impostor: PhysicsImpostor): number;
  49702. /**
  49703. * Gets the box size of the impostor
  49704. * @param impostor impostor to get box size from
  49705. * @param result the resulting box size
  49706. */
  49707. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49708. /**
  49709. * Disposes of the impostor
  49710. */
  49711. dispose(): void;
  49712. /**
  49713. * Does a raycast in the physics world
  49714. * @param from when should the ray start?
  49715. * @param to when should the ray end?
  49716. * @returns PhysicsRaycastResult
  49717. */
  49718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49719. }
  49720. }
  49721. declare module BABYLON {
  49722. interface AbstractScene {
  49723. /**
  49724. * The list of reflection probes added to the scene
  49725. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49726. */
  49727. reflectionProbes: Array<ReflectionProbe>;
  49728. /**
  49729. * Removes the given reflection probe from this scene.
  49730. * @param toRemove The reflection probe to remove
  49731. * @returns The index of the removed reflection probe
  49732. */
  49733. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49734. /**
  49735. * Adds the given reflection probe to this scene.
  49736. * @param newReflectionProbe The reflection probe to add
  49737. */
  49738. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49739. }
  49740. /**
  49741. * Class used to generate realtime reflection / refraction cube textures
  49742. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49743. */
  49744. export class ReflectionProbe {
  49745. /** defines the name of the probe */
  49746. name: string;
  49747. private _scene;
  49748. private _renderTargetTexture;
  49749. private _projectionMatrix;
  49750. private _viewMatrix;
  49751. private _target;
  49752. private _add;
  49753. private _attachedMesh;
  49754. private _invertYAxis;
  49755. /** Gets or sets probe position (center of the cube map) */
  49756. position: Vector3;
  49757. /**
  49758. * Creates a new reflection probe
  49759. * @param name defines the name of the probe
  49760. * @param size defines the texture resolution (for each face)
  49761. * @param scene defines the hosting scene
  49762. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49763. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49764. */
  49765. constructor(
  49766. /** defines the name of the probe */
  49767. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49768. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49769. samples: number;
  49770. /** Gets or sets the refresh rate to use (on every frame by default) */
  49771. refreshRate: number;
  49772. /**
  49773. * Gets the hosting scene
  49774. * @returns a Scene
  49775. */
  49776. getScene(): Scene;
  49777. /** Gets the internal CubeTexture used to render to */
  49778. readonly cubeTexture: RenderTargetTexture;
  49779. /** Gets the list of meshes to render */
  49780. readonly renderList: Nullable<AbstractMesh[]>;
  49781. /**
  49782. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49783. * @param mesh defines the mesh to attach to
  49784. */
  49785. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49786. /**
  49787. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49788. * @param renderingGroupId The rendering group id corresponding to its index
  49789. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49790. */
  49791. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49792. /**
  49793. * Clean all associated resources
  49794. */
  49795. dispose(): void;
  49796. /**
  49797. * Converts the reflection probe information to a readable string for debug purpose.
  49798. * @param fullDetails Supports for multiple levels of logging within scene loading
  49799. * @returns the human readable reflection probe info
  49800. */
  49801. toString(fullDetails?: boolean): string;
  49802. /**
  49803. * Get the class name of the relfection probe.
  49804. * @returns "ReflectionProbe"
  49805. */
  49806. getClassName(): string;
  49807. /**
  49808. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49809. * @returns The JSON representation of the texture
  49810. */
  49811. serialize(): any;
  49812. /**
  49813. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49814. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49815. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49816. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49817. * @returns The parsed reflection probe if successful
  49818. */
  49819. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49820. }
  49821. }
  49822. declare module BABYLON {
  49823. /** @hidden */
  49824. export var _BabylonLoaderRegistered: boolean;
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * The Physically based simple base material of BJS.
  49829. *
  49830. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49831. * It is used as the base class for both the specGloss and metalRough conventions.
  49832. */
  49833. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, disables all the lights affecting the material.
  49840. */
  49841. disableLighting: boolean;
  49842. /**
  49843. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49844. */
  49845. environmentTexture: BaseTexture;
  49846. /**
  49847. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49848. */
  49849. invertNormalMapX: boolean;
  49850. /**
  49851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49852. */
  49853. invertNormalMapY: boolean;
  49854. /**
  49855. * Normal map used in the model.
  49856. */
  49857. normalTexture: BaseTexture;
  49858. /**
  49859. * Emissivie color used to self-illuminate the model.
  49860. */
  49861. emissiveColor: Color3;
  49862. /**
  49863. * Emissivie texture used to self-illuminate the model.
  49864. */
  49865. emissiveTexture: BaseTexture;
  49866. /**
  49867. * Occlusion Channel Strenght.
  49868. */
  49869. occlusionStrength: number;
  49870. /**
  49871. * Occlusion Texture of the material (adding extra occlusion effects).
  49872. */
  49873. occlusionTexture: BaseTexture;
  49874. /**
  49875. * Defines the alpha limits in alpha test mode.
  49876. */
  49877. alphaCutOff: number;
  49878. /**
  49879. * Gets the current double sided mode.
  49880. */
  49881. /**
  49882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49883. */
  49884. doubleSided: boolean;
  49885. /**
  49886. * Stores the pre-calculated light information of a mesh in a texture.
  49887. */
  49888. lightmapTexture: BaseTexture;
  49889. /**
  49890. * If true, the light map contains occlusion information instead of lighting info.
  49891. */
  49892. useLightmapAsShadowmap: boolean;
  49893. /**
  49894. * Instantiates a new PBRMaterial instance.
  49895. *
  49896. * @param name The material name
  49897. * @param scene The scene the material will be use in.
  49898. */
  49899. constructor(name: string, scene: Scene);
  49900. getClassName(): string;
  49901. }
  49902. }
  49903. declare module BABYLON {
  49904. /**
  49905. * The PBR material of BJS following the metal roughness convention.
  49906. *
  49907. * This fits to the PBR convention in the GLTF definition:
  49908. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49909. */
  49910. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49911. /**
  49912. * The base color has two different interpretations depending on the value of metalness.
  49913. * When the material is a metal, the base color is the specific measured reflectance value
  49914. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49915. * of the material.
  49916. */
  49917. baseColor: Color3;
  49918. /**
  49919. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49920. * well as opacity information in the alpha channel.
  49921. */
  49922. baseTexture: BaseTexture;
  49923. /**
  49924. * Specifies the metallic scalar value of the material.
  49925. * Can also be used to scale the metalness values of the metallic texture.
  49926. */
  49927. metallic: number;
  49928. /**
  49929. * Specifies the roughness scalar value of the material.
  49930. * Can also be used to scale the roughness values of the metallic texture.
  49931. */
  49932. roughness: number;
  49933. /**
  49934. * Texture containing both the metallic value in the B channel and the
  49935. * roughness value in the G channel to keep better precision.
  49936. */
  49937. metallicRoughnessTexture: BaseTexture;
  49938. /**
  49939. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49940. *
  49941. * @param name The material name
  49942. * @param scene The scene the material will be use in.
  49943. */
  49944. constructor(name: string, scene: Scene);
  49945. /**
  49946. * Return the currrent class name of the material.
  49947. */
  49948. getClassName(): string;
  49949. /**
  49950. * Makes a duplicate of the current material.
  49951. * @param name - name to use for the new material.
  49952. */
  49953. clone(name: string): PBRMetallicRoughnessMaterial;
  49954. /**
  49955. * Serialize the material to a parsable JSON object.
  49956. */
  49957. serialize(): any;
  49958. /**
  49959. * Parses a JSON object correponding to the serialize function.
  49960. */
  49961. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * The PBR material of BJS following the specular glossiness convention.
  49967. *
  49968. * This fits to the PBR convention in the GLTF definition:
  49969. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49970. */
  49971. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49972. /**
  49973. * Specifies the diffuse color of the material.
  49974. */
  49975. diffuseColor: Color3;
  49976. /**
  49977. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49978. * channel.
  49979. */
  49980. diffuseTexture: BaseTexture;
  49981. /**
  49982. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49983. */
  49984. specularColor: Color3;
  49985. /**
  49986. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49987. */
  49988. glossiness: number;
  49989. /**
  49990. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49991. */
  49992. specularGlossinessTexture: BaseTexture;
  49993. /**
  49994. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49995. *
  49996. * @param name The material name
  49997. * @param scene The scene the material will be use in.
  49998. */
  49999. constructor(name: string, scene: Scene);
  50000. /**
  50001. * Return the currrent class name of the material.
  50002. */
  50003. getClassName(): string;
  50004. /**
  50005. * Makes a duplicate of the current material.
  50006. * @param name - name to use for the new material.
  50007. */
  50008. clone(name: string): PBRSpecularGlossinessMaterial;
  50009. /**
  50010. * Serialize the material to a parsable JSON object.
  50011. */
  50012. serialize(): any;
  50013. /**
  50014. * Parses a JSON object correponding to the serialize function.
  50015. */
  50016. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50017. }
  50018. }
  50019. declare module BABYLON {
  50020. /**
  50021. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50022. * It can help converting any input color in a desired output one. This can then be used to create effects
  50023. * from sepia, black and white to sixties or futuristic rendering...
  50024. *
  50025. * The only supported format is currently 3dl.
  50026. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50027. */
  50028. export class ColorGradingTexture extends BaseTexture {
  50029. /**
  50030. * The current texture matrix. (will always be identity in color grading texture)
  50031. */
  50032. private _textureMatrix;
  50033. /**
  50034. * The texture URL.
  50035. */
  50036. url: string;
  50037. /**
  50038. * Empty line regex stored for GC.
  50039. */
  50040. private static _noneEmptyLineRegex;
  50041. private _engine;
  50042. /**
  50043. * Instantiates a ColorGradingTexture from the following parameters.
  50044. *
  50045. * @param url The location of the color gradind data (currently only supporting 3dl)
  50046. * @param scene The scene the texture will be used in
  50047. */
  50048. constructor(url: string, scene: Scene);
  50049. /**
  50050. * Returns the texture matrix used in most of the material.
  50051. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50052. */
  50053. getTextureMatrix(): Matrix;
  50054. /**
  50055. * Occurs when the file being loaded is a .3dl LUT file.
  50056. */
  50057. private load3dlTexture;
  50058. /**
  50059. * Starts the loading process of the texture.
  50060. */
  50061. private loadTexture;
  50062. /**
  50063. * Clones the color gradind texture.
  50064. */
  50065. clone(): ColorGradingTexture;
  50066. /**
  50067. * Called during delayed load for textures.
  50068. */
  50069. delayLoad(): void;
  50070. /**
  50071. * Parses a color grading texture serialized by Babylon.
  50072. * @param parsedTexture The texture information being parsedTexture
  50073. * @param scene The scene to load the texture in
  50074. * @param rootUrl The root url of the data assets to load
  50075. * @return A color gradind texture
  50076. */
  50077. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50078. /**
  50079. * Serializes the LUT texture to json format.
  50080. */
  50081. serialize(): any;
  50082. }
  50083. }
  50084. declare module BABYLON {
  50085. /**
  50086. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50087. */
  50088. export class EquiRectangularCubeTexture extends BaseTexture {
  50089. /** The six faces of the cube. */
  50090. private static _FacesMapping;
  50091. private _noMipmap;
  50092. private _onLoad;
  50093. private _onError;
  50094. /** The size of the cubemap. */
  50095. private _size;
  50096. /** The buffer of the image. */
  50097. private _buffer;
  50098. /** The width of the input image. */
  50099. private _width;
  50100. /** The height of the input image. */
  50101. private _height;
  50102. /** The URL to the image. */
  50103. url: string;
  50104. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50105. coordinatesMode: number;
  50106. /**
  50107. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50108. * @param url The location of the image
  50109. * @param scene The scene the texture will be used in
  50110. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50111. * @param noMipmap Forces to not generate the mipmap if true
  50112. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50113. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50114. * @param onLoad — defines a callback called when texture is loaded
  50115. * @param onError — defines a callback called if there is an error
  50116. */
  50117. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50118. /**
  50119. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50120. */
  50121. private loadImage;
  50122. /**
  50123. * Convert the image buffer into a cubemap and create a CubeTexture.
  50124. */
  50125. private loadTexture;
  50126. /**
  50127. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50128. * @param buffer The ArrayBuffer that should be converted.
  50129. * @returns The buffer as Float32Array.
  50130. */
  50131. private getFloat32ArrayFromArrayBuffer;
  50132. /**
  50133. * Get the current class name of the texture useful for serialization or dynamic coding.
  50134. * @returns "EquiRectangularCubeTexture"
  50135. */
  50136. getClassName(): string;
  50137. /**
  50138. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50139. * @returns A clone of the current EquiRectangularCubeTexture.
  50140. */
  50141. clone(): EquiRectangularCubeTexture;
  50142. }
  50143. }
  50144. declare module BABYLON {
  50145. /**
  50146. * Based on jsTGALoader - Javascript loader for TGA file
  50147. * By Vincent Thibault
  50148. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50149. */
  50150. export class TGATools {
  50151. private static _TYPE_INDEXED;
  50152. private static _TYPE_RGB;
  50153. private static _TYPE_GREY;
  50154. private static _TYPE_RLE_INDEXED;
  50155. private static _TYPE_RLE_RGB;
  50156. private static _TYPE_RLE_GREY;
  50157. private static _ORIGIN_MASK;
  50158. private static _ORIGIN_SHIFT;
  50159. private static _ORIGIN_BL;
  50160. private static _ORIGIN_BR;
  50161. private static _ORIGIN_UL;
  50162. private static _ORIGIN_UR;
  50163. /**
  50164. * Gets the header of a TGA file
  50165. * @param data defines the TGA data
  50166. * @returns the header
  50167. */
  50168. static GetTGAHeader(data: Uint8Array): any;
  50169. /**
  50170. * Uploads TGA content to a Babylon Texture
  50171. * @hidden
  50172. */
  50173. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50174. /** @hidden */
  50175. 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;
  50176. /** @hidden */
  50177. 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;
  50178. /** @hidden */
  50179. 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;
  50180. /** @hidden */
  50181. 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;
  50182. /** @hidden */
  50183. 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;
  50184. /** @hidden */
  50185. 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;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * Implementation of the TGA Texture Loader.
  50191. * @hidden
  50192. */
  50193. export class _TGATextureLoader implements IInternalTextureLoader {
  50194. /**
  50195. * Defines wether the loader supports cascade loading the different faces.
  50196. */
  50197. readonly supportCascades: boolean;
  50198. /**
  50199. * This returns if the loader support the current file information.
  50200. * @param extension defines the file extension of the file being loaded
  50201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50202. * @param fallback defines the fallback internal texture if any
  50203. * @param isBase64 defines whether the texture is encoded as a base64
  50204. * @param isBuffer defines whether the texture data are stored as a buffer
  50205. * @returns true if the loader can load the specified file
  50206. */
  50207. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50208. /**
  50209. * Transform the url before loading if required.
  50210. * @param rootUrl the url of the texture
  50211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50212. * @returns the transformed texture
  50213. */
  50214. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50215. /**
  50216. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50217. * @param rootUrl the url of the texture
  50218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50219. * @returns the fallback texture
  50220. */
  50221. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50222. /**
  50223. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50224. * @param data contains the texture data
  50225. * @param texture defines the BabylonJS internal texture
  50226. * @param createPolynomials will be true if polynomials have been requested
  50227. * @param onLoad defines the callback to trigger once the texture is ready
  50228. * @param onError defines the callback to trigger in case of error
  50229. */
  50230. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50231. /**
  50232. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50233. * @param data contains the texture data
  50234. * @param texture defines the BabylonJS internal texture
  50235. * @param callback defines the method to call once ready to upload
  50236. */
  50237. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50238. }
  50239. }
  50240. declare module BABYLON {
  50241. /**
  50242. * Info about the .basis files
  50243. */
  50244. class BasisFileInfo {
  50245. /**
  50246. * If the file has alpha
  50247. */
  50248. hasAlpha: boolean;
  50249. /**
  50250. * Info about each image of the basis file
  50251. */
  50252. images: Array<{
  50253. levels: Array<{
  50254. width: number;
  50255. height: number;
  50256. transcodedPixels: ArrayBufferView;
  50257. }>;
  50258. }>;
  50259. }
  50260. /**
  50261. * Result of transcoding a basis file
  50262. */
  50263. class TranscodeResult {
  50264. /**
  50265. * Info about the .basis file
  50266. */
  50267. fileInfo: BasisFileInfo;
  50268. /**
  50269. * Format to use when loading the file
  50270. */
  50271. format: number;
  50272. }
  50273. /**
  50274. * Configuration options for the Basis transcoder
  50275. */
  50276. export class BasisTranscodeConfiguration {
  50277. /**
  50278. * Supported compression formats used to determine the supported output format of the transcoder
  50279. */
  50280. supportedCompressionFormats?: {
  50281. /**
  50282. * etc1 compression format
  50283. */
  50284. etc1?: boolean;
  50285. /**
  50286. * s3tc compression format
  50287. */
  50288. s3tc?: boolean;
  50289. /**
  50290. * pvrtc compression format
  50291. */
  50292. pvrtc?: boolean;
  50293. /**
  50294. * etc2 compression format
  50295. */
  50296. etc2?: boolean;
  50297. };
  50298. /**
  50299. * If mipmap levels should be loaded for transcoded images (Default: true)
  50300. */
  50301. loadMipmapLevels?: boolean;
  50302. /**
  50303. * Index of a single image to load (Default: all images)
  50304. */
  50305. loadSingleImage?: number;
  50306. }
  50307. /**
  50308. * Used to load .Basis files
  50309. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50310. */
  50311. export class BasisTools {
  50312. private static _IgnoreSupportedFormats;
  50313. /**
  50314. * URL to use when loading the basis transcoder
  50315. */
  50316. static JSModuleURL: string;
  50317. /**
  50318. * URL to use when loading the wasm module for the transcoder
  50319. */
  50320. static WasmModuleURL: string;
  50321. /**
  50322. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50323. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50324. * @returns internal format corresponding to the Basis format
  50325. */
  50326. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50327. private static _WorkerPromise;
  50328. private static _Worker;
  50329. private static _actionId;
  50330. private static _CreateWorkerAsync;
  50331. /**
  50332. * Transcodes a loaded image file to compressed pixel data
  50333. * @param imageData image data to transcode
  50334. * @param config configuration options for the transcoding
  50335. * @returns a promise resulting in the transcoded image
  50336. */
  50337. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50338. /**
  50339. * Loads a texture from the transcode result
  50340. * @param texture texture load to
  50341. * @param transcodeResult the result of transcoding the basis file to load from
  50342. */
  50343. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50344. }
  50345. }
  50346. declare module BABYLON {
  50347. /**
  50348. * Loader for .basis file format
  50349. */
  50350. export class _BasisTextureLoader implements IInternalTextureLoader {
  50351. /**
  50352. * Defines whether the loader supports cascade loading the different faces.
  50353. */
  50354. readonly supportCascades: boolean;
  50355. /**
  50356. * This returns if the loader support the current file information.
  50357. * @param extension defines the file extension of the file being loaded
  50358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50359. * @param fallback defines the fallback internal texture if any
  50360. * @param isBase64 defines whether the texture is encoded as a base64
  50361. * @param isBuffer defines whether the texture data are stored as a buffer
  50362. * @returns true if the loader can load the specified file
  50363. */
  50364. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50365. /**
  50366. * Transform the url before loading if required.
  50367. * @param rootUrl the url of the texture
  50368. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50369. * @returns the transformed texture
  50370. */
  50371. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50372. /**
  50373. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50374. * @param rootUrl the url of the texture
  50375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50376. * @returns the fallback texture
  50377. */
  50378. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50379. /**
  50380. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50381. * @param data contains the texture data
  50382. * @param texture defines the BabylonJS internal texture
  50383. * @param createPolynomials will be true if polynomials have been requested
  50384. * @param onLoad defines the callback to trigger once the texture is ready
  50385. * @param onError defines the callback to trigger in case of error
  50386. */
  50387. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50388. /**
  50389. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50390. * @param data contains the texture data
  50391. * @param texture defines the BabylonJS internal texture
  50392. * @param callback defines the method to call once ready to upload
  50393. */
  50394. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50395. }
  50396. }
  50397. declare module BABYLON {
  50398. /**
  50399. * 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.
  50400. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50401. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50402. */
  50403. export class CustomProceduralTexture extends ProceduralTexture {
  50404. private _animate;
  50405. private _time;
  50406. private _config;
  50407. private _texturePath;
  50408. /**
  50409. * Instantiates a new Custom Procedural Texture.
  50410. * 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.
  50411. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50412. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50413. * @param name Define the name of the texture
  50414. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50415. * @param size Define the size of the texture to create
  50416. * @param scene Define the scene the texture belongs to
  50417. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50418. * @param generateMipMaps Define if the texture should creates mip maps or not
  50419. */
  50420. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50421. private _loadJson;
  50422. /**
  50423. * Is the texture ready to be used ? (rendered at least once)
  50424. * @returns true if ready, otherwise, false.
  50425. */
  50426. isReady(): boolean;
  50427. /**
  50428. * Render the texture to its associated render target.
  50429. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50430. */
  50431. render(useCameraPostProcess?: boolean): void;
  50432. /**
  50433. * Update the list of dependant textures samplers in the shader.
  50434. */
  50435. updateTextures(): void;
  50436. /**
  50437. * Update the uniform values of the procedural texture in the shader.
  50438. */
  50439. updateShaderUniforms(): void;
  50440. /**
  50441. * Define if the texture animates or not.
  50442. */
  50443. animate: boolean;
  50444. }
  50445. }
  50446. declare module BABYLON {
  50447. /** @hidden */
  50448. export var noisePixelShader: {
  50449. name: string;
  50450. shader: string;
  50451. };
  50452. }
  50453. declare module BABYLON {
  50454. /**
  50455. * Class used to generate noise procedural textures
  50456. */
  50457. export class NoiseProceduralTexture extends ProceduralTexture {
  50458. private _time;
  50459. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50460. brightness: number;
  50461. /** Defines the number of octaves to process */
  50462. octaves: number;
  50463. /** Defines the level of persistence (0.8 by default) */
  50464. persistence: number;
  50465. /** Gets or sets animation speed factor (default is 1) */
  50466. animationSpeedFactor: number;
  50467. /**
  50468. * Creates a new NoiseProceduralTexture
  50469. * @param name defines the name fo the texture
  50470. * @param size defines the size of the texture (default is 256)
  50471. * @param scene defines the hosting scene
  50472. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50473. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50474. */
  50475. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50476. private _updateShaderUniforms;
  50477. protected _getDefines(): string;
  50478. /** Generate the current state of the procedural texture */
  50479. render(useCameraPostProcess?: boolean): void;
  50480. /**
  50481. * Serializes this noise procedural texture
  50482. * @returns a serialized noise procedural texture object
  50483. */
  50484. serialize(): any;
  50485. /**
  50486. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50487. * @param parsedTexture defines parsed texture data
  50488. * @param scene defines the current scene
  50489. * @param rootUrl defines the root URL containing noise procedural texture information
  50490. * @returns a parsed NoiseProceduralTexture
  50491. */
  50492. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50493. }
  50494. }
  50495. declare module BABYLON {
  50496. /**
  50497. * Raw cube texture where the raw buffers are passed in
  50498. */
  50499. export class RawCubeTexture extends CubeTexture {
  50500. /**
  50501. * Creates a cube texture where the raw buffers are passed in.
  50502. * @param scene defines the scene the texture is attached to
  50503. * @param data defines the array of data to use to create each face
  50504. * @param size defines the size of the textures
  50505. * @param format defines the format of the data
  50506. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50507. * @param generateMipMaps defines if the engine should generate the mip levels
  50508. * @param invertY defines if data must be stored with Y axis inverted
  50509. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50510. * @param compression defines the compression used (null by default)
  50511. */
  50512. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50513. /**
  50514. * Updates the raw cube texture.
  50515. * @param data defines the data to store
  50516. * @param format defines the data format
  50517. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50518. * @param invertY defines if data must be stored with Y axis inverted
  50519. * @param compression defines the compression used (null by default)
  50520. * @param level defines which level of the texture to update
  50521. */
  50522. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50523. /**
  50524. * Updates a raw cube texture with RGBD encoded data.
  50525. * @param data defines the array of data [mipmap][face] to use to create each face
  50526. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50529. * @returns a promsie that resolves when the operation is complete
  50530. */
  50531. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50532. /**
  50533. * Clones the raw cube texture.
  50534. * @return a new cube texture
  50535. */
  50536. clone(): CubeTexture;
  50537. /** @hidden */
  50538. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50539. }
  50540. }
  50541. declare module BABYLON {
  50542. /**
  50543. * Class used to store 3D textures containing user data
  50544. */
  50545. export class RawTexture3D extends Texture {
  50546. /** Gets or sets the texture format to use */
  50547. format: number;
  50548. private _engine;
  50549. /**
  50550. * Create a new RawTexture3D
  50551. * @param data defines the data of the texture
  50552. * @param width defines the width of the texture
  50553. * @param height defines the height of the texture
  50554. * @param depth defines the depth of the texture
  50555. * @param format defines the texture format to use
  50556. * @param scene defines the hosting scene
  50557. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50558. * @param invertY defines if texture must be stored with Y axis inverted
  50559. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50560. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50561. */
  50562. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50563. /** Gets or sets the texture format to use */
  50564. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50565. /**
  50566. * Update the texture with new data
  50567. * @param data defines the data to store in the texture
  50568. */
  50569. update(data: ArrayBufferView): void;
  50570. }
  50571. }
  50572. declare module BABYLON {
  50573. /**
  50574. * Creates a refraction texture used by refraction channel of the standard material.
  50575. * It is like a mirror but to see through a material.
  50576. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50577. */
  50578. export class RefractionTexture extends RenderTargetTexture {
  50579. /**
  50580. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50581. * 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.
  50582. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50583. */
  50584. refractionPlane: Plane;
  50585. /**
  50586. * Define how deep under the surface we should see.
  50587. */
  50588. depth: number;
  50589. /**
  50590. * Creates a refraction texture used by refraction channel of the standard material.
  50591. * It is like a mirror but to see through a material.
  50592. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50593. * @param name Define the texture name
  50594. * @param size Define the size of the underlying texture
  50595. * @param scene Define the scene the refraction belongs to
  50596. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50597. */
  50598. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50599. /**
  50600. * Clone the refraction texture.
  50601. * @returns the cloned texture
  50602. */
  50603. clone(): RefractionTexture;
  50604. /**
  50605. * Serialize the texture to a JSON representation you could use in Parse later on
  50606. * @returns the serialized JSON representation
  50607. */
  50608. serialize(): any;
  50609. }
  50610. }
  50611. declare module BABYLON {
  50612. /**
  50613. * Defines the options related to the creation of an HtmlElementTexture
  50614. */
  50615. export interface IHtmlElementTextureOptions {
  50616. /**
  50617. * Defines wether mip maps should be created or not.
  50618. */
  50619. generateMipMaps?: boolean;
  50620. /**
  50621. * Defines the sampling mode of the texture.
  50622. */
  50623. samplingMode?: number;
  50624. /**
  50625. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50626. */
  50627. engine: Nullable<Engine>;
  50628. /**
  50629. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50630. */
  50631. scene: Nullable<Scene>;
  50632. }
  50633. /**
  50634. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50635. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50636. * is automatically managed.
  50637. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50638. * in your application.
  50639. *
  50640. * As the update is not automatic, you need to call them manually.
  50641. */
  50642. export class HtmlElementTexture extends BaseTexture {
  50643. /**
  50644. * The texture URL.
  50645. */
  50646. element: HTMLVideoElement | HTMLCanvasElement;
  50647. private static readonly DefaultOptions;
  50648. private _textureMatrix;
  50649. private _engine;
  50650. private _isVideo;
  50651. private _generateMipMaps;
  50652. private _samplingMode;
  50653. /**
  50654. * Instantiates a HtmlElementTexture from the following parameters.
  50655. *
  50656. * @param name Defines the name of the texture
  50657. * @param element Defines the video or canvas the texture is filled with
  50658. * @param options Defines the other none mandatory texture creation options
  50659. */
  50660. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50661. private _createInternalTexture;
  50662. /**
  50663. * Returns the texture matrix used in most of the material.
  50664. */
  50665. getTextureMatrix(): Matrix;
  50666. /**
  50667. * Updates the content of the texture.
  50668. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50669. */
  50670. update(invertY?: Nullable<boolean>): void;
  50671. }
  50672. }
  50673. declare module BABYLON {
  50674. /**
  50675. * Enum used to define the target of a block
  50676. */
  50677. export enum NodeMaterialBlockTargets {
  50678. /** Vertex shader */
  50679. Vertex = 1,
  50680. /** Fragment shader */
  50681. Fragment = 2,
  50682. /** Vertex and Fragment */
  50683. VertexAndFragment = 3
  50684. }
  50685. }
  50686. declare module BABYLON {
  50687. /**
  50688. * Defines the kind of connection point for node based material
  50689. */
  50690. export enum NodeMaterialBlockConnectionPointTypes {
  50691. /** Float */
  50692. Float = 1,
  50693. /** Int */
  50694. Int = 2,
  50695. /** Vector2 */
  50696. Vector2 = 4,
  50697. /** Vector3 */
  50698. Vector3 = 8,
  50699. /** Vector4 */
  50700. Vector4 = 16,
  50701. /** Color3 */
  50702. Color3 = 32,
  50703. /** Color4 */
  50704. Color4 = 64,
  50705. /** Matrix */
  50706. Matrix = 128,
  50707. /** Texture */
  50708. Texture = 256,
  50709. /** Texture3D */
  50710. Texture3D = 512,
  50711. /** Vector3 or Color3 */
  50712. Vector3OrColor3 = 40,
  50713. /** Vector3 or Vector4 */
  50714. Vector3OrVector4 = 24,
  50715. /** Vector4 or Color4 */
  50716. Vector4OrColor4 = 80,
  50717. /** Color3 or Color4 */
  50718. Color3OrColor4 = 96,
  50719. /** Vector3 or Color3 */
  50720. Vector3OrColor3OrVector4OrColor4 = 120,
  50721. /** Detect type based on connection */
  50722. AutoDetect = 1024,
  50723. /** Output type that will be defined by input type */
  50724. BasedOnInput = 2048,
  50725. /** Light */
  50726. Light = 4096
  50727. }
  50728. }
  50729. declare module BABYLON {
  50730. /**
  50731. * Enum used to define well known values e.g. values automatically provided by the system
  50732. */
  50733. export enum NodeMaterialWellKnownValues {
  50734. /** World */
  50735. World = 1,
  50736. /** View */
  50737. View = 2,
  50738. /** Projection */
  50739. Projection = 3,
  50740. /** ViewProjection */
  50741. ViewProjection = 4,
  50742. /** WorldView */
  50743. WorldView = 5,
  50744. /** WorldViewProjection */
  50745. WorldViewProjection = 6,
  50746. /** CameraPosition */
  50747. CameraPosition = 7,
  50748. /** Will be filled by the block itself */
  50749. Automatic = 8
  50750. }
  50751. }
  50752. declare module BABYLON {
  50753. /**
  50754. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50755. */
  50756. export enum NodeMaterialBlockConnectionPointMode {
  50757. /** Value is an uniform */
  50758. Uniform = 0,
  50759. /** Value is a mesh attribute */
  50760. Attribute = 1,
  50761. /** Value is a varying between vertex and fragment shaders */
  50762. Varying = 2,
  50763. /** Mode is undefined */
  50764. Undefined = 3
  50765. }
  50766. }
  50767. declare module BABYLON {
  50768. /**
  50769. * Class used to store shared data between 2 NodeMaterialBuildState
  50770. */
  50771. export class NodeMaterialBuildStateSharedData {
  50772. /**
  50773. * Gets the list of emitted varyings
  50774. */
  50775. varyings: string[];
  50776. /**
  50777. * Gets the varying declaration string
  50778. */
  50779. varyingDeclaration: string;
  50780. /**
  50781. * Uniform connection points
  50782. */
  50783. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50784. /**
  50785. * Bindable blocks (Blocks that need to set data to the effect)
  50786. */
  50787. bindableBlocks: NodeMaterialBlock[];
  50788. /**
  50789. * List of blocks that can provide a compilation fallback
  50790. */
  50791. blocksWithFallbacks: NodeMaterialBlock[];
  50792. /**
  50793. * List of blocks that can provide a define update
  50794. */
  50795. blocksWithDefines: NodeMaterialBlock[];
  50796. /**
  50797. * List of blocks that can provide a repeatable content
  50798. */
  50799. repeatableContentBlocks: NodeMaterialBlock[];
  50800. /**
  50801. * List of blocks that can block the isReady function for the material
  50802. */
  50803. blockingBlocks: NodeMaterialBlock[];
  50804. /**
  50805. * Build Id used to avoid multiple recompilations
  50806. */
  50807. buildId: number;
  50808. /** List of emitted variables */
  50809. variableNames: {
  50810. [key: string]: number;
  50811. };
  50812. /** List of emitted defines */
  50813. defineNames: {
  50814. [key: string]: number;
  50815. };
  50816. /** Should emit comments? */
  50817. emitComments: boolean;
  50818. /** Emit build activity */
  50819. verbose: boolean;
  50820. /**
  50821. * Gets the compilation hints emitted at compilation time
  50822. */
  50823. hints: {
  50824. needWorldViewMatrix: boolean;
  50825. needWorldViewProjectionMatrix: boolean;
  50826. needAlphaBlending: boolean;
  50827. needAlphaTesting: boolean;
  50828. };
  50829. /**
  50830. * List of compilation checks
  50831. */
  50832. checks: {
  50833. emitVertex: boolean;
  50834. emitFragment: boolean;
  50835. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50836. };
  50837. /** Creates a new shared data */
  50838. constructor();
  50839. /**
  50840. * Emits console errors and exceptions if there is a failing check
  50841. */
  50842. emitErrors(): void;
  50843. }
  50844. }
  50845. declare module BABYLON {
  50846. /**
  50847. * Class used to store node based material build state
  50848. */
  50849. export class NodeMaterialBuildState {
  50850. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50851. supportUniformBuffers: boolean;
  50852. /**
  50853. * Gets the list of emitted attributes
  50854. */
  50855. attributes: string[];
  50856. /**
  50857. * Gets the list of emitted uniforms
  50858. */
  50859. uniforms: string[];
  50860. /**
  50861. * Gets the list of emitted uniform buffers
  50862. */
  50863. uniformBuffers: string[];
  50864. /**
  50865. * Gets the list of emitted samplers
  50866. */
  50867. samplers: string[];
  50868. /**
  50869. * Gets the list of emitted functions
  50870. */
  50871. functions: {
  50872. [key: string]: string;
  50873. };
  50874. /**
  50875. * Gets the target of the compilation state
  50876. */
  50877. target: NodeMaterialBlockTargets;
  50878. /**
  50879. * Gets the list of emitted counters
  50880. */
  50881. counters: {
  50882. [key: string]: number;
  50883. };
  50884. /**
  50885. * Shared data between multiple NodeMaterialBuildState instances
  50886. */
  50887. sharedData: NodeMaterialBuildStateSharedData;
  50888. /** @hidden */
  50889. _vertexState: NodeMaterialBuildState;
  50890. private _attributeDeclaration;
  50891. private _uniformDeclaration;
  50892. private _samplerDeclaration;
  50893. private _varyingTransfer;
  50894. private _repeatableContentAnchorIndex;
  50895. /** @hidden */
  50896. _builtCompilationString: string;
  50897. /**
  50898. * Gets the emitted compilation strings
  50899. */
  50900. compilationString: string;
  50901. /**
  50902. * Finalize the compilation strings
  50903. * @param state defines the current compilation state
  50904. */
  50905. finalize(state: NodeMaterialBuildState): void;
  50906. /** @hidden */
  50907. readonly _repeatableContentAnchor: string;
  50908. /** @hidden */
  50909. _getFreeVariableName(prefix: string): string;
  50910. /** @hidden */
  50911. _getFreeDefineName(prefix: string): string;
  50912. /** @hidden */
  50913. _excludeVariableName(name: string): void;
  50914. /** @hidden */
  50915. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50916. /** @hidden */
  50917. _emitFunction(name: string, code: string, comments: string): void;
  50918. /** @hidden */
  50919. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50920. replaceStrings?: {
  50921. search: RegExp;
  50922. replace: string;
  50923. }[];
  50924. }): string;
  50925. /** @hidden */
  50926. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50927. repeatKey?: string;
  50928. removeAttributes?: boolean;
  50929. removeUniforms?: boolean;
  50930. removeVaryings?: boolean;
  50931. removeIfDef?: boolean;
  50932. replaceStrings?: {
  50933. search: RegExp;
  50934. replace: string;
  50935. }[];
  50936. }, storeKey?: string): void;
  50937. /** @hidden */
  50938. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50939. private _emitDefine;
  50940. /** @hidden */
  50941. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50942. }
  50943. }
  50944. declare module BABYLON {
  50945. /**
  50946. * Root class for all node material optimizers
  50947. */
  50948. export class NodeMaterialOptimizer {
  50949. /**
  50950. * Function used to optimize a NodeMaterial graph
  50951. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50952. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50953. */
  50954. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50955. }
  50956. }
  50957. declare module BABYLON {
  50958. /**
  50959. * Block used to transform a vector4 with a matrix
  50960. */
  50961. export class Vector4TransformBlock extends NodeMaterialBlock {
  50962. /**
  50963. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50964. */
  50965. complementW: number;
  50966. /**
  50967. * Creates a new Vector4TransformBlock
  50968. * @param name defines the block name
  50969. */
  50970. constructor(name: string);
  50971. /**
  50972. * Gets the current class name
  50973. * @returns the class name
  50974. */
  50975. getClassName(): string;
  50976. /**
  50977. * Gets the vector input
  50978. */
  50979. readonly vector: NodeMaterialConnectionPoint;
  50980. /**
  50981. * Gets the output component
  50982. */
  50983. readonly output: NodeMaterialConnectionPoint;
  50984. /**
  50985. * Gets the matrix transform input
  50986. */
  50987. readonly transform: NodeMaterialConnectionPoint;
  50988. protected _buildBlock(state: NodeMaterialBuildState): this;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * Block used to output the vertex position
  50994. */
  50995. export class VertexOutputBlock extends NodeMaterialBlock {
  50996. /**
  50997. * Creates a new VertexOutputBlock
  50998. * @param name defines the block name
  50999. */
  51000. constructor(name: string);
  51001. /**
  51002. * Gets the current class name
  51003. * @returns the class name
  51004. */
  51005. getClassName(): string;
  51006. /**
  51007. * Gets the vector input component
  51008. */
  51009. readonly vector: NodeMaterialConnectionPoint;
  51010. protected _buildBlock(state: NodeMaterialBuildState): this;
  51011. }
  51012. }
  51013. declare module BABYLON {
  51014. /**
  51015. * Block used to output the final color
  51016. */
  51017. export class FragmentOutputBlock extends NodeMaterialBlock {
  51018. /**
  51019. * Gets or sets a boolean indicating if this block will output an alpha value
  51020. */
  51021. alphaBlendingEnabled: boolean;
  51022. /**
  51023. * Create a new FragmentOutputBlock
  51024. * @param name defines the block name
  51025. */
  51026. constructor(name: string);
  51027. /**
  51028. * Gets the current class name
  51029. * @returns the class name
  51030. */
  51031. getClassName(): string;
  51032. /**
  51033. * Gets the color input component
  51034. */
  51035. readonly color: NodeMaterialConnectionPoint;
  51036. protected _buildBlock(state: NodeMaterialBuildState): this;
  51037. }
  51038. }
  51039. declare module BABYLON {
  51040. /**
  51041. * Interface used to configure the node material editor
  51042. */
  51043. export interface INodeMaterialEditorOptions {
  51044. /** Define the URl to load node editor script */
  51045. editorURL?: string;
  51046. }
  51047. /** @hidden */
  51048. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51049. /** BONES */
  51050. NUM_BONE_INFLUENCERS: number;
  51051. BonesPerMesh: number;
  51052. BONETEXTURE: boolean;
  51053. /** MORPH TARGETS */
  51054. MORPHTARGETS: boolean;
  51055. MORPHTARGETS_NORMAL: boolean;
  51056. MORPHTARGETS_TANGENT: boolean;
  51057. MORPHTARGETS_UV: boolean;
  51058. NUM_MORPH_INFLUENCERS: number;
  51059. /** IMAGE PROCESSING */
  51060. IMAGEPROCESSING: boolean;
  51061. VIGNETTE: boolean;
  51062. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51063. VIGNETTEBLENDMODEOPAQUE: boolean;
  51064. TONEMAPPING: boolean;
  51065. TONEMAPPING_ACES: boolean;
  51066. CONTRAST: boolean;
  51067. EXPOSURE: boolean;
  51068. COLORCURVES: boolean;
  51069. COLORGRADING: boolean;
  51070. COLORGRADING3D: boolean;
  51071. SAMPLER3DGREENDEPTH: boolean;
  51072. SAMPLER3DBGRMAP: boolean;
  51073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51074. constructor();
  51075. setValue(name: string, value: boolean): void;
  51076. }
  51077. /**
  51078. * Class used to configure NodeMaterial
  51079. */
  51080. export interface INodeMaterialOptions {
  51081. /**
  51082. * Defines if blocks should emit comments
  51083. */
  51084. emitComments: boolean;
  51085. }
  51086. /**
  51087. * Class used to create a node based material built by assembling shader blocks
  51088. */
  51089. export class NodeMaterial extends PushMaterial {
  51090. private _options;
  51091. private _vertexCompilationState;
  51092. private _fragmentCompilationState;
  51093. private _sharedData;
  51094. private _buildId;
  51095. private _buildWasSuccessful;
  51096. private _cachedWorldViewMatrix;
  51097. private _cachedWorldViewProjectionMatrix;
  51098. private _textureConnectionPoints;
  51099. private _optimizers;
  51100. /** Define the URl to load node editor script */
  51101. static EditorURL: string;
  51102. private BJSNODEMATERIALEDITOR;
  51103. /** Get the inspector from bundle or global */
  51104. private _getGlobalNodeMaterialEditor;
  51105. /**
  51106. * Defines the maximum number of lights that can be used in the material
  51107. */
  51108. maxSimultaneousLights: number;
  51109. /**
  51110. * Observable raised when the material is built
  51111. */
  51112. onBuildObservable: Observable<NodeMaterial>;
  51113. /**
  51114. * Gets or sets the root nodes of the material vertex shader
  51115. */
  51116. _vertexOutputNodes: NodeMaterialBlock[];
  51117. /**
  51118. * Gets or sets the root nodes of the material fragment (pixel) shader
  51119. */
  51120. _fragmentOutputNodes: NodeMaterialBlock[];
  51121. /** Gets or sets options to control the node material overall behavior */
  51122. options: INodeMaterialOptions;
  51123. /**
  51124. * Default configuration related to image processing available in the standard Material.
  51125. */
  51126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51127. /**
  51128. * Gets the image processing configuration used either in this material.
  51129. */
  51130. /**
  51131. * Sets the Default image processing configuration used either in the this material.
  51132. *
  51133. * If sets to null, the scene one is in use.
  51134. */
  51135. imageProcessingConfiguration: ImageProcessingConfiguration;
  51136. /**
  51137. * Create a new node based material
  51138. * @param name defines the material name
  51139. * @param scene defines the hosting scene
  51140. * @param options defines creation option
  51141. */
  51142. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51143. /**
  51144. * Gets the current class name of the material e.g. "NodeMaterial"
  51145. * @returns the class name
  51146. */
  51147. getClassName(): string;
  51148. /**
  51149. * Keep track of the image processing observer to allow dispose and replace.
  51150. */
  51151. private _imageProcessingObserver;
  51152. /**
  51153. * Attaches a new image processing configuration to the Standard Material.
  51154. * @param configuration
  51155. */
  51156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51157. /**
  51158. * Adds a new optimizer to the list of optimizers
  51159. * @param optimizer defines the optimizers to add
  51160. * @returns the current material
  51161. */
  51162. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51163. /**
  51164. * Remove an optimizer from the list of optimizers
  51165. * @param optimizer defines the optimizers to remove
  51166. * @returns the current material
  51167. */
  51168. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51169. /**
  51170. * Add a new block to the list of output nodes
  51171. * @param node defines the node to add
  51172. * @returns the current material
  51173. */
  51174. addOutputNode(node: NodeMaterialBlock): this;
  51175. /**
  51176. * Remove a block from the list of root nodes
  51177. * @param node defines the node to remove
  51178. * @returns the current material
  51179. */
  51180. removeOutputNode(node: NodeMaterialBlock): this;
  51181. private _addVertexOutputNode;
  51182. private _removeVertexOutputNode;
  51183. private _addFragmentOutputNode;
  51184. private _removeFragmentOutputNode;
  51185. /**
  51186. * Specifies if the material will require alpha blending
  51187. * @returns a boolean specifying if alpha blending is needed
  51188. */
  51189. needAlphaBlending(): boolean;
  51190. /**
  51191. * Specifies if this material should be rendered in alpha test mode
  51192. * @returns a boolean specifying if an alpha test is needed.
  51193. */
  51194. needAlphaTesting(): boolean;
  51195. private _initializeBlock;
  51196. private _resetDualBlocks;
  51197. /**
  51198. * Build the material and generates the inner effect
  51199. * @param verbose defines if the build should log activity
  51200. */
  51201. build(verbose?: boolean): void;
  51202. /**
  51203. * Runs an otpimization phase to try to improve the shader code
  51204. */
  51205. optimize(): void;
  51206. private _prepareDefinesForAttributes;
  51207. /**
  51208. * Get if the submesh is ready to be used and all its information available.
  51209. * Child classes can use it to update shaders
  51210. * @param mesh defines the mesh to check
  51211. * @param subMesh defines which submesh to check
  51212. * @param useInstances specifies that instances should be used
  51213. * @returns a boolean indicating that the submesh is ready or not
  51214. */
  51215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51216. /**
  51217. * Binds the world matrix to the material
  51218. * @param world defines the world transformation matrix
  51219. */
  51220. bindOnlyWorldMatrix(world: Matrix): void;
  51221. /**
  51222. * Binds the submesh to this material by preparing the effect and shader to draw
  51223. * @param world defines the world transformation matrix
  51224. * @param mesh defines the mesh containing the submesh
  51225. * @param subMesh defines the submesh to bind the material to
  51226. */
  51227. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51228. /**
  51229. * Gets the active textures from the material
  51230. * @returns an array of textures
  51231. */
  51232. getActiveTextures(): BaseTexture[];
  51233. /**
  51234. * Specifies if the material uses a texture
  51235. * @param texture defines the texture to check against the material
  51236. * @returns a boolean specifying if the material uses the texture
  51237. */
  51238. hasTexture(texture: BaseTexture): boolean;
  51239. /**
  51240. * Disposes the material
  51241. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51242. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51243. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51244. */
  51245. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51246. /** Creates the node editor window. */
  51247. private _createNodeEditor;
  51248. /**
  51249. * Launch the node material editor
  51250. * @param config Define the configuration of the editor
  51251. * @return a promise fulfilled when the node editor is visible
  51252. */
  51253. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51254. /**
  51255. * Clear the current material
  51256. */
  51257. clear(): void;
  51258. /**
  51259. * Clear the current material and set it to a default state
  51260. */
  51261. setToDefault(): void;
  51262. }
  51263. }
  51264. declare module BABYLON {
  51265. /**
  51266. * Defines a block that can be used inside a node based material
  51267. */
  51268. export class NodeMaterialBlock {
  51269. private _buildId;
  51270. private _target;
  51271. private _isFinalMerger;
  51272. /** @hidden */
  51273. _inputs: NodeMaterialConnectionPoint[];
  51274. /** @hidden */
  51275. _outputs: NodeMaterialConnectionPoint[];
  51276. /**
  51277. * Gets or sets the name of the block
  51278. */
  51279. name: string;
  51280. /**
  51281. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51282. */
  51283. readonly isFinalMerger: boolean;
  51284. /**
  51285. * Gets or sets the build Id
  51286. */
  51287. buildId: number;
  51288. /**
  51289. * Gets or sets the target of the block
  51290. */
  51291. target: NodeMaterialBlockTargets;
  51292. /**
  51293. * Gets the list of input points
  51294. */
  51295. readonly inputs: NodeMaterialConnectionPoint[];
  51296. /** Gets the list of output points */
  51297. readonly outputs: NodeMaterialConnectionPoint[];
  51298. /**
  51299. * Find an input by its name
  51300. * @param name defines the name of the input to look for
  51301. * @returns the input or null if not found
  51302. */
  51303. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51304. /**
  51305. * Find an output by its name
  51306. * @param name defines the name of the outputto look for
  51307. * @returns the output or null if not found
  51308. */
  51309. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51310. /**
  51311. * Creates a new NodeMaterialBlock
  51312. * @param name defines the block name
  51313. * @param target defines the target of that block (Vertex by default)
  51314. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51315. */
  51316. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51317. /**
  51318. * Initialize the block and prepare the context for build
  51319. * @param state defines the state that will be used for the build
  51320. */
  51321. initialize(state: NodeMaterialBuildState): void;
  51322. /**
  51323. * Bind data to effect. Will only be called for blocks with isBindable === true
  51324. * @param effect defines the effect to bind data to
  51325. * @param nodeMaterial defines the hosting NodeMaterial
  51326. * @param mesh defines the mesh that will be rendered
  51327. */
  51328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51329. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51330. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51331. protected _writeFloat(value: number): string;
  51332. /**
  51333. * Gets the current class name e.g. "NodeMaterialBlock"
  51334. * @returns the class name
  51335. */
  51336. getClassName(): string;
  51337. /**
  51338. * Register a new input. Must be called inside a block constructor
  51339. * @param name defines the connection point name
  51340. * @param type defines the connection point type
  51341. * @param isOptional defines a boolean indicating that this input can be omitted
  51342. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51343. * @returns the current block
  51344. */
  51345. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51346. /**
  51347. * Register a new output. Must be called inside a block constructor
  51348. * @param name defines the connection point name
  51349. * @param type defines the connection point type
  51350. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51351. * @returns the current block
  51352. */
  51353. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51354. /**
  51355. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51356. * @param forOutput defines an optional connection point to check compatibility with
  51357. * @returns the first available input or null
  51358. */
  51359. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51360. /**
  51361. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51362. * @param forBlock defines an optional block to check compatibility with
  51363. * @returns the first available input or null
  51364. */
  51365. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51366. /**
  51367. * Connect current block with another block
  51368. * @param other defines the block to connect with
  51369. * @param options define the various options to help pick the right connections
  51370. * @returns the current block
  51371. */
  51372. connectTo(other: NodeMaterialBlock, options?: {
  51373. input?: string;
  51374. output?: string;
  51375. outputSwizzle?: string;
  51376. }): this | undefined;
  51377. protected _buildBlock(state: NodeMaterialBuildState): void;
  51378. /**
  51379. * Add potential fallbacks if shader compilation fails
  51380. * @param mesh defines the mesh to be rendered
  51381. * @param fallbacks defines the current prioritized list of fallbacks
  51382. */
  51383. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51384. /**
  51385. * Update defines for shader compilation
  51386. * @param mesh defines the mesh to be rendered
  51387. * @param nodeMaterial defines the node material requesting the update
  51388. * @param defines defines the material defines to update
  51389. * @param useInstances specifies that instances should be used
  51390. */
  51391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51392. /**
  51393. * Lets the block try to connect some inputs automatically
  51394. */
  51395. autoConfigure(): void;
  51396. /**
  51397. * Function called when a block is declared as repeatable content generator
  51398. * @param vertexShaderState defines the current compilation state for the vertex shader
  51399. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51400. * @param mesh defines the mesh to be rendered
  51401. * @param defines defines the material defines to update
  51402. */
  51403. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51404. /**
  51405. * Checks if the block is ready
  51406. * @param mesh defines the mesh to be rendered
  51407. * @param nodeMaterial defines the node material requesting the update
  51408. * @param defines defines the material defines to update
  51409. * @param useInstances specifies that instances should be used
  51410. * @returns true if the block is ready
  51411. */
  51412. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51413. /**
  51414. * Compile the current node and generate the shader code
  51415. * @param state defines the current compilation state (uniforms, samplers, current string)
  51416. * @returns the current block
  51417. */
  51418. build(state: NodeMaterialBuildState): this | undefined;
  51419. }
  51420. }
  51421. declare module BABYLON {
  51422. /**
  51423. * Defines a connection point for a block
  51424. */
  51425. export class NodeMaterialConnectionPoint {
  51426. /** @hidden */
  51427. _ownerBlock: NodeMaterialBlock;
  51428. /** @hidden */
  51429. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51430. private _associatedVariableName;
  51431. private _endpoints;
  51432. private _storedValue;
  51433. private _valueCallback;
  51434. private _mode;
  51435. /** @hidden */
  51436. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51437. /** @hidden */
  51438. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51439. /** @hidden */
  51440. _needToEmitVarying: boolean;
  51441. /** @hidden */
  51442. _forceUniformInVertexShaderOnly: boolean;
  51443. private _type;
  51444. /**
  51445. * Gets or sets the connection point type (default is float)
  51446. */
  51447. type: NodeMaterialBlockConnectionPointTypes;
  51448. /**
  51449. * Gets or sets the connection point name
  51450. */
  51451. name: string;
  51452. /**
  51453. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51454. */
  51455. swizzle: string;
  51456. /**
  51457. * Gets or sets a boolean indicating that this connection point can be omitted
  51458. */
  51459. isOptional: boolean;
  51460. /**
  51461. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51462. */
  51463. define: string;
  51464. /** Gets or sets the target of that connection point */
  51465. target: NodeMaterialBlockTargets;
  51466. /**
  51467. * Gets or sets the value of that point.
  51468. * Please note that this value will be ignored if valueCallback is defined
  51469. */
  51470. value: any;
  51471. /**
  51472. * Gets or sets a callback used to get the value of that point.
  51473. * Please note that setting this value will force the connection point to ignore the value property
  51474. */
  51475. valueCallback: () => any;
  51476. /**
  51477. * Gets or sets the associated variable name in the shader
  51478. */
  51479. associatedVariableName: string;
  51480. /**
  51481. * Gets a boolean indicating that this connection point not defined yet
  51482. */
  51483. readonly isUndefined: boolean;
  51484. /**
  51485. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51486. * In this case the connection point name must be the name of the uniform to use.
  51487. * Can only be set on inputs
  51488. */
  51489. isUniform: boolean;
  51490. /**
  51491. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51492. * In this case the connection point name must be the name of the attribute to use
  51493. * Can only be set on inputs
  51494. */
  51495. isAttribute: boolean;
  51496. /**
  51497. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51498. * Can only be set on exit points
  51499. */
  51500. isVarying: boolean;
  51501. /** Get the other side of the connection (if any) */
  51502. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51503. /** Get the block that owns this connection point */
  51504. readonly ownerBlock: NodeMaterialBlock;
  51505. /** Get the block connected on the other side of this connection (if any) */
  51506. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51507. /** Get the block connected on the endpoints of this connection (if any) */
  51508. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51509. /**
  51510. * Creates a new connection point
  51511. * @param name defines the connection point name
  51512. * @param ownerBlock defines the block hosting this connection point
  51513. */
  51514. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51515. /**
  51516. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51517. * @returns the class name
  51518. */
  51519. getClassName(): string;
  51520. /**
  51521. * Set the source of this connection point to a vertex attribute
  51522. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51523. * @returns the current connection point
  51524. */
  51525. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51526. /**
  51527. * Set the source of this connection point to a well known value
  51528. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51529. * @returns the current connection point
  51530. */
  51531. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51532. /**
  51533. * Gets a boolean indicating that the current connection point is a well known value
  51534. */
  51535. readonly isWellKnownValue: boolean;
  51536. /**
  51537. * Gets or sets the current well known value or null if not defined as well know value
  51538. */
  51539. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51540. private _getTypeLength;
  51541. /**
  51542. * Connect this point to another connection point
  51543. * @param connectionPoint defines the other connection point
  51544. * @returns the current connection point
  51545. */
  51546. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51547. /**
  51548. * Disconnect this point from one of his endpoint
  51549. * @param endpoint defines the other connection point
  51550. * @returns the current connection point
  51551. */
  51552. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51553. /**
  51554. * When connection point is an uniform, this function will send its value to the effect
  51555. * @param effect defines the effect to transmit value to
  51556. * @param world defines the world matrix
  51557. * @param worldView defines the worldxview matrix
  51558. * @param worldViewProjection defines the worldxviewxprojection matrix
  51559. */
  51560. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51561. /**
  51562. * When connection point is an uniform, this function will send its value to the effect
  51563. * @param effect defines the effect to transmit value to
  51564. * @param scene defines the hosting scene
  51565. */
  51566. transmit(effect: Effect, scene: Scene): void;
  51567. }
  51568. }
  51569. declare module BABYLON {
  51570. /**
  51571. * Block used to add support for vertex skinning (bones)
  51572. */
  51573. export class BonesBlock extends NodeMaterialBlock {
  51574. /**
  51575. * Creates a new BonesBlock
  51576. * @param name defines the block name
  51577. */
  51578. constructor(name: string);
  51579. /**
  51580. * Initialize the block and prepare the context for build
  51581. * @param state defines the state that will be used for the build
  51582. */
  51583. initialize(state: NodeMaterialBuildState): void;
  51584. /**
  51585. * Gets the current class name
  51586. * @returns the class name
  51587. */
  51588. getClassName(): string;
  51589. /**
  51590. * Gets the matrix indices input component
  51591. */
  51592. readonly matricesIndices: NodeMaterialConnectionPoint;
  51593. /**
  51594. * Gets the matrix weights input component
  51595. */
  51596. readonly matricesWeights: NodeMaterialConnectionPoint;
  51597. /**
  51598. * Gets the extra matrix indices input component
  51599. */
  51600. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51601. /**
  51602. * Gets the extra matrix weights input component
  51603. */
  51604. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51605. /**
  51606. * Gets the world input component
  51607. */
  51608. readonly world: NodeMaterialConnectionPoint;
  51609. /**
  51610. * Gets the output component
  51611. */
  51612. readonly output: NodeMaterialConnectionPoint;
  51613. autoConfigure(): void;
  51614. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51615. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51617. protected _buildBlock(state: NodeMaterialBuildState): this;
  51618. }
  51619. }
  51620. declare module BABYLON {
  51621. /**
  51622. * Block used to add support for instances
  51623. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51624. */
  51625. export class InstancesBlock extends NodeMaterialBlock {
  51626. /**
  51627. * Creates a new InstancesBlock
  51628. * @param name defines the block name
  51629. */
  51630. constructor(name: string);
  51631. /**
  51632. * Gets the current class name
  51633. * @returns the class name
  51634. */
  51635. getClassName(): string;
  51636. /**
  51637. * Gets the first world row input component
  51638. */
  51639. readonly world0: NodeMaterialConnectionPoint;
  51640. /**
  51641. * Gets the second world row input component
  51642. */
  51643. readonly world1: NodeMaterialConnectionPoint;
  51644. /**
  51645. * Gets the third world row input component
  51646. */
  51647. readonly world2: NodeMaterialConnectionPoint;
  51648. /**
  51649. * Gets the forth world row input component
  51650. */
  51651. readonly world3: NodeMaterialConnectionPoint;
  51652. /**
  51653. * Gets the world input component
  51654. */
  51655. readonly world: NodeMaterialConnectionPoint;
  51656. /**
  51657. * Gets the output component
  51658. */
  51659. readonly output: NodeMaterialConnectionPoint;
  51660. autoConfigure(): void;
  51661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51662. protected _buildBlock(state: NodeMaterialBuildState): this;
  51663. }
  51664. }
  51665. declare module BABYLON {
  51666. /**
  51667. * Block used to add morph targets support to vertex shader
  51668. */
  51669. export class MorphTargetsBlock extends NodeMaterialBlock {
  51670. private _repeatableContentAnchor;
  51671. private _repeatebleContentGenerated;
  51672. /**
  51673. * Create a new MorphTargetsBlock
  51674. * @param name defines the block name
  51675. */
  51676. constructor(name: string);
  51677. /**
  51678. * Gets the current class name
  51679. * @returns the class name
  51680. */
  51681. getClassName(): string;
  51682. /**
  51683. * Gets the position input component
  51684. */
  51685. readonly position: NodeMaterialConnectionPoint;
  51686. /**
  51687. * Gets the normal input component
  51688. */
  51689. readonly normal: NodeMaterialConnectionPoint;
  51690. /**
  51691. * Gets the tangent input component
  51692. */
  51693. readonly tangent: NodeMaterialConnectionPoint;
  51694. /**
  51695. * Gets the tangent input component
  51696. */
  51697. readonly uv: NodeMaterialConnectionPoint;
  51698. /**
  51699. * Gets the position output component
  51700. */
  51701. readonly positionOutput: NodeMaterialConnectionPoint;
  51702. /**
  51703. * Gets the normal output component
  51704. */
  51705. readonly normalOutput: NodeMaterialConnectionPoint;
  51706. /**
  51707. * Gets the tangent output component
  51708. */
  51709. readonly tangentOutput: NodeMaterialConnectionPoint;
  51710. /**
  51711. * Gets the tangent output component
  51712. */
  51713. readonly uvOutput: NodeMaterialConnectionPoint;
  51714. initialize(state: NodeMaterialBuildState): void;
  51715. autoConfigure(): void;
  51716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51717. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51718. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51719. protected _buildBlock(state: NodeMaterialBuildState): this;
  51720. }
  51721. }
  51722. declare module BABYLON {
  51723. /**
  51724. * Block used to add an alpha test in the fragment shader
  51725. */
  51726. export class AlphaTestBlock extends NodeMaterialBlock {
  51727. /**
  51728. * Gets or sets the alpha value where alpha testing happens
  51729. */
  51730. alphaCutOff: number;
  51731. /**
  51732. * Create a new AlphaTestBlock
  51733. * @param name defines the block name
  51734. */
  51735. constructor(name: string);
  51736. /**
  51737. * Gets the current class name
  51738. * @returns the class name
  51739. */
  51740. getClassName(): string;
  51741. /**
  51742. * Gets the color input component
  51743. */
  51744. readonly color: NodeMaterialConnectionPoint;
  51745. protected _buildBlock(state: NodeMaterialBuildState): this;
  51746. }
  51747. }
  51748. declare module BABYLON {
  51749. /**
  51750. * Block used to create a Color4 out of 4 inputs (one for each component)
  51751. */
  51752. export class RGBAMergerBlock extends NodeMaterialBlock {
  51753. /**
  51754. * Create a new RGBAMergerBlock
  51755. * @param name defines the block name
  51756. */
  51757. constructor(name: string);
  51758. /**
  51759. * Gets the current class name
  51760. * @returns the class name
  51761. */
  51762. getClassName(): string;
  51763. /**
  51764. * Gets the R input component
  51765. */
  51766. readonly r: NodeMaterialConnectionPoint;
  51767. /**
  51768. * Gets the G input component
  51769. */
  51770. readonly g: NodeMaterialConnectionPoint;
  51771. /**
  51772. * Gets the B input component
  51773. */
  51774. readonly b: NodeMaterialConnectionPoint;
  51775. /**
  51776. * Gets the RGB input component
  51777. */
  51778. readonly rgb: NodeMaterialConnectionPoint;
  51779. /**
  51780. * Gets the R input component
  51781. */
  51782. readonly a: NodeMaterialConnectionPoint;
  51783. /**
  51784. * Gets the output component
  51785. */
  51786. readonly output: NodeMaterialConnectionPoint;
  51787. protected _buildBlock(state: NodeMaterialBuildState): this;
  51788. }
  51789. }
  51790. declare module BABYLON {
  51791. /**
  51792. * Block used to create a Color3 out of 3 inputs (one for each component)
  51793. */
  51794. export class RGBMergerBlock extends NodeMaterialBlock {
  51795. /**
  51796. * Create a new RGBMergerBlock
  51797. * @param name defines the block name
  51798. */
  51799. constructor(name: string);
  51800. /**
  51801. * Gets the current class name
  51802. * @returns the class name
  51803. */
  51804. getClassName(): string;
  51805. /**
  51806. * Gets the R component input
  51807. */
  51808. readonly r: NodeMaterialConnectionPoint;
  51809. /**
  51810. * Gets the G component input
  51811. */
  51812. readonly g: NodeMaterialConnectionPoint;
  51813. /**
  51814. * Gets the B component input
  51815. */
  51816. readonly b: NodeMaterialConnectionPoint;
  51817. /**
  51818. * Gets the output component
  51819. */
  51820. readonly output: NodeMaterialConnectionPoint;
  51821. protected _buildBlock(state: NodeMaterialBuildState): this;
  51822. }
  51823. }
  51824. declare module BABYLON {
  51825. /**
  51826. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51827. */
  51828. export class RGBASplitterBlock extends NodeMaterialBlock {
  51829. /**
  51830. * Create a new RGBASplitterBlock
  51831. * @param name defines the block name
  51832. */
  51833. constructor(name: string);
  51834. /**
  51835. * Gets the current class name
  51836. * @returns the class name
  51837. */
  51838. getClassName(): string;
  51839. /**
  51840. * Gets the input component
  51841. */
  51842. readonly input: NodeMaterialConnectionPoint;
  51843. protected _buildBlock(state: NodeMaterialBuildState): this;
  51844. }
  51845. }
  51846. declare module BABYLON {
  51847. /**
  51848. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51849. */
  51850. export class RGBSplitterBlock extends NodeMaterialBlock {
  51851. /**
  51852. * Create a new RGBSplitterBlock
  51853. * @param name defines the block name
  51854. */
  51855. constructor(name: string);
  51856. /**
  51857. * Gets the current class name
  51858. * @returns the class name
  51859. */
  51860. getClassName(): string;
  51861. /**
  51862. * Gets the input component
  51863. */
  51864. readonly input: NodeMaterialConnectionPoint;
  51865. protected _buildBlock(state: NodeMaterialBuildState): this;
  51866. }
  51867. }
  51868. declare module BABYLON {
  51869. /**
  51870. * Block used to read a texture from a sampler
  51871. */
  51872. export class TextureBlock extends NodeMaterialBlock {
  51873. private _defineName;
  51874. /**
  51875. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51876. */
  51877. autoConnectTextureMatrix: boolean;
  51878. /**
  51879. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51880. */
  51881. autoSelectUV: boolean;
  51882. /**
  51883. * Create a new TextureBlock
  51884. * @param name defines the block name
  51885. */
  51886. constructor(name: string);
  51887. /**
  51888. * Gets the current class name
  51889. * @returns the class name
  51890. */
  51891. getClassName(): string;
  51892. /**
  51893. * Gets the uv input component
  51894. */
  51895. readonly uv: NodeMaterialConnectionPoint;
  51896. /**
  51897. * Gets the texture information input component
  51898. */
  51899. readonly textureInfo: NodeMaterialConnectionPoint;
  51900. /**
  51901. * Gets the transformed uv input component
  51902. */
  51903. readonly transformedUV: NodeMaterialConnectionPoint;
  51904. /**
  51905. * Gets the texture input component
  51906. */
  51907. readonly texture: NodeMaterialConnectionPoint;
  51908. /**
  51909. * Gets the texture transform input component
  51910. */
  51911. readonly textureTransform: NodeMaterialConnectionPoint;
  51912. /**
  51913. * Gets the output component
  51914. */
  51915. readonly output: NodeMaterialConnectionPoint;
  51916. autoConfigure(): void;
  51917. initialize(state: NodeMaterialBuildState): void;
  51918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51919. isReady(): boolean;
  51920. private _injectVertexCode;
  51921. protected _buildBlock(state: NodeMaterialBuildState): this;
  51922. }
  51923. }
  51924. declare module BABYLON {
  51925. /**
  51926. * Block used to add image processing support to fragment shader
  51927. */
  51928. export class ImageProcessingBlock extends NodeMaterialBlock {
  51929. /**
  51930. * Create a new ImageProcessingBlock
  51931. * @param name defines the block name
  51932. */
  51933. constructor(name: string);
  51934. /**
  51935. * Gets the current class name
  51936. * @returns the class name
  51937. */
  51938. getClassName(): string;
  51939. /**
  51940. * Gets the color input component
  51941. */
  51942. readonly color: NodeMaterialConnectionPoint;
  51943. /**
  51944. * Gets the output component
  51945. */
  51946. readonly output: NodeMaterialConnectionPoint;
  51947. /**
  51948. * Initialize the block and prepare the context for build
  51949. * @param state defines the state that will be used for the build
  51950. */
  51951. initialize(state: NodeMaterialBuildState): void;
  51952. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51955. protected _buildBlock(state: NodeMaterialBuildState): this;
  51956. }
  51957. }
  51958. declare module BABYLON {
  51959. /**
  51960. * Block used to add support for scene fog
  51961. */
  51962. export class FogBlock extends NodeMaterialBlock {
  51963. /**
  51964. * Create a new FogBlock
  51965. * @param name defines the block name
  51966. */
  51967. constructor(name: string);
  51968. /**
  51969. * Gets the current class name
  51970. * @returns the class name
  51971. */
  51972. getClassName(): string;
  51973. /**
  51974. * Gets the world position input component
  51975. */
  51976. readonly worldPosition: NodeMaterialConnectionPoint;
  51977. /**
  51978. * Gets the view input component
  51979. */
  51980. readonly view: NodeMaterialConnectionPoint;
  51981. /**
  51982. * Gets the color input component
  51983. */
  51984. readonly color: NodeMaterialConnectionPoint;
  51985. /**
  51986. * Gets the fog color input component
  51987. */
  51988. readonly fogColor: NodeMaterialConnectionPoint;
  51989. /**
  51990. * Gets the for parameter input component
  51991. */
  51992. readonly fogParameters: NodeMaterialConnectionPoint;
  51993. /**
  51994. * Gets the output component
  51995. */
  51996. readonly output: NodeMaterialConnectionPoint;
  51997. autoConfigure(): void;
  51998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52000. protected _buildBlock(state: NodeMaterialBuildState): this;
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /**
  52005. * Block used to add light in the fragment shader
  52006. */
  52007. export class LightBlock extends NodeMaterialBlock {
  52008. private _lightId;
  52009. /**
  52010. * Create a new LightBlock
  52011. * @param name defines the block name
  52012. */
  52013. constructor(name: string);
  52014. /**
  52015. * Gets the current class name
  52016. * @returns the class name
  52017. */
  52018. getClassName(): string;
  52019. /**
  52020. * Gets the world position input component
  52021. */
  52022. readonly worldPosition: NodeMaterialConnectionPoint;
  52023. /**
  52024. * Gets the world normal input component
  52025. */
  52026. readonly worldNormal: NodeMaterialConnectionPoint;
  52027. /**
  52028. * Gets the light input component
  52029. */
  52030. readonly light: NodeMaterialConnectionPoint;
  52031. /**
  52032. * Gets the camera (or eye) position component
  52033. */
  52034. readonly cameraPosition: NodeMaterialConnectionPoint;
  52035. /**
  52036. * Gets the diffuse output component
  52037. */
  52038. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52039. /**
  52040. * Gets the specular output component
  52041. */
  52042. readonly specularOutput: NodeMaterialConnectionPoint;
  52043. autoConfigure(): void;
  52044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52046. private _injectVertexCode;
  52047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52048. }
  52049. }
  52050. declare module BABYLON {
  52051. /**
  52052. * Block used to multiply 2 vector4
  52053. */
  52054. export class MultiplyBlock extends NodeMaterialBlock {
  52055. /**
  52056. * Creates a new MultiplyBlock
  52057. * @param name defines the block name
  52058. */
  52059. constructor(name: string);
  52060. /**
  52061. * Gets the current class name
  52062. * @returns the class name
  52063. */
  52064. getClassName(): string;
  52065. /**
  52066. * Gets the left operand input component
  52067. */
  52068. readonly left: NodeMaterialConnectionPoint;
  52069. /**
  52070. * Gets the right operand input component
  52071. */
  52072. readonly right: NodeMaterialConnectionPoint;
  52073. /**
  52074. * Gets the output component
  52075. */
  52076. readonly output: NodeMaterialConnectionPoint;
  52077. protected _buildBlock(state: NodeMaterialBuildState): this;
  52078. }
  52079. }
  52080. declare module BABYLON {
  52081. /**
  52082. * Block used to add 2 vector4
  52083. */
  52084. export class AddBlock extends NodeMaterialBlock {
  52085. /**
  52086. * Creates a new AddBlock
  52087. * @param name defines the block name
  52088. */
  52089. constructor(name: string);
  52090. /**
  52091. * Gets the current class name
  52092. * @returns the class name
  52093. */
  52094. getClassName(): string;
  52095. /**
  52096. * Gets the left operand input component
  52097. */
  52098. readonly left: NodeMaterialConnectionPoint;
  52099. /**
  52100. * Gets the right operand input component
  52101. */
  52102. readonly right: NodeMaterialConnectionPoint;
  52103. /**
  52104. * Gets the output component
  52105. */
  52106. readonly output: NodeMaterialConnectionPoint;
  52107. protected _buildBlock(state: NodeMaterialBuildState): this;
  52108. }
  52109. }
  52110. declare module BABYLON {
  52111. /**
  52112. * Block used to clamp a float
  52113. */
  52114. export class ClampBlock extends NodeMaterialBlock {
  52115. /** Gets or sets the minimum range */
  52116. minimum: number;
  52117. /** Gets or sets the maximum range */
  52118. maximum: number;
  52119. /**
  52120. * Creates a new ClampBlock
  52121. * @param name defines the block name
  52122. */
  52123. constructor(name: string);
  52124. /**
  52125. * Gets the current class name
  52126. * @returns the class name
  52127. */
  52128. getClassName(): string;
  52129. /**
  52130. * Gets the value input component
  52131. */
  52132. readonly value: NodeMaterialConnectionPoint;
  52133. /**
  52134. * Gets the output component
  52135. */
  52136. readonly output: NodeMaterialConnectionPoint;
  52137. protected _buildBlock(state: NodeMaterialBuildState): this;
  52138. }
  52139. }
  52140. declare module BABYLON {
  52141. /**
  52142. * Block used to scale a value
  52143. */
  52144. export class ScaleBlock extends NodeMaterialBlock {
  52145. /**
  52146. * Creates a new ScaleBlock
  52147. * @param name defines the block name
  52148. */
  52149. constructor(name: string);
  52150. /**
  52151. * Gets the current class name
  52152. * @returns the class name
  52153. */
  52154. getClassName(): string;
  52155. /**
  52156. * Gets the value operand input component
  52157. */
  52158. readonly value: NodeMaterialConnectionPoint;
  52159. /**
  52160. * Gets the scale operand input component
  52161. */
  52162. readonly scale: NodeMaterialConnectionPoint;
  52163. /**
  52164. * Gets the output component
  52165. */
  52166. readonly output: NodeMaterialConnectionPoint;
  52167. protected _buildBlock(state: NodeMaterialBuildState): this;
  52168. }
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. * Block used to transform a vector2 with a matrix
  52173. */
  52174. export class Vector2TransformBlock extends NodeMaterialBlock {
  52175. /**
  52176. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52177. */
  52178. complementZ: number;
  52179. /**
  52180. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52181. */
  52182. complementW: number;
  52183. /**
  52184. * Creates a new Vector2TransformBlock
  52185. * @param name defines the block name
  52186. */
  52187. constructor(name: string);
  52188. /**
  52189. * Gets the vector input
  52190. */
  52191. readonly vector: NodeMaterialConnectionPoint;
  52192. /**
  52193. * Gets the matrix transform input
  52194. */
  52195. readonly transform: NodeMaterialConnectionPoint;
  52196. /**
  52197. * Gets the output component
  52198. */
  52199. readonly output: NodeMaterialConnectionPoint;
  52200. /**
  52201. * Gets the current class name
  52202. * @returns the class name
  52203. */
  52204. getClassName(): string;
  52205. protected _buildBlock(state: NodeMaterialBuildState): this;
  52206. }
  52207. }
  52208. declare module BABYLON {
  52209. /**
  52210. * Block used to transform a vector3 with a matrix
  52211. */
  52212. export class Vector3TransformBlock extends NodeMaterialBlock {
  52213. /**
  52214. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52215. */
  52216. complement: number;
  52217. /**
  52218. * Creates a new Vector3TransformBlock
  52219. * @param name defines the block name
  52220. */
  52221. constructor(name: string);
  52222. /**
  52223. * Gets the vector input
  52224. */
  52225. readonly vector: NodeMaterialConnectionPoint;
  52226. /**
  52227. * Gets the matrix transform input
  52228. */
  52229. readonly transform: NodeMaterialConnectionPoint;
  52230. /**
  52231. * Gets the output component
  52232. */
  52233. readonly output: NodeMaterialConnectionPoint;
  52234. /**
  52235. * Gets the current class name
  52236. * @returns the class name
  52237. */
  52238. getClassName(): string;
  52239. protected _buildBlock(state: NodeMaterialBuildState): this;
  52240. }
  52241. }
  52242. declare module BABYLON {
  52243. /**
  52244. * Block used to multiply two matrices
  52245. */
  52246. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  52247. /**
  52248. * Creates a new MatrixMultiplicationBlock
  52249. * @param name defines the block name
  52250. */
  52251. constructor(name: string);
  52252. /**
  52253. * Gets the left operand
  52254. */
  52255. readonly left: NodeMaterialConnectionPoint;
  52256. /**
  52257. * Gets the right operand
  52258. */
  52259. readonly right: NodeMaterialConnectionPoint;
  52260. /**
  52261. * Gets the output component
  52262. */
  52263. readonly output: NodeMaterialConnectionPoint;
  52264. /**
  52265. * Gets the current class name
  52266. * @returns the class name
  52267. */
  52268. getClassName(): string;
  52269. protected _buildBlock(state: NodeMaterialBuildState): this;
  52270. }
  52271. }
  52272. declare module BABYLON {
  52273. /**
  52274. * Helper class to push actions to a pool of workers.
  52275. */
  52276. export class WorkerPool implements IDisposable {
  52277. private _workerInfos;
  52278. private _pendingActions;
  52279. /**
  52280. * Constructor
  52281. * @param workers Array of workers to use for actions
  52282. */
  52283. constructor(workers: Array<Worker>);
  52284. /**
  52285. * Terminates all workers and clears any pending actions.
  52286. */
  52287. dispose(): void;
  52288. /**
  52289. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52290. * pended until a worker has completed its action.
  52291. * @param action The action to perform. Call onComplete when the action is complete.
  52292. */
  52293. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52294. private _execute;
  52295. }
  52296. }
  52297. declare module BABYLON {
  52298. /**
  52299. * Configuration for Draco compression
  52300. */
  52301. export interface IDracoCompressionConfiguration {
  52302. /**
  52303. * Configuration for the decoder.
  52304. */
  52305. decoder: {
  52306. /**
  52307. * The url to the WebAssembly module.
  52308. */
  52309. wasmUrl?: string;
  52310. /**
  52311. * The url to the WebAssembly binary.
  52312. */
  52313. wasmBinaryUrl?: string;
  52314. /**
  52315. * The url to the fallback JavaScript module.
  52316. */
  52317. fallbackUrl?: string;
  52318. };
  52319. }
  52320. /**
  52321. * Draco compression (https://google.github.io/draco/)
  52322. *
  52323. * This class wraps the Draco module.
  52324. *
  52325. * **Encoder**
  52326. *
  52327. * The encoder is not currently implemented.
  52328. *
  52329. * **Decoder**
  52330. *
  52331. * 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.
  52332. *
  52333. * To update the configuration, use the following code:
  52334. * ```javascript
  52335. * DracoCompression.Configuration = {
  52336. * decoder: {
  52337. * wasmUrl: "<url to the WebAssembly library>",
  52338. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52339. * fallbackUrl: "<url to the fallback JavaScript library>",
  52340. * }
  52341. * };
  52342. * ```
  52343. *
  52344. * 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.
  52345. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52346. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52347. *
  52348. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52349. * ```javascript
  52350. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52351. * ```
  52352. *
  52353. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52354. */
  52355. export class DracoCompression implements IDisposable {
  52356. private _workerPoolPromise?;
  52357. private _decoderModulePromise?;
  52358. /**
  52359. * The configuration. Defaults to the following urls:
  52360. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52361. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52362. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52363. */
  52364. static Configuration: IDracoCompressionConfiguration;
  52365. /**
  52366. * Returns true if the decoder configuration is available.
  52367. */
  52368. static readonly DecoderAvailable: boolean;
  52369. /**
  52370. * Default number of workers to create when creating the draco compression object.
  52371. */
  52372. static DefaultNumWorkers: number;
  52373. private static GetDefaultNumWorkers;
  52374. private static _Default;
  52375. /**
  52376. * Default instance for the draco compression object.
  52377. */
  52378. static readonly Default: DracoCompression;
  52379. /**
  52380. * Constructor
  52381. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52382. */
  52383. constructor(numWorkers?: number);
  52384. /**
  52385. * Stop all async operations and release resources.
  52386. */
  52387. dispose(): void;
  52388. /**
  52389. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52390. * @returns a promise that resolves when ready
  52391. */
  52392. whenReadyAsync(): Promise<void>;
  52393. /**
  52394. * Decode Draco compressed mesh data to vertex data.
  52395. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52396. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52397. * @returns A promise that resolves with the decoded vertex data
  52398. */
  52399. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52400. [kind: string]: number;
  52401. }): Promise<VertexData>;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * Class for building Constructive Solid Geometry
  52407. */
  52408. export class CSG {
  52409. private polygons;
  52410. /**
  52411. * The world matrix
  52412. */
  52413. matrix: Matrix;
  52414. /**
  52415. * Stores the position
  52416. */
  52417. position: Vector3;
  52418. /**
  52419. * Stores the rotation
  52420. */
  52421. rotation: Vector3;
  52422. /**
  52423. * Stores the rotation quaternion
  52424. */
  52425. rotationQuaternion: Nullable<Quaternion>;
  52426. /**
  52427. * Stores the scaling vector
  52428. */
  52429. scaling: Vector3;
  52430. /**
  52431. * Convert the Mesh to CSG
  52432. * @param mesh The Mesh to convert to CSG
  52433. * @returns A new CSG from the Mesh
  52434. */
  52435. static FromMesh(mesh: Mesh): CSG;
  52436. /**
  52437. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52438. * @param polygons Polygons used to construct a CSG solid
  52439. */
  52440. private static FromPolygons;
  52441. /**
  52442. * Clones, or makes a deep copy, of the CSG
  52443. * @returns A new CSG
  52444. */
  52445. clone(): CSG;
  52446. /**
  52447. * Unions this CSG with another CSG
  52448. * @param csg The CSG to union against this CSG
  52449. * @returns The unioned CSG
  52450. */
  52451. union(csg: CSG): CSG;
  52452. /**
  52453. * Unions this CSG with another CSG in place
  52454. * @param csg The CSG to union against this CSG
  52455. */
  52456. unionInPlace(csg: CSG): void;
  52457. /**
  52458. * Subtracts this CSG with another CSG
  52459. * @param csg The CSG to subtract against this CSG
  52460. * @returns A new CSG
  52461. */
  52462. subtract(csg: CSG): CSG;
  52463. /**
  52464. * Subtracts this CSG with another CSG in place
  52465. * @param csg The CSG to subtact against this CSG
  52466. */
  52467. subtractInPlace(csg: CSG): void;
  52468. /**
  52469. * Intersect this CSG with another CSG
  52470. * @param csg The CSG to intersect against this CSG
  52471. * @returns A new CSG
  52472. */
  52473. intersect(csg: CSG): CSG;
  52474. /**
  52475. * Intersects this CSG with another CSG in place
  52476. * @param csg The CSG to intersect against this CSG
  52477. */
  52478. intersectInPlace(csg: CSG): void;
  52479. /**
  52480. * Return a new CSG solid with solid and empty space switched. This solid is
  52481. * not modified.
  52482. * @returns A new CSG solid with solid and empty space switched
  52483. */
  52484. inverse(): CSG;
  52485. /**
  52486. * Inverses the CSG in place
  52487. */
  52488. inverseInPlace(): void;
  52489. /**
  52490. * This is used to keep meshes transformations so they can be restored
  52491. * when we build back a Babylon Mesh
  52492. * NB : All CSG operations are performed in world coordinates
  52493. * @param csg The CSG to copy the transform attributes from
  52494. * @returns This CSG
  52495. */
  52496. copyTransformAttributes(csg: CSG): CSG;
  52497. /**
  52498. * Build Raw mesh from CSG
  52499. * Coordinates here are in world space
  52500. * @param name The name of the mesh geometry
  52501. * @param scene The Scene
  52502. * @param keepSubMeshes Specifies if the submeshes should be kept
  52503. * @returns A new Mesh
  52504. */
  52505. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52506. /**
  52507. * Build Mesh from CSG taking material and transforms into account
  52508. * @param name The name of the Mesh
  52509. * @param material The material of the Mesh
  52510. * @param scene The Scene
  52511. * @param keepSubMeshes Specifies if submeshes should be kept
  52512. * @returns The new Mesh
  52513. */
  52514. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52515. }
  52516. }
  52517. declare module BABYLON {
  52518. /**
  52519. * Class used to create a trail following a mesh
  52520. */
  52521. export class TrailMesh extends Mesh {
  52522. private _generator;
  52523. private _autoStart;
  52524. private _running;
  52525. private _diameter;
  52526. private _length;
  52527. private _sectionPolygonPointsCount;
  52528. private _sectionVectors;
  52529. private _sectionNormalVectors;
  52530. private _beforeRenderObserver;
  52531. /**
  52532. * @constructor
  52533. * @param name The value used by scene.getMeshByName() to do a lookup.
  52534. * @param generator The mesh to generate a trail.
  52535. * @param scene The scene to add this mesh to.
  52536. * @param diameter Diameter of trailing mesh. Default is 1.
  52537. * @param length Length of trailing mesh. Default is 60.
  52538. * @param autoStart Automatically start trailing mesh. Default true.
  52539. */
  52540. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52541. /**
  52542. * "TrailMesh"
  52543. * @returns "TrailMesh"
  52544. */
  52545. getClassName(): string;
  52546. private _createMesh;
  52547. /**
  52548. * Start trailing mesh.
  52549. */
  52550. start(): void;
  52551. /**
  52552. * Stop trailing mesh.
  52553. */
  52554. stop(): void;
  52555. /**
  52556. * Update trailing mesh geometry.
  52557. */
  52558. update(): void;
  52559. /**
  52560. * Returns a new TrailMesh object.
  52561. * @param name is a string, the name given to the new mesh
  52562. * @param newGenerator use new generator object for cloned trail mesh
  52563. * @returns a new mesh
  52564. */
  52565. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52566. /**
  52567. * Serializes this trail mesh
  52568. * @param serializationObject object to write serialization to
  52569. */
  52570. serialize(serializationObject: any): void;
  52571. /**
  52572. * Parses a serialized trail mesh
  52573. * @param parsedMesh the serialized mesh
  52574. * @param scene the scene to create the trail mesh in
  52575. * @returns the created trail mesh
  52576. */
  52577. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52578. }
  52579. }
  52580. declare module BABYLON {
  52581. /**
  52582. * Class containing static functions to help procedurally build meshes
  52583. */
  52584. export class TiledBoxBuilder {
  52585. /**
  52586. * Creates a box mesh
  52587. * 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)
  52588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52590. * * 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
  52591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52592. * @param name defines the name of the mesh
  52593. * @param options defines the options used to create the mesh
  52594. * @param scene defines the hosting scene
  52595. * @returns the box mesh
  52596. */
  52597. static CreateTiledBox(name: string, options: {
  52598. pattern?: number;
  52599. width?: number;
  52600. height?: number;
  52601. depth?: number;
  52602. tileSize?: number;
  52603. tileWidth?: number;
  52604. tileHeight?: number;
  52605. alignHorizontal?: number;
  52606. alignVertical?: number;
  52607. faceUV?: Vector4[];
  52608. faceColors?: Color4[];
  52609. sideOrientation?: number;
  52610. updatable?: boolean;
  52611. }, scene?: Nullable<Scene>): Mesh;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Class containing static functions to help procedurally build meshes
  52617. */
  52618. export class TorusKnotBuilder {
  52619. /**
  52620. * Creates a torus knot mesh
  52621. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52622. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52623. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52624. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52626. * * 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
  52627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52628. * @param name defines the name of the mesh
  52629. * @param options defines the options used to create the mesh
  52630. * @param scene defines the hosting scene
  52631. * @returns the torus knot mesh
  52632. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52633. */
  52634. static CreateTorusKnot(name: string, options: {
  52635. radius?: number;
  52636. tube?: number;
  52637. radialSegments?: number;
  52638. tubularSegments?: number;
  52639. p?: number;
  52640. q?: number;
  52641. updatable?: boolean;
  52642. sideOrientation?: number;
  52643. frontUVs?: Vector4;
  52644. backUVs?: Vector4;
  52645. }, scene: any): Mesh;
  52646. }
  52647. }
  52648. declare module BABYLON {
  52649. /**
  52650. * Polygon
  52651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52652. */
  52653. export class Polygon {
  52654. /**
  52655. * Creates a rectangle
  52656. * @param xmin bottom X coord
  52657. * @param ymin bottom Y coord
  52658. * @param xmax top X coord
  52659. * @param ymax top Y coord
  52660. * @returns points that make the resulting rectation
  52661. */
  52662. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52663. /**
  52664. * Creates a circle
  52665. * @param radius radius of circle
  52666. * @param cx scale in x
  52667. * @param cy scale in y
  52668. * @param numberOfSides number of sides that make up the circle
  52669. * @returns points that make the resulting circle
  52670. */
  52671. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52672. /**
  52673. * Creates a polygon from input string
  52674. * @param input Input polygon data
  52675. * @returns the parsed points
  52676. */
  52677. static Parse(input: string): Vector2[];
  52678. /**
  52679. * Starts building a polygon from x and y coordinates
  52680. * @param x x coordinate
  52681. * @param y y coordinate
  52682. * @returns the started path2
  52683. */
  52684. static StartingAt(x: number, y: number): Path2;
  52685. }
  52686. /**
  52687. * Builds a polygon
  52688. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52689. */
  52690. export class PolygonMeshBuilder {
  52691. private _points;
  52692. private _outlinepoints;
  52693. private _holes;
  52694. private _name;
  52695. private _scene;
  52696. private _epoints;
  52697. private _eholes;
  52698. private _addToepoint;
  52699. /**
  52700. * Babylon reference to the earcut plugin.
  52701. */
  52702. bjsEarcut: any;
  52703. /**
  52704. * Creates a PolygonMeshBuilder
  52705. * @param name name of the builder
  52706. * @param contours Path of the polygon
  52707. * @param scene scene to add to when creating the mesh
  52708. * @param earcutInjection can be used to inject your own earcut reference
  52709. */
  52710. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52711. /**
  52712. * Adds a whole within the polygon
  52713. * @param hole Array of points defining the hole
  52714. * @returns this
  52715. */
  52716. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52717. /**
  52718. * Creates the polygon
  52719. * @param updatable If the mesh should be updatable
  52720. * @param depth The depth of the mesh created
  52721. * @returns the created mesh
  52722. */
  52723. build(updatable?: boolean, depth?: number): Mesh;
  52724. /**
  52725. * Creates the polygon
  52726. * @param depth The depth of the mesh created
  52727. * @returns the created VertexData
  52728. */
  52729. buildVertexData(depth?: number): VertexData;
  52730. /**
  52731. * Adds a side to the polygon
  52732. * @param positions points that make the polygon
  52733. * @param normals normals of the polygon
  52734. * @param uvs uvs of the polygon
  52735. * @param indices indices of the polygon
  52736. * @param bounds bounds of the polygon
  52737. * @param points points of the polygon
  52738. * @param depth depth of the polygon
  52739. * @param flip flip of the polygon
  52740. */
  52741. private addSide;
  52742. }
  52743. }
  52744. declare module BABYLON {
  52745. /**
  52746. * Class containing static functions to help procedurally build meshes
  52747. */
  52748. export class PolygonBuilder {
  52749. /**
  52750. * Creates a polygon mesh
  52751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52752. * * 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
  52753. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52755. * * 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)
  52756. * * Remember you can only change the shape positions, not their number when updating a polygon
  52757. * @param name defines the name of the mesh
  52758. * @param options defines the options used to create the mesh
  52759. * @param scene defines the hosting scene
  52760. * @param earcutInjection can be used to inject your own earcut reference
  52761. * @returns the polygon mesh
  52762. */
  52763. static CreatePolygon(name: string, options: {
  52764. shape: Vector3[];
  52765. holes?: Vector3[][];
  52766. depth?: number;
  52767. faceUV?: Vector4[];
  52768. faceColors?: Color4[];
  52769. updatable?: boolean;
  52770. sideOrientation?: number;
  52771. frontUVs?: Vector4;
  52772. backUVs?: Vector4;
  52773. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52774. /**
  52775. * Creates an extruded polygon mesh, with depth in the Y direction.
  52776. * * 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)
  52777. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52778. * @param name defines the name of the mesh
  52779. * @param options defines the options used to create the mesh
  52780. * @param scene defines the hosting scene
  52781. * @param earcutInjection can be used to inject your own earcut reference
  52782. * @returns the polygon mesh
  52783. */
  52784. static ExtrudePolygon(name: string, options: {
  52785. shape: Vector3[];
  52786. holes?: Vector3[][];
  52787. depth?: number;
  52788. faceUV?: Vector4[];
  52789. faceColors?: Color4[];
  52790. updatable?: boolean;
  52791. sideOrientation?: number;
  52792. frontUVs?: Vector4;
  52793. backUVs?: Vector4;
  52794. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52795. }
  52796. }
  52797. declare module BABYLON {
  52798. /**
  52799. * Class containing static functions to help procedurally build meshes
  52800. */
  52801. export class LatheBuilder {
  52802. /**
  52803. * Creates lathe mesh.
  52804. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52805. * * 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
  52806. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52807. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52808. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52809. * * 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
  52810. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52811. * * 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
  52812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52813. * * 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
  52814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52816. * @param name defines the name of the mesh
  52817. * @param options defines the options used to create the mesh
  52818. * @param scene defines the hosting scene
  52819. * @returns the lathe mesh
  52820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52821. */
  52822. static CreateLathe(name: string, options: {
  52823. shape: Vector3[];
  52824. radius?: number;
  52825. tessellation?: number;
  52826. clip?: number;
  52827. arc?: number;
  52828. closed?: boolean;
  52829. updatable?: boolean;
  52830. sideOrientation?: number;
  52831. frontUVs?: Vector4;
  52832. backUVs?: Vector4;
  52833. cap?: number;
  52834. invertUV?: boolean;
  52835. }, scene?: Nullable<Scene>): Mesh;
  52836. }
  52837. }
  52838. declare module BABYLON {
  52839. /**
  52840. * Class containing static functions to help procedurally build meshes
  52841. */
  52842. export class TiledPlaneBuilder {
  52843. /**
  52844. * Creates a tiled plane mesh
  52845. * * The parameter `pattern` will, depending on value, do nothing or
  52846. * * * flip (reflect about central vertical) alternate tiles across and up
  52847. * * * flip every tile on alternate rows
  52848. * * * rotate (180 degs) alternate tiles across and up
  52849. * * * rotate every tile on alternate rows
  52850. * * * flip and rotate alternate tiles across and up
  52851. * * * flip and rotate every tile on alternate rows
  52852. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52853. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52854. * * 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
  52855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52856. * * 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)
  52857. * * 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)
  52858. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52859. * @param name defines the name of the mesh
  52860. * @param options defines the options used to create the mesh
  52861. * @param scene defines the hosting scene
  52862. * @returns the box mesh
  52863. */
  52864. static CreateTiledPlane(name: string, options: {
  52865. pattern?: number;
  52866. tileSize?: number;
  52867. tileWidth?: number;
  52868. tileHeight?: number;
  52869. size?: number;
  52870. width?: number;
  52871. height?: number;
  52872. alignHorizontal?: number;
  52873. alignVertical?: number;
  52874. sideOrientation?: number;
  52875. frontUVs?: Vector4;
  52876. backUVs?: Vector4;
  52877. updatable?: boolean;
  52878. }, scene?: Nullable<Scene>): Mesh;
  52879. }
  52880. }
  52881. declare module BABYLON {
  52882. /**
  52883. * Class containing static functions to help procedurally build meshes
  52884. */
  52885. export class TubeBuilder {
  52886. /**
  52887. * Creates a tube mesh.
  52888. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52889. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52890. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52891. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52892. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52893. * * 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)
  52894. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52895. * * 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
  52896. * * 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
  52897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52898. * * 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
  52899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52901. * @param name defines the name of the mesh
  52902. * @param options defines the options used to create the mesh
  52903. * @param scene defines the hosting scene
  52904. * @returns the tube mesh
  52905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52906. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52907. */
  52908. static CreateTube(name: string, options: {
  52909. path: Vector3[];
  52910. radius?: number;
  52911. tessellation?: number;
  52912. radiusFunction?: {
  52913. (i: number, distance: number): number;
  52914. };
  52915. cap?: number;
  52916. arc?: number;
  52917. updatable?: boolean;
  52918. sideOrientation?: number;
  52919. frontUVs?: Vector4;
  52920. backUVs?: Vector4;
  52921. instance?: Mesh;
  52922. invertUV?: boolean;
  52923. }, scene?: Nullable<Scene>): Mesh;
  52924. }
  52925. }
  52926. declare module BABYLON {
  52927. /**
  52928. * Class containing static functions to help procedurally build meshes
  52929. */
  52930. export class IcoSphereBuilder {
  52931. /**
  52932. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52933. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52934. * * 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`)
  52935. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52936. * * 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
  52937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52938. * * 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
  52939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52940. * @param name defines the name of the mesh
  52941. * @param options defines the options used to create the mesh
  52942. * @param scene defines the hosting scene
  52943. * @returns the icosahedron mesh
  52944. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52945. */
  52946. static CreateIcoSphere(name: string, options: {
  52947. radius?: number;
  52948. radiusX?: number;
  52949. radiusY?: number;
  52950. radiusZ?: number;
  52951. flat?: boolean;
  52952. subdivisions?: number;
  52953. sideOrientation?: number;
  52954. frontUVs?: Vector4;
  52955. backUVs?: Vector4;
  52956. updatable?: boolean;
  52957. }, scene?: Nullable<Scene>): Mesh;
  52958. }
  52959. }
  52960. declare module BABYLON {
  52961. /**
  52962. * Class containing static functions to help procedurally build meshes
  52963. */
  52964. export class DecalBuilder {
  52965. /**
  52966. * Creates a decal mesh.
  52967. * 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
  52968. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52969. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52970. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52971. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52972. * @param name defines the name of the mesh
  52973. * @param sourceMesh defines the mesh where the decal must be applied
  52974. * @param options defines the options used to create the mesh
  52975. * @param scene defines the hosting scene
  52976. * @returns the decal mesh
  52977. * @see https://doc.babylonjs.com/how_to/decals
  52978. */
  52979. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52980. position?: Vector3;
  52981. normal?: Vector3;
  52982. size?: Vector3;
  52983. angle?: number;
  52984. }): Mesh;
  52985. }
  52986. }
  52987. declare module BABYLON {
  52988. /**
  52989. * Class containing static functions to help procedurally build meshes
  52990. */
  52991. export class MeshBuilder {
  52992. /**
  52993. * Creates a box mesh
  52994. * * The parameter `size` sets the size (float) of each box side (default 1)
  52995. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52996. * * 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)
  52997. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52999. * * 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
  53000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53001. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53002. * @param name defines the name of the mesh
  53003. * @param options defines the options used to create the mesh
  53004. * @param scene defines the hosting scene
  53005. * @returns the box mesh
  53006. */
  53007. static CreateBox(name: string, options: {
  53008. size?: number;
  53009. width?: number;
  53010. height?: number;
  53011. depth?: number;
  53012. faceUV?: Vector4[];
  53013. faceColors?: Color4[];
  53014. sideOrientation?: number;
  53015. frontUVs?: Vector4;
  53016. backUVs?: Vector4;
  53017. updatable?: boolean;
  53018. }, scene?: Nullable<Scene>): Mesh;
  53019. /**
  53020. * Creates a tiled box mesh
  53021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53023. * @param name defines the name of the mesh
  53024. * @param options defines the options used to create the mesh
  53025. * @param scene defines the hosting scene
  53026. * @returns the tiled box mesh
  53027. */
  53028. static CreateTiledBox(name: string, options: {
  53029. pattern?: number;
  53030. size?: number;
  53031. width?: number;
  53032. height?: number;
  53033. depth: number;
  53034. tileSize?: number;
  53035. tileWidth?: number;
  53036. tileHeight?: number;
  53037. faceUV?: Vector4[];
  53038. faceColors?: Color4[];
  53039. alignHorizontal?: number;
  53040. alignVertical?: number;
  53041. sideOrientation?: number;
  53042. updatable?: boolean;
  53043. }, scene?: Nullable<Scene>): Mesh;
  53044. /**
  53045. * Creates a sphere mesh
  53046. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53047. * * 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`)
  53048. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53049. * * 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
  53050. * * 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)
  53051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53052. * * 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
  53053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53054. * @param name defines the name of the mesh
  53055. * @param options defines the options used to create the mesh
  53056. * @param scene defines the hosting scene
  53057. * @returns the sphere mesh
  53058. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53059. */
  53060. static CreateSphere(name: string, options: {
  53061. segments?: number;
  53062. diameter?: number;
  53063. diameterX?: number;
  53064. diameterY?: number;
  53065. diameterZ?: number;
  53066. arc?: number;
  53067. slice?: number;
  53068. sideOrientation?: number;
  53069. frontUVs?: Vector4;
  53070. backUVs?: Vector4;
  53071. updatable?: boolean;
  53072. }, scene?: Nullable<Scene>): Mesh;
  53073. /**
  53074. * Creates a plane polygonal mesh. By default, this is a disc
  53075. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53076. * * 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
  53077. * * 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
  53078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53079. * * 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
  53080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53081. * @param name defines the name of the mesh
  53082. * @param options defines the options used to create the mesh
  53083. * @param scene defines the hosting scene
  53084. * @returns the plane polygonal mesh
  53085. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53086. */
  53087. static CreateDisc(name: string, options: {
  53088. radius?: number;
  53089. tessellation?: number;
  53090. arc?: number;
  53091. updatable?: boolean;
  53092. sideOrientation?: number;
  53093. frontUVs?: Vector4;
  53094. backUVs?: Vector4;
  53095. }, scene?: Nullable<Scene>): Mesh;
  53096. /**
  53097. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53098. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53099. * * 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`)
  53100. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53101. * * 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
  53102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53103. * * 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
  53104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53105. * @param name defines the name of the mesh
  53106. * @param options defines the options used to create the mesh
  53107. * @param scene defines the hosting scene
  53108. * @returns the icosahedron mesh
  53109. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53110. */
  53111. static CreateIcoSphere(name: string, options: {
  53112. radius?: number;
  53113. radiusX?: number;
  53114. radiusY?: number;
  53115. radiusZ?: number;
  53116. flat?: boolean;
  53117. subdivisions?: number;
  53118. sideOrientation?: number;
  53119. frontUVs?: Vector4;
  53120. backUVs?: Vector4;
  53121. updatable?: boolean;
  53122. }, scene?: Nullable<Scene>): Mesh;
  53123. /**
  53124. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53125. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53126. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53127. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53128. * * 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
  53129. * * 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
  53130. * * 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
  53131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53132. * * 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
  53133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53134. * * 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
  53135. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53136. * * 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
  53137. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53139. * @param name defines the name of the mesh
  53140. * @param options defines the options used to create the mesh
  53141. * @param scene defines the hosting scene
  53142. * @returns the ribbon mesh
  53143. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53145. */
  53146. static CreateRibbon(name: string, options: {
  53147. pathArray: Vector3[][];
  53148. closeArray?: boolean;
  53149. closePath?: boolean;
  53150. offset?: number;
  53151. updatable?: boolean;
  53152. sideOrientation?: number;
  53153. frontUVs?: Vector4;
  53154. backUVs?: Vector4;
  53155. instance?: Mesh;
  53156. invertUV?: boolean;
  53157. uvs?: Vector2[];
  53158. colors?: Color4[];
  53159. }, scene?: Nullable<Scene>): Mesh;
  53160. /**
  53161. * Creates a cylinder or a cone mesh
  53162. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53163. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53164. * * 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.
  53165. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53166. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53167. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53168. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53169. * * 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).
  53170. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53171. * * 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).
  53172. * * 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
  53173. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53174. * * 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
  53175. * * 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.
  53176. * * If `enclose` is false, a ring surface is one element.
  53177. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53178. * * 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
  53179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53180. * * 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
  53181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53182. * @param name defines the name of the mesh
  53183. * @param options defines the options used to create the mesh
  53184. * @param scene defines the hosting scene
  53185. * @returns the cylinder mesh
  53186. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53187. */
  53188. static CreateCylinder(name: string, options: {
  53189. height?: number;
  53190. diameterTop?: number;
  53191. diameterBottom?: number;
  53192. diameter?: number;
  53193. tessellation?: number;
  53194. subdivisions?: number;
  53195. arc?: number;
  53196. faceColors?: Color4[];
  53197. faceUV?: Vector4[];
  53198. updatable?: boolean;
  53199. hasRings?: boolean;
  53200. enclose?: boolean;
  53201. cap?: number;
  53202. sideOrientation?: number;
  53203. frontUVs?: Vector4;
  53204. backUVs?: Vector4;
  53205. }, scene?: Nullable<Scene>): Mesh;
  53206. /**
  53207. * Creates a torus mesh
  53208. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53209. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53210. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53212. * * 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
  53213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53214. * @param name defines the name of the mesh
  53215. * @param options defines the options used to create the mesh
  53216. * @param scene defines the hosting scene
  53217. * @returns the torus mesh
  53218. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53219. */
  53220. static CreateTorus(name: string, options: {
  53221. diameter?: number;
  53222. thickness?: number;
  53223. tessellation?: number;
  53224. updatable?: boolean;
  53225. sideOrientation?: number;
  53226. frontUVs?: Vector4;
  53227. backUVs?: Vector4;
  53228. }, scene?: Nullable<Scene>): Mesh;
  53229. /**
  53230. * Creates a torus knot mesh
  53231. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53232. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53233. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53234. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53236. * * 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
  53237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53238. * @param name defines the name of the mesh
  53239. * @param options defines the options used to create the mesh
  53240. * @param scene defines the hosting scene
  53241. * @returns the torus knot mesh
  53242. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53243. */
  53244. static CreateTorusKnot(name: string, options: {
  53245. radius?: number;
  53246. tube?: number;
  53247. radialSegments?: number;
  53248. tubularSegments?: number;
  53249. p?: number;
  53250. q?: number;
  53251. updatable?: boolean;
  53252. sideOrientation?: number;
  53253. frontUVs?: Vector4;
  53254. backUVs?: Vector4;
  53255. }, scene?: Nullable<Scene>): Mesh;
  53256. /**
  53257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53258. * * 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
  53259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53264. * * 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
  53265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53268. * @param name defines the name of the new line system
  53269. * @param options defines the options used to create the line system
  53270. * @param scene defines the hosting scene
  53271. * @returns a new line system mesh
  53272. */
  53273. static CreateLineSystem(name: string, options: {
  53274. lines: Vector3[][];
  53275. updatable?: boolean;
  53276. instance?: Nullable<LinesMesh>;
  53277. colors?: Nullable<Color4[][]>;
  53278. useVertexAlpha?: boolean;
  53279. }, scene: Nullable<Scene>): LinesMesh;
  53280. /**
  53281. * Creates a line mesh
  53282. * 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
  53283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53284. * * The parameter `points` is an array successive Vector3
  53285. * * 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
  53286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53288. * * When updating an instance, remember that only point positions can change, not the number of points
  53289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53291. * @param name defines the name of the new line system
  53292. * @param options defines the options used to create the line system
  53293. * @param scene defines the hosting scene
  53294. * @returns a new line mesh
  53295. */
  53296. static CreateLines(name: string, options: {
  53297. points: Vector3[];
  53298. updatable?: boolean;
  53299. instance?: Nullable<LinesMesh>;
  53300. colors?: Color4[];
  53301. useVertexAlpha?: boolean;
  53302. }, scene?: Nullable<Scene>): LinesMesh;
  53303. /**
  53304. * Creates a dashed line mesh
  53305. * * 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
  53306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53307. * * The parameter `points` is an array successive Vector3
  53308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53311. * * 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
  53312. * * When updating an instance, remember that only point positions can change, not the number of points
  53313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53314. * @param name defines the name of the mesh
  53315. * @param options defines the options used to create the mesh
  53316. * @param scene defines the hosting scene
  53317. * @returns the dashed line mesh
  53318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53319. */
  53320. static CreateDashedLines(name: string, options: {
  53321. points: Vector3[];
  53322. dashSize?: number;
  53323. gapSize?: number;
  53324. dashNb?: number;
  53325. updatable?: boolean;
  53326. instance?: LinesMesh;
  53327. }, scene?: Nullable<Scene>): LinesMesh;
  53328. /**
  53329. * 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.
  53330. * * 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.
  53331. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53332. * * 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.
  53333. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53334. * * 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
  53335. * * 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
  53336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53338. * * 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
  53339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53341. * @param name defines the name of the mesh
  53342. * @param options defines the options used to create the mesh
  53343. * @param scene defines the hosting scene
  53344. * @returns the extruded shape mesh
  53345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53347. */
  53348. static ExtrudeShape(name: string, options: {
  53349. shape: Vector3[];
  53350. path: Vector3[];
  53351. scale?: number;
  53352. rotation?: number;
  53353. cap?: number;
  53354. updatable?: boolean;
  53355. sideOrientation?: number;
  53356. frontUVs?: Vector4;
  53357. backUVs?: Vector4;
  53358. instance?: Mesh;
  53359. invertUV?: boolean;
  53360. }, scene?: Nullable<Scene>): Mesh;
  53361. /**
  53362. * Creates an custom extruded shape mesh.
  53363. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53364. * * 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.
  53365. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53366. * * 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
  53367. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53368. * * 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
  53369. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53370. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53371. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53372. * * 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
  53373. * * 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
  53374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53376. * * 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
  53377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53379. * @param name defines the name of the mesh
  53380. * @param options defines the options used to create the mesh
  53381. * @param scene defines the hosting scene
  53382. * @returns the custom extruded shape mesh
  53383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53386. */
  53387. static ExtrudeShapeCustom(name: string, options: {
  53388. shape: Vector3[];
  53389. path: Vector3[];
  53390. scaleFunction?: any;
  53391. rotationFunction?: any;
  53392. ribbonCloseArray?: boolean;
  53393. ribbonClosePath?: boolean;
  53394. cap?: number;
  53395. updatable?: boolean;
  53396. sideOrientation?: number;
  53397. frontUVs?: Vector4;
  53398. backUVs?: Vector4;
  53399. instance?: Mesh;
  53400. invertUV?: boolean;
  53401. }, scene?: Nullable<Scene>): Mesh;
  53402. /**
  53403. * Creates lathe mesh.
  53404. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53405. * * 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
  53406. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53407. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53408. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53409. * * 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
  53410. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53411. * * 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
  53412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53413. * * 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
  53414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53416. * @param name defines the name of the mesh
  53417. * @param options defines the options used to create the mesh
  53418. * @param scene defines the hosting scene
  53419. * @returns the lathe mesh
  53420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53421. */
  53422. static CreateLathe(name: string, options: {
  53423. shape: Vector3[];
  53424. radius?: number;
  53425. tessellation?: number;
  53426. clip?: number;
  53427. arc?: number;
  53428. closed?: boolean;
  53429. updatable?: boolean;
  53430. sideOrientation?: number;
  53431. frontUVs?: Vector4;
  53432. backUVs?: Vector4;
  53433. cap?: number;
  53434. invertUV?: boolean;
  53435. }, scene?: Nullable<Scene>): Mesh;
  53436. /**
  53437. * Creates a tiled plane mesh
  53438. * * You can set a limited pattern arrangement with the tiles
  53439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53440. * * 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
  53441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53442. * @param name defines the name of the mesh
  53443. * @param options defines the options used to create the mesh
  53444. * @param scene defines the hosting scene
  53445. * @returns the plane mesh
  53446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53447. */
  53448. static CreateTiledPlane(name: string, options: {
  53449. pattern?: number;
  53450. tileSize?: number;
  53451. tileWidth?: number;
  53452. tileHeight?: number;
  53453. size?: number;
  53454. width?: number;
  53455. height?: number;
  53456. alignHorizontal?: number;
  53457. alignVertical?: number;
  53458. sideOrientation?: number;
  53459. frontUVs?: Vector4;
  53460. backUVs?: Vector4;
  53461. updatable?: boolean;
  53462. }, scene?: Nullable<Scene>): Mesh;
  53463. /**
  53464. * Creates a plane mesh
  53465. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53466. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53467. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53469. * * 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
  53470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53471. * @param name defines the name of the mesh
  53472. * @param options defines the options used to create the mesh
  53473. * @param scene defines the hosting scene
  53474. * @returns the plane mesh
  53475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53476. */
  53477. static CreatePlane(name: string, options: {
  53478. size?: number;
  53479. width?: number;
  53480. height?: number;
  53481. sideOrientation?: number;
  53482. frontUVs?: Vector4;
  53483. backUVs?: Vector4;
  53484. updatable?: boolean;
  53485. sourcePlane?: Plane;
  53486. }, scene?: Nullable<Scene>): Mesh;
  53487. /**
  53488. * Creates a ground mesh
  53489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the ground mesh
  53496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53497. */
  53498. static CreateGround(name: string, options: {
  53499. width?: number;
  53500. height?: number;
  53501. subdivisions?: number;
  53502. subdivisionsX?: number;
  53503. subdivisionsY?: number;
  53504. updatable?: boolean;
  53505. }, scene?: Nullable<Scene>): Mesh;
  53506. /**
  53507. * Creates a tiled ground mesh
  53508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53510. * * 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
  53511. * * 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
  53512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53513. * @param name defines the name of the mesh
  53514. * @param options defines the options used to create the mesh
  53515. * @param scene defines the hosting scene
  53516. * @returns the tiled ground mesh
  53517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53518. */
  53519. static CreateTiledGround(name: string, options: {
  53520. xmin: number;
  53521. zmin: number;
  53522. xmax: number;
  53523. zmax: number;
  53524. subdivisions?: {
  53525. w: number;
  53526. h: number;
  53527. };
  53528. precision?: {
  53529. w: number;
  53530. h: number;
  53531. };
  53532. updatable?: boolean;
  53533. }, scene?: Nullable<Scene>): Mesh;
  53534. /**
  53535. * Creates a ground mesh from a height map
  53536. * * The parameter `url` sets the URL of the height map image resource.
  53537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53541. * * 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.
  53542. * * 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).
  53543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53545. * @param name defines the name of the mesh
  53546. * @param url defines the url to the height map
  53547. * @param options defines the options used to create the mesh
  53548. * @param scene defines the hosting scene
  53549. * @returns the ground mesh
  53550. * @see https://doc.babylonjs.com/babylon101/height_map
  53551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53552. */
  53553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53554. width?: number;
  53555. height?: number;
  53556. subdivisions?: number;
  53557. minHeight?: number;
  53558. maxHeight?: number;
  53559. colorFilter?: Color3;
  53560. alphaFilter?: number;
  53561. updatable?: boolean;
  53562. onReady?: (mesh: GroundMesh) => void;
  53563. }, scene?: Nullable<Scene>): GroundMesh;
  53564. /**
  53565. * Creates a polygon mesh
  53566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53567. * * 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
  53568. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53571. * * Remember you can only change the shape positions, not their number when updating a polygon
  53572. * @param name defines the name of the mesh
  53573. * @param options defines the options used to create the mesh
  53574. * @param scene defines the hosting scene
  53575. * @param earcutInjection can be used to inject your own earcut reference
  53576. * @returns the polygon mesh
  53577. */
  53578. static CreatePolygon(name: string, options: {
  53579. shape: Vector3[];
  53580. holes?: Vector3[][];
  53581. depth?: number;
  53582. faceUV?: Vector4[];
  53583. faceColors?: Color4[];
  53584. updatable?: boolean;
  53585. sideOrientation?: number;
  53586. frontUVs?: Vector4;
  53587. backUVs?: Vector4;
  53588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53589. /**
  53590. * Creates an extruded polygon mesh, with depth in the Y direction.
  53591. * * 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)
  53592. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53593. * @param name defines the name of the mesh
  53594. * @param options defines the options used to create the mesh
  53595. * @param scene defines the hosting scene
  53596. * @param earcutInjection can be used to inject your own earcut reference
  53597. * @returns the polygon mesh
  53598. */
  53599. static ExtrudePolygon(name: string, options: {
  53600. shape: Vector3[];
  53601. holes?: Vector3[][];
  53602. depth?: number;
  53603. faceUV?: Vector4[];
  53604. faceColors?: Color4[];
  53605. updatable?: boolean;
  53606. sideOrientation?: number;
  53607. frontUVs?: Vector4;
  53608. backUVs?: Vector4;
  53609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53610. /**
  53611. * Creates a tube mesh.
  53612. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53613. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53614. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53615. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53616. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53617. * * 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)
  53618. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53619. * * 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
  53620. * * 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
  53621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53622. * * 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
  53623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53625. * @param name defines the name of the mesh
  53626. * @param options defines the options used to create the mesh
  53627. * @param scene defines the hosting scene
  53628. * @returns the tube mesh
  53629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53630. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53631. */
  53632. static CreateTube(name: string, options: {
  53633. path: Vector3[];
  53634. radius?: number;
  53635. tessellation?: number;
  53636. radiusFunction?: {
  53637. (i: number, distance: number): number;
  53638. };
  53639. cap?: number;
  53640. arc?: number;
  53641. updatable?: boolean;
  53642. sideOrientation?: number;
  53643. frontUVs?: Vector4;
  53644. backUVs?: Vector4;
  53645. instance?: Mesh;
  53646. invertUV?: boolean;
  53647. }, scene?: Nullable<Scene>): Mesh;
  53648. /**
  53649. * Creates a polyhedron mesh
  53650. * * 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
  53651. * * The parameter `size` (positive float, default 1) sets the polygon size
  53652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53653. * * 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`
  53654. * * 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
  53655. * * 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)`)
  53656. * * 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
  53657. * * 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
  53658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53659. * * 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
  53660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53661. * @param name defines the name of the mesh
  53662. * @param options defines the options used to create the mesh
  53663. * @param scene defines the hosting scene
  53664. * @returns the polyhedron mesh
  53665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53666. */
  53667. static CreatePolyhedron(name: string, options: {
  53668. type?: number;
  53669. size?: number;
  53670. sizeX?: number;
  53671. sizeY?: number;
  53672. sizeZ?: number;
  53673. custom?: any;
  53674. faceUV?: Vector4[];
  53675. faceColors?: Color4[];
  53676. flat?: boolean;
  53677. updatable?: boolean;
  53678. sideOrientation?: number;
  53679. frontUVs?: Vector4;
  53680. backUVs?: Vector4;
  53681. }, scene?: Nullable<Scene>): Mesh;
  53682. /**
  53683. * Creates a decal mesh.
  53684. * 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
  53685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53689. * @param name defines the name of the mesh
  53690. * @param sourceMesh defines the mesh where the decal must be applied
  53691. * @param options defines the options used to create the mesh
  53692. * @param scene defines the hosting scene
  53693. * @returns the decal mesh
  53694. * @see https://doc.babylonjs.com/how_to/decals
  53695. */
  53696. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53697. position?: Vector3;
  53698. normal?: Vector3;
  53699. size?: Vector3;
  53700. angle?: number;
  53701. }): Mesh;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /**
  53706. * A simplifier interface for future simplification implementations
  53707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53708. */
  53709. export interface ISimplifier {
  53710. /**
  53711. * Simplification of a given mesh according to the given settings.
  53712. * Since this requires computation, it is assumed that the function runs async.
  53713. * @param settings The settings of the simplification, including quality and distance
  53714. * @param successCallback A callback that will be called after the mesh was simplified.
  53715. * @param errorCallback in case of an error, this callback will be called. optional.
  53716. */
  53717. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53718. }
  53719. /**
  53720. * Expected simplification settings.
  53721. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53722. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53723. */
  53724. export interface ISimplificationSettings {
  53725. /**
  53726. * Gets or sets the expected quality
  53727. */
  53728. quality: number;
  53729. /**
  53730. * Gets or sets the distance when this optimized version should be used
  53731. */
  53732. distance: number;
  53733. /**
  53734. * Gets an already optimized mesh
  53735. */
  53736. optimizeMesh?: boolean;
  53737. }
  53738. /**
  53739. * Class used to specify simplification options
  53740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53741. */
  53742. export class SimplificationSettings implements ISimplificationSettings {
  53743. /** expected quality */
  53744. quality: number;
  53745. /** distance when this optimized version should be used */
  53746. distance: number;
  53747. /** already optimized mesh */
  53748. optimizeMesh?: boolean | undefined;
  53749. /**
  53750. * Creates a SimplificationSettings
  53751. * @param quality expected quality
  53752. * @param distance distance when this optimized version should be used
  53753. * @param optimizeMesh already optimized mesh
  53754. */
  53755. constructor(
  53756. /** expected quality */
  53757. quality: number,
  53758. /** distance when this optimized version should be used */
  53759. distance: number,
  53760. /** already optimized mesh */
  53761. optimizeMesh?: boolean | undefined);
  53762. }
  53763. /**
  53764. * Interface used to define a simplification task
  53765. */
  53766. export interface ISimplificationTask {
  53767. /**
  53768. * Array of settings
  53769. */
  53770. settings: Array<ISimplificationSettings>;
  53771. /**
  53772. * Simplification type
  53773. */
  53774. simplificationType: SimplificationType;
  53775. /**
  53776. * Mesh to simplify
  53777. */
  53778. mesh: Mesh;
  53779. /**
  53780. * Callback called on success
  53781. */
  53782. successCallback?: () => void;
  53783. /**
  53784. * Defines if parallel processing can be used
  53785. */
  53786. parallelProcessing: boolean;
  53787. }
  53788. /**
  53789. * Queue used to order the simplification tasks
  53790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53791. */
  53792. export class SimplificationQueue {
  53793. private _simplificationArray;
  53794. /**
  53795. * Gets a boolean indicating that the process is still running
  53796. */
  53797. running: boolean;
  53798. /**
  53799. * Creates a new queue
  53800. */
  53801. constructor();
  53802. /**
  53803. * Adds a new simplification task
  53804. * @param task defines a task to add
  53805. */
  53806. addTask(task: ISimplificationTask): void;
  53807. /**
  53808. * Execute next task
  53809. */
  53810. executeNext(): void;
  53811. /**
  53812. * Execute a simplification task
  53813. * @param task defines the task to run
  53814. */
  53815. runSimplification(task: ISimplificationTask): void;
  53816. private getSimplifier;
  53817. }
  53818. /**
  53819. * The implemented types of simplification
  53820. * At the moment only Quadratic Error Decimation is implemented
  53821. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53822. */
  53823. export enum SimplificationType {
  53824. /** Quadratic error decimation */
  53825. QUADRATIC = 0
  53826. }
  53827. }
  53828. declare module BABYLON {
  53829. interface Scene {
  53830. /** @hidden (Backing field) */
  53831. _simplificationQueue: SimplificationQueue;
  53832. /**
  53833. * Gets or sets the simplification queue attached to the scene
  53834. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53835. */
  53836. simplificationQueue: SimplificationQueue;
  53837. }
  53838. interface Mesh {
  53839. /**
  53840. * Simplify the mesh according to the given array of settings.
  53841. * Function will return immediately and will simplify async
  53842. * @param settings a collection of simplification settings
  53843. * @param parallelProcessing should all levels calculate parallel or one after the other
  53844. * @param simplificationType the type of simplification to run
  53845. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53846. * @returns the current mesh
  53847. */
  53848. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53849. }
  53850. /**
  53851. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53852. * created in a scene
  53853. */
  53854. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53855. /**
  53856. * The component name helpfull to identify the component in the list of scene components.
  53857. */
  53858. readonly name: string;
  53859. /**
  53860. * The scene the component belongs to.
  53861. */
  53862. scene: Scene;
  53863. /**
  53864. * Creates a new instance of the component for the given scene
  53865. * @param scene Defines the scene to register the component in
  53866. */
  53867. constructor(scene: Scene);
  53868. /**
  53869. * Registers the component in a given scene
  53870. */
  53871. register(): void;
  53872. /**
  53873. * Rebuilds the elements related to this component in case of
  53874. * context lost for instance.
  53875. */
  53876. rebuild(): void;
  53877. /**
  53878. * Disposes the component and the associated ressources
  53879. */
  53880. dispose(): void;
  53881. private _beforeCameraUpdate;
  53882. }
  53883. }
  53884. declare module BABYLON {
  53885. /**
  53886. * Class used to enable access to IndexedDB
  53887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53888. */
  53889. export class Database implements IOfflineProvider {
  53890. private _callbackManifestChecked;
  53891. private _currentSceneUrl;
  53892. private _db;
  53893. private _enableSceneOffline;
  53894. private _enableTexturesOffline;
  53895. private _manifestVersionFound;
  53896. private _mustUpdateRessources;
  53897. private _hasReachedQuota;
  53898. private _isSupported;
  53899. private _idbFactory;
  53900. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53901. private static IsUASupportingBlobStorage;
  53902. /**
  53903. * Gets a boolean indicating if Database storate is enabled (off by default)
  53904. */
  53905. static IDBStorageEnabled: boolean;
  53906. /**
  53907. * Gets a boolean indicating if scene must be saved in the database
  53908. */
  53909. readonly enableSceneOffline: boolean;
  53910. /**
  53911. * Gets a boolean indicating if textures must be saved in the database
  53912. */
  53913. readonly enableTexturesOffline: boolean;
  53914. /**
  53915. * Creates a new Database
  53916. * @param urlToScene defines the url to load the scene
  53917. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53918. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53919. */
  53920. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53921. private static _ParseURL;
  53922. private static _ReturnFullUrlLocation;
  53923. private _checkManifestFile;
  53924. /**
  53925. * Open the database and make it available
  53926. * @param successCallback defines the callback to call on success
  53927. * @param errorCallback defines the callback to call on error
  53928. */
  53929. open(successCallback: () => void, errorCallback: () => void): void;
  53930. /**
  53931. * Loads an image from the database
  53932. * @param url defines the url to load from
  53933. * @param image defines the target DOM image
  53934. */
  53935. loadImage(url: string, image: HTMLImageElement): void;
  53936. private _loadImageFromDBAsync;
  53937. private _saveImageIntoDBAsync;
  53938. private _checkVersionFromDB;
  53939. private _loadVersionFromDBAsync;
  53940. private _saveVersionIntoDBAsync;
  53941. /**
  53942. * Loads a file from database
  53943. * @param url defines the URL to load from
  53944. * @param sceneLoaded defines a callback to call on success
  53945. * @param progressCallBack defines a callback to call when progress changed
  53946. * @param errorCallback defines a callback to call on error
  53947. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53948. */
  53949. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53950. private _loadFileAsync;
  53951. private _saveFileAsync;
  53952. /**
  53953. * Validates if xhr data is correct
  53954. * @param xhr defines the request to validate
  53955. * @param dataType defines the expected data type
  53956. * @returns true if data is correct
  53957. */
  53958. private static _ValidateXHRData;
  53959. }
  53960. }
  53961. declare module BABYLON {
  53962. /** @hidden */
  53963. export var gpuUpdateParticlesPixelShader: {
  53964. name: string;
  53965. shader: string;
  53966. };
  53967. }
  53968. declare module BABYLON {
  53969. /** @hidden */
  53970. export var gpuUpdateParticlesVertexShader: {
  53971. name: string;
  53972. shader: string;
  53973. };
  53974. }
  53975. declare module BABYLON {
  53976. /** @hidden */
  53977. export var clipPlaneFragmentDeclaration2: {
  53978. name: string;
  53979. shader: string;
  53980. };
  53981. }
  53982. declare module BABYLON {
  53983. /** @hidden */
  53984. export var gpuRenderParticlesPixelShader: {
  53985. name: string;
  53986. shader: string;
  53987. };
  53988. }
  53989. declare module BABYLON {
  53990. /** @hidden */
  53991. export var clipPlaneVertexDeclaration2: {
  53992. name: string;
  53993. shader: string;
  53994. };
  53995. }
  53996. declare module BABYLON {
  53997. /** @hidden */
  53998. export var gpuRenderParticlesVertexShader: {
  53999. name: string;
  54000. shader: string;
  54001. };
  54002. }
  54003. declare module BABYLON {
  54004. /**
  54005. * This represents a GPU particle system in Babylon
  54006. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54007. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54008. */
  54009. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54010. /**
  54011. * The layer mask we are rendering the particles through.
  54012. */
  54013. layerMask: number;
  54014. private _capacity;
  54015. private _activeCount;
  54016. private _currentActiveCount;
  54017. private _accumulatedCount;
  54018. private _renderEffect;
  54019. private _updateEffect;
  54020. private _buffer0;
  54021. private _buffer1;
  54022. private _spriteBuffer;
  54023. private _updateVAO;
  54024. private _renderVAO;
  54025. private _targetIndex;
  54026. private _sourceBuffer;
  54027. private _targetBuffer;
  54028. private _engine;
  54029. private _currentRenderId;
  54030. private _started;
  54031. private _stopped;
  54032. private _timeDelta;
  54033. private _randomTexture;
  54034. private _randomTexture2;
  54035. private _attributesStrideSize;
  54036. private _updateEffectOptions;
  54037. private _randomTextureSize;
  54038. private _actualFrame;
  54039. private readonly _rawTextureWidth;
  54040. /**
  54041. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54042. */
  54043. static readonly IsSupported: boolean;
  54044. /**
  54045. * An event triggered when the system is disposed.
  54046. */
  54047. onDisposeObservable: Observable<GPUParticleSystem>;
  54048. /**
  54049. * Gets the maximum number of particles active at the same time.
  54050. * @returns The max number of active particles.
  54051. */
  54052. getCapacity(): number;
  54053. /**
  54054. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54055. * to override the particles.
  54056. */
  54057. forceDepthWrite: boolean;
  54058. /**
  54059. * Gets or set the number of active particles
  54060. */
  54061. activeParticleCount: number;
  54062. private _preWarmDone;
  54063. /**
  54064. * Is this system ready to be used/rendered
  54065. * @return true if the system is ready
  54066. */
  54067. isReady(): boolean;
  54068. /**
  54069. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54070. * @returns True if it has been started, otherwise false.
  54071. */
  54072. isStarted(): boolean;
  54073. /**
  54074. * Starts the particle system and begins to emit
  54075. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54076. */
  54077. start(delay?: number): void;
  54078. /**
  54079. * Stops the particle system.
  54080. */
  54081. stop(): void;
  54082. /**
  54083. * Remove all active particles
  54084. */
  54085. reset(): void;
  54086. /**
  54087. * Returns the string "GPUParticleSystem"
  54088. * @returns a string containing the class name
  54089. */
  54090. getClassName(): string;
  54091. private _colorGradientsTexture;
  54092. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54093. /**
  54094. * Adds a new color gradient
  54095. * @param gradient defines the gradient to use (between 0 and 1)
  54096. * @param color1 defines the color to affect to the specified gradient
  54097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54098. * @returns the current particle system
  54099. */
  54100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54101. /**
  54102. * Remove a specific color gradient
  54103. * @param gradient defines the gradient to remove
  54104. * @returns the current particle system
  54105. */
  54106. removeColorGradient(gradient: number): GPUParticleSystem;
  54107. private _angularSpeedGradientsTexture;
  54108. private _sizeGradientsTexture;
  54109. private _velocityGradientsTexture;
  54110. private _limitVelocityGradientsTexture;
  54111. private _dragGradientsTexture;
  54112. private _addFactorGradient;
  54113. /**
  54114. * Adds a new size gradient
  54115. * @param gradient defines the gradient to use (between 0 and 1)
  54116. * @param factor defines the size factor to affect to the specified gradient
  54117. * @returns the current particle system
  54118. */
  54119. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54120. /**
  54121. * Remove a specific size gradient
  54122. * @param gradient defines the gradient to remove
  54123. * @returns the current particle system
  54124. */
  54125. removeSizeGradient(gradient: number): GPUParticleSystem;
  54126. /**
  54127. * Adds a new angular speed gradient
  54128. * @param gradient defines the gradient to use (between 0 and 1)
  54129. * @param factor defines the angular speed to affect to the specified gradient
  54130. * @returns the current particle system
  54131. */
  54132. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54133. /**
  54134. * Remove a specific angular speed gradient
  54135. * @param gradient defines the gradient to remove
  54136. * @returns the current particle system
  54137. */
  54138. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54139. /**
  54140. * Adds a new velocity gradient
  54141. * @param gradient defines the gradient to use (between 0 and 1)
  54142. * @param factor defines the velocity to affect to the specified gradient
  54143. * @returns the current particle system
  54144. */
  54145. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54146. /**
  54147. * Remove a specific velocity gradient
  54148. * @param gradient defines the gradient to remove
  54149. * @returns the current particle system
  54150. */
  54151. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54152. /**
  54153. * Adds a new limit velocity gradient
  54154. * @param gradient defines the gradient to use (between 0 and 1)
  54155. * @param factor defines the limit velocity value to affect to the specified gradient
  54156. * @returns the current particle system
  54157. */
  54158. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54159. /**
  54160. * Remove a specific limit velocity gradient
  54161. * @param gradient defines the gradient to remove
  54162. * @returns the current particle system
  54163. */
  54164. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54165. /**
  54166. * Adds a new drag gradient
  54167. * @param gradient defines the gradient to use (between 0 and 1)
  54168. * @param factor defines the drag value to affect to the specified gradient
  54169. * @returns the current particle system
  54170. */
  54171. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54172. /**
  54173. * Remove a specific drag gradient
  54174. * @param gradient defines the gradient to remove
  54175. * @returns the current particle system
  54176. */
  54177. removeDragGradient(gradient: number): GPUParticleSystem;
  54178. /**
  54179. * Not supported by GPUParticleSystem
  54180. * @param gradient defines the gradient to use (between 0 and 1)
  54181. * @param factor defines the emit rate value to affect to the specified gradient
  54182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54183. * @returns the current particle system
  54184. */
  54185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54186. /**
  54187. * Not supported by GPUParticleSystem
  54188. * @param gradient defines the gradient to remove
  54189. * @returns the current particle system
  54190. */
  54191. removeEmitRateGradient(gradient: number): IParticleSystem;
  54192. /**
  54193. * Not supported by GPUParticleSystem
  54194. * @param gradient defines the gradient to use (between 0 and 1)
  54195. * @param factor defines the start size value to affect to the specified gradient
  54196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54197. * @returns the current particle system
  54198. */
  54199. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54200. /**
  54201. * Not supported by GPUParticleSystem
  54202. * @param gradient defines the gradient to remove
  54203. * @returns the current particle system
  54204. */
  54205. removeStartSizeGradient(gradient: number): IParticleSystem;
  54206. /**
  54207. * Not supported by GPUParticleSystem
  54208. * @param gradient defines the gradient to use (between 0 and 1)
  54209. * @param min defines the color remap minimal range
  54210. * @param max defines the color remap maximal range
  54211. * @returns the current particle system
  54212. */
  54213. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54214. /**
  54215. * Not supported by GPUParticleSystem
  54216. * @param gradient defines the gradient to remove
  54217. * @returns the current particle system
  54218. */
  54219. removeColorRemapGradient(): IParticleSystem;
  54220. /**
  54221. * Not supported by GPUParticleSystem
  54222. * @param gradient defines the gradient to use (between 0 and 1)
  54223. * @param min defines the alpha remap minimal range
  54224. * @param max defines the alpha remap maximal range
  54225. * @returns the current particle system
  54226. */
  54227. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54228. /**
  54229. * Not supported by GPUParticleSystem
  54230. * @param gradient defines the gradient to remove
  54231. * @returns the current particle system
  54232. */
  54233. removeAlphaRemapGradient(): IParticleSystem;
  54234. /**
  54235. * Not supported by GPUParticleSystem
  54236. * @param gradient defines the gradient to use (between 0 and 1)
  54237. * @param color defines the color to affect to the specified gradient
  54238. * @returns the current particle system
  54239. */
  54240. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54241. /**
  54242. * Not supported by GPUParticleSystem
  54243. * @param gradient defines the gradient to remove
  54244. * @returns the current particle system
  54245. */
  54246. removeRampGradient(): IParticleSystem;
  54247. /**
  54248. * Not supported by GPUParticleSystem
  54249. * @returns the list of ramp gradients
  54250. */
  54251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54252. /**
  54253. * Not supported by GPUParticleSystem
  54254. * Gets or sets a boolean indicating that ramp gradients must be used
  54255. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54256. */
  54257. useRampGradients: boolean;
  54258. /**
  54259. * Not supported by GPUParticleSystem
  54260. * @param gradient defines the gradient to use (between 0 and 1)
  54261. * @param factor defines the life time factor to affect to the specified gradient
  54262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54263. * @returns the current particle system
  54264. */
  54265. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54266. /**
  54267. * Not supported by GPUParticleSystem
  54268. * @param gradient defines the gradient to remove
  54269. * @returns the current particle system
  54270. */
  54271. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54272. /**
  54273. * Instantiates a GPU particle system.
  54274. * 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.
  54275. * @param name The name of the particle system
  54276. * @param options The options used to create the system
  54277. * @param scene The scene the particle system belongs to
  54278. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54279. */
  54280. constructor(name: string, options: Partial<{
  54281. capacity: number;
  54282. randomTextureSize: number;
  54283. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54284. protected _reset(): void;
  54285. private _createUpdateVAO;
  54286. private _createRenderVAO;
  54287. private _initialize;
  54288. /** @hidden */
  54289. _recreateUpdateEffect(): void;
  54290. /** @hidden */
  54291. _recreateRenderEffect(): void;
  54292. /**
  54293. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54294. * @param preWarm defines if we are in the pre-warmimg phase
  54295. */
  54296. animate(preWarm?: boolean): void;
  54297. private _createFactorGradientTexture;
  54298. private _createSizeGradientTexture;
  54299. private _createAngularSpeedGradientTexture;
  54300. private _createVelocityGradientTexture;
  54301. private _createLimitVelocityGradientTexture;
  54302. private _createDragGradientTexture;
  54303. private _createColorGradientTexture;
  54304. /**
  54305. * Renders the particle system in its current state
  54306. * @param preWarm defines if the system should only update the particles but not render them
  54307. * @returns the current number of particles
  54308. */
  54309. render(preWarm?: boolean): number;
  54310. /**
  54311. * Rebuilds the particle system
  54312. */
  54313. rebuild(): void;
  54314. private _releaseBuffers;
  54315. private _releaseVAOs;
  54316. /**
  54317. * Disposes the particle system and free the associated resources
  54318. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54319. */
  54320. dispose(disposeTexture?: boolean): void;
  54321. /**
  54322. * Clones the particle system.
  54323. * @param name The name of the cloned object
  54324. * @param newEmitter The new emitter to use
  54325. * @returns the cloned particle system
  54326. */
  54327. clone(name: string, newEmitter: any): GPUParticleSystem;
  54328. /**
  54329. * Serializes the particle system to a JSON object.
  54330. * @returns the JSON object
  54331. */
  54332. serialize(): any;
  54333. /**
  54334. * Parses a JSON object to create a GPU particle system.
  54335. * @param parsedParticleSystem The JSON object to parse
  54336. * @param scene The scene to create the particle system in
  54337. * @param rootUrl The root url to use to load external dependencies like texture
  54338. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54339. * @returns the parsed GPU particle system
  54340. */
  54341. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54342. }
  54343. }
  54344. declare module BABYLON {
  54345. /**
  54346. * Represents a set of particle systems working together to create a specific effect
  54347. */
  54348. export class ParticleSystemSet implements IDisposable {
  54349. private _emitterCreationOptions;
  54350. private _emitterNode;
  54351. /**
  54352. * Gets the particle system list
  54353. */
  54354. systems: IParticleSystem[];
  54355. /**
  54356. * Gets the emitter node used with this set
  54357. */
  54358. readonly emitterNode: Nullable<TransformNode>;
  54359. /**
  54360. * Creates a new emitter mesh as a sphere
  54361. * @param options defines the options used to create the sphere
  54362. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54363. * @param scene defines the hosting scene
  54364. */
  54365. setEmitterAsSphere(options: {
  54366. diameter: number;
  54367. segments: number;
  54368. color: Color3;
  54369. }, renderingGroupId: number, scene: Scene): void;
  54370. /**
  54371. * Starts all particle systems of the set
  54372. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54373. */
  54374. start(emitter?: AbstractMesh): void;
  54375. /**
  54376. * Release all associated resources
  54377. */
  54378. dispose(): void;
  54379. /**
  54380. * Serialize the set into a JSON compatible object
  54381. * @returns a JSON compatible representation of the set
  54382. */
  54383. serialize(): any;
  54384. /**
  54385. * Parse a new ParticleSystemSet from a serialized source
  54386. * @param data defines a JSON compatible representation of the set
  54387. * @param scene defines the hosting scene
  54388. * @param gpu defines if we want GPU particles or CPU particles
  54389. * @returns a new ParticleSystemSet
  54390. */
  54391. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54392. }
  54393. }
  54394. declare module BABYLON {
  54395. /**
  54396. * This class is made for on one-liner static method to help creating particle system set.
  54397. */
  54398. export class ParticleHelper {
  54399. /**
  54400. * Gets or sets base Assets URL
  54401. */
  54402. static BaseAssetsUrl: string;
  54403. /**
  54404. * Create a default particle system that you can tweak
  54405. * @param emitter defines the emitter to use
  54406. * @param capacity defines the system capacity (default is 500 particles)
  54407. * @param scene defines the hosting scene
  54408. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54409. * @returns the new Particle system
  54410. */
  54411. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54412. /**
  54413. * This is the main static method (one-liner) of this helper to create different particle systems
  54414. * @param type This string represents the type to the particle system to create
  54415. * @param scene The scene where the particle system should live
  54416. * @param gpu If the system will use gpu
  54417. * @returns the ParticleSystemSet created
  54418. */
  54419. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54420. /**
  54421. * Static function used to export a particle system to a ParticleSystemSet variable.
  54422. * Please note that the emitter shape is not exported
  54423. * @param systems defines the particle systems to export
  54424. * @returns the created particle system set
  54425. */
  54426. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54427. }
  54428. }
  54429. declare module BABYLON {
  54430. interface Engine {
  54431. /**
  54432. * Create an effect to use with particle systems.
  54433. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54434. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54435. * @param uniformsNames defines a list of attribute names
  54436. * @param samplers defines an array of string used to represent textures
  54437. * @param defines defines the string containing the defines to use to compile the shaders
  54438. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54439. * @param onCompiled defines a function to call when the effect creation is successful
  54440. * @param onError defines a function to call when the effect creation has failed
  54441. * @returns the new Effect
  54442. */
  54443. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54444. }
  54445. interface Mesh {
  54446. /**
  54447. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54448. * @returns an array of IParticleSystem
  54449. */
  54450. getEmittedParticleSystems(): IParticleSystem[];
  54451. /**
  54452. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54453. * @returns an array of IParticleSystem
  54454. */
  54455. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54456. }
  54457. /**
  54458. * @hidden
  54459. */
  54460. export var _IDoNeedToBeInTheBuild: number;
  54461. }
  54462. declare module BABYLON {
  54463. interface Scene {
  54464. /** @hidden (Backing field) */
  54465. _physicsEngine: Nullable<IPhysicsEngine>;
  54466. /**
  54467. * Gets the current physics engine
  54468. * @returns a IPhysicsEngine or null if none attached
  54469. */
  54470. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54471. /**
  54472. * Enables physics to the current scene
  54473. * @param gravity defines the scene's gravity for the physics engine
  54474. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54475. * @return a boolean indicating if the physics engine was initialized
  54476. */
  54477. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54478. /**
  54479. * Disables and disposes the physics engine associated with the scene
  54480. */
  54481. disablePhysicsEngine(): void;
  54482. /**
  54483. * Gets a boolean indicating if there is an active physics engine
  54484. * @returns a boolean indicating if there is an active physics engine
  54485. */
  54486. isPhysicsEnabled(): boolean;
  54487. /**
  54488. * Deletes a physics compound impostor
  54489. * @param compound defines the compound to delete
  54490. */
  54491. deleteCompoundImpostor(compound: any): void;
  54492. /**
  54493. * An event triggered when physic simulation is about to be run
  54494. */
  54495. onBeforePhysicsObservable: Observable<Scene>;
  54496. /**
  54497. * An event triggered when physic simulation has been done
  54498. */
  54499. onAfterPhysicsObservable: Observable<Scene>;
  54500. }
  54501. interface AbstractMesh {
  54502. /** @hidden */
  54503. _physicsImpostor: Nullable<PhysicsImpostor>;
  54504. /**
  54505. * Gets or sets impostor used for physic simulation
  54506. * @see http://doc.babylonjs.com/features/physics_engine
  54507. */
  54508. physicsImpostor: Nullable<PhysicsImpostor>;
  54509. /**
  54510. * Gets the current physics impostor
  54511. * @see http://doc.babylonjs.com/features/physics_engine
  54512. * @returns a physics impostor or null
  54513. */
  54514. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54515. /** Apply a physic impulse to the mesh
  54516. * @param force defines the force to apply
  54517. * @param contactPoint defines where to apply the force
  54518. * @returns the current mesh
  54519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54520. */
  54521. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54522. /**
  54523. * Creates a physic joint between two meshes
  54524. * @param otherMesh defines the other mesh to use
  54525. * @param pivot1 defines the pivot to use on this mesh
  54526. * @param pivot2 defines the pivot to use on the other mesh
  54527. * @param options defines additional options (can be plugin dependent)
  54528. * @returns the current mesh
  54529. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54530. */
  54531. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54532. /** @hidden */
  54533. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54534. }
  54535. /**
  54536. * Defines the physics engine scene component responsible to manage a physics engine
  54537. */
  54538. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54539. /**
  54540. * The component name helpful to identify the component in the list of scene components.
  54541. */
  54542. readonly name: string;
  54543. /**
  54544. * The scene the component belongs to.
  54545. */
  54546. scene: Scene;
  54547. /**
  54548. * Creates a new instance of the component for the given scene
  54549. * @param scene Defines the scene to register the component in
  54550. */
  54551. constructor(scene: Scene);
  54552. /**
  54553. * Registers the component in a given scene
  54554. */
  54555. register(): void;
  54556. /**
  54557. * Rebuilds the elements related to this component in case of
  54558. * context lost for instance.
  54559. */
  54560. rebuild(): void;
  54561. /**
  54562. * Disposes the component and the associated ressources
  54563. */
  54564. dispose(): void;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * A helper for physics simulations
  54570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54571. */
  54572. export class PhysicsHelper {
  54573. private _scene;
  54574. private _physicsEngine;
  54575. /**
  54576. * Initializes the Physics helper
  54577. * @param scene Babylon.js scene
  54578. */
  54579. constructor(scene: Scene);
  54580. /**
  54581. * Applies a radial explosion impulse
  54582. * @param origin the origin of the explosion
  54583. * @param radiusOrEventOptions the radius or the options of radial explosion
  54584. * @param strength the explosion strength
  54585. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54586. * @returns A physics radial explosion event, or null
  54587. */
  54588. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54589. /**
  54590. * Applies a radial explosion force
  54591. * @param origin the origin of the explosion
  54592. * @param radiusOrEventOptions the radius or the options of radial explosion
  54593. * @param strength the explosion strength
  54594. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54595. * @returns A physics radial explosion event, or null
  54596. */
  54597. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54598. /**
  54599. * Creates a gravitational field
  54600. * @param origin the origin of the explosion
  54601. * @param radiusOrEventOptions the radius or the options of radial explosion
  54602. * @param strength the explosion strength
  54603. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54604. * @returns A physics gravitational field event, or null
  54605. */
  54606. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54607. /**
  54608. * Creates a physics updraft event
  54609. * @param origin the origin of the updraft
  54610. * @param radiusOrEventOptions the radius or the options of the updraft
  54611. * @param strength the strength of the updraft
  54612. * @param height the height of the updraft
  54613. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54614. * @returns A physics updraft event, or null
  54615. */
  54616. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54617. /**
  54618. * Creates a physics vortex event
  54619. * @param origin the of the vortex
  54620. * @param radiusOrEventOptions the radius or the options of the vortex
  54621. * @param strength the strength of the vortex
  54622. * @param height the height of the vortex
  54623. * @returns a Physics vortex event, or null
  54624. * A physics vortex event or null
  54625. */
  54626. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54627. }
  54628. /**
  54629. * Represents a physics radial explosion event
  54630. */
  54631. class PhysicsRadialExplosionEvent {
  54632. private _scene;
  54633. private _options;
  54634. private _sphere;
  54635. private _dataFetched;
  54636. /**
  54637. * Initializes a radial explosioin event
  54638. * @param _scene BabylonJS scene
  54639. * @param _options The options for the vortex event
  54640. */
  54641. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54642. /**
  54643. * Returns the data related to the radial explosion event (sphere).
  54644. * @returns The radial explosion event data
  54645. */
  54646. getData(): PhysicsRadialExplosionEventData;
  54647. /**
  54648. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54649. * @param impostor A physics imposter
  54650. * @param origin the origin of the explosion
  54651. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54652. */
  54653. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54654. /**
  54655. * Triggers affecterd impostors callbacks
  54656. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54657. */
  54658. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54659. /**
  54660. * Disposes the sphere.
  54661. * @param force Specifies if the sphere should be disposed by force
  54662. */
  54663. dispose(force?: boolean): void;
  54664. /*** Helpers ***/
  54665. private _prepareSphere;
  54666. private _intersectsWithSphere;
  54667. }
  54668. /**
  54669. * Represents a gravitational field event
  54670. */
  54671. class PhysicsGravitationalFieldEvent {
  54672. private _physicsHelper;
  54673. private _scene;
  54674. private _origin;
  54675. private _options;
  54676. private _tickCallback;
  54677. private _sphere;
  54678. private _dataFetched;
  54679. /**
  54680. * Initializes the physics gravitational field event
  54681. * @param _physicsHelper A physics helper
  54682. * @param _scene BabylonJS scene
  54683. * @param _origin The origin position of the gravitational field event
  54684. * @param _options The options for the vortex event
  54685. */
  54686. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54687. /**
  54688. * Returns the data related to the gravitational field event (sphere).
  54689. * @returns A gravitational field event
  54690. */
  54691. getData(): PhysicsGravitationalFieldEventData;
  54692. /**
  54693. * Enables the gravitational field.
  54694. */
  54695. enable(): void;
  54696. /**
  54697. * Disables the gravitational field.
  54698. */
  54699. disable(): void;
  54700. /**
  54701. * Disposes the sphere.
  54702. * @param force The force to dispose from the gravitational field event
  54703. */
  54704. dispose(force?: boolean): void;
  54705. private _tick;
  54706. }
  54707. /**
  54708. * Represents a physics updraft event
  54709. */
  54710. class PhysicsUpdraftEvent {
  54711. private _scene;
  54712. private _origin;
  54713. private _options;
  54714. private _physicsEngine;
  54715. private _originTop;
  54716. private _originDirection;
  54717. private _tickCallback;
  54718. private _cylinder;
  54719. private _cylinderPosition;
  54720. private _dataFetched;
  54721. /**
  54722. * Initializes the physics updraft event
  54723. * @param _scene BabylonJS scene
  54724. * @param _origin The origin position of the updraft
  54725. * @param _options The options for the updraft event
  54726. */
  54727. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54728. /**
  54729. * Returns the data related to the updraft event (cylinder).
  54730. * @returns A physics updraft event
  54731. */
  54732. getData(): PhysicsUpdraftEventData;
  54733. /**
  54734. * Enables the updraft.
  54735. */
  54736. enable(): void;
  54737. /**
  54738. * Disables the updraft.
  54739. */
  54740. disable(): void;
  54741. /**
  54742. * Disposes the cylinder.
  54743. * @param force Specifies if the updraft should be disposed by force
  54744. */
  54745. dispose(force?: boolean): void;
  54746. private getImpostorHitData;
  54747. private _tick;
  54748. /*** Helpers ***/
  54749. private _prepareCylinder;
  54750. private _intersectsWithCylinder;
  54751. }
  54752. /**
  54753. * Represents a physics vortex event
  54754. */
  54755. class PhysicsVortexEvent {
  54756. private _scene;
  54757. private _origin;
  54758. private _options;
  54759. private _physicsEngine;
  54760. private _originTop;
  54761. private _tickCallback;
  54762. private _cylinder;
  54763. private _cylinderPosition;
  54764. private _dataFetched;
  54765. /**
  54766. * Initializes the physics vortex event
  54767. * @param _scene The BabylonJS scene
  54768. * @param _origin The origin position of the vortex
  54769. * @param _options The options for the vortex event
  54770. */
  54771. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54772. /**
  54773. * Returns the data related to the vortex event (cylinder).
  54774. * @returns The physics vortex event data
  54775. */
  54776. getData(): PhysicsVortexEventData;
  54777. /**
  54778. * Enables the vortex.
  54779. */
  54780. enable(): void;
  54781. /**
  54782. * Disables the cortex.
  54783. */
  54784. disable(): void;
  54785. /**
  54786. * Disposes the sphere.
  54787. * @param force
  54788. */
  54789. dispose(force?: boolean): void;
  54790. private getImpostorHitData;
  54791. private _tick;
  54792. /*** Helpers ***/
  54793. private _prepareCylinder;
  54794. private _intersectsWithCylinder;
  54795. }
  54796. /**
  54797. * Options fot the radial explosion event
  54798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54799. */
  54800. export class PhysicsRadialExplosionEventOptions {
  54801. /**
  54802. * The radius of the sphere for the radial explosion.
  54803. */
  54804. radius: number;
  54805. /**
  54806. * The strenth of the explosion.
  54807. */
  54808. strength: number;
  54809. /**
  54810. * The strenght of the force in correspondence to the distance of the affected object
  54811. */
  54812. falloff: PhysicsRadialImpulseFalloff;
  54813. /**
  54814. * Sphere options for the radial explosion.
  54815. */
  54816. sphere: {
  54817. segments: number;
  54818. diameter: number;
  54819. };
  54820. /**
  54821. * Sphere options for the radial explosion.
  54822. */
  54823. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54824. }
  54825. /**
  54826. * Options fot the updraft event
  54827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54828. */
  54829. export class PhysicsUpdraftEventOptions {
  54830. /**
  54831. * The radius of the cylinder for the vortex
  54832. */
  54833. radius: number;
  54834. /**
  54835. * The strenth of the updraft.
  54836. */
  54837. strength: number;
  54838. /**
  54839. * The height of the cylinder for the updraft.
  54840. */
  54841. height: number;
  54842. /**
  54843. * The mode for the the updraft.
  54844. */
  54845. updraftMode: PhysicsUpdraftMode;
  54846. }
  54847. /**
  54848. * Options fot the vortex event
  54849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54850. */
  54851. export class PhysicsVortexEventOptions {
  54852. /**
  54853. * The radius of the cylinder for the vortex
  54854. */
  54855. radius: number;
  54856. /**
  54857. * The strenth of the vortex.
  54858. */
  54859. strength: number;
  54860. /**
  54861. * The height of the cylinder for the vortex.
  54862. */
  54863. height: number;
  54864. /**
  54865. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54866. */
  54867. centripetalForceThreshold: number;
  54868. /**
  54869. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54870. */
  54871. centripetalForceMultiplier: number;
  54872. /**
  54873. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54874. */
  54875. centrifugalForceMultiplier: number;
  54876. /**
  54877. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54878. */
  54879. updraftForceMultiplier: number;
  54880. }
  54881. /**
  54882. * The strenght of the force in correspondence to the distance of the affected object
  54883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54884. */
  54885. export enum PhysicsRadialImpulseFalloff {
  54886. /** Defines that impulse is constant in strength across it's whole radius */
  54887. Constant = 0,
  54888. /** Defines that impulse gets weaker if it's further from the origin */
  54889. Linear = 1
  54890. }
  54891. /**
  54892. * The strength of the force in correspondence to the distance of the affected object
  54893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54894. */
  54895. export enum PhysicsUpdraftMode {
  54896. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54897. Center = 0,
  54898. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54899. Perpendicular = 1
  54900. }
  54901. /**
  54902. * Interface for a physics hit data
  54903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54904. */
  54905. export interface PhysicsHitData {
  54906. /**
  54907. * The force applied at the contact point
  54908. */
  54909. force: Vector3;
  54910. /**
  54911. * The contact point
  54912. */
  54913. contactPoint: Vector3;
  54914. /**
  54915. * The distance from the origin to the contact point
  54916. */
  54917. distanceFromOrigin: number;
  54918. }
  54919. /**
  54920. * Interface for radial explosion event data
  54921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54922. */
  54923. export interface PhysicsRadialExplosionEventData {
  54924. /**
  54925. * A sphere used for the radial explosion event
  54926. */
  54927. sphere: Mesh;
  54928. }
  54929. /**
  54930. * Interface for gravitational field event data
  54931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54932. */
  54933. export interface PhysicsGravitationalFieldEventData {
  54934. /**
  54935. * A sphere mesh used for the gravitational field event
  54936. */
  54937. sphere: Mesh;
  54938. }
  54939. /**
  54940. * Interface for updraft event data
  54941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54942. */
  54943. export interface PhysicsUpdraftEventData {
  54944. /**
  54945. * A cylinder used for the updraft event
  54946. */
  54947. cylinder: Mesh;
  54948. }
  54949. /**
  54950. * Interface for vortex event data
  54951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54952. */
  54953. export interface PhysicsVortexEventData {
  54954. /**
  54955. * A cylinder used for the vortex event
  54956. */
  54957. cylinder: Mesh;
  54958. }
  54959. /**
  54960. * Interface for an affected physics impostor
  54961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54962. */
  54963. export interface PhysicsAffectedImpostorWithData {
  54964. /**
  54965. * The impostor affected by the effect
  54966. */
  54967. impostor: PhysicsImpostor;
  54968. /**
  54969. * The data about the hit/horce from the explosion
  54970. */
  54971. hitData: PhysicsHitData;
  54972. }
  54973. }
  54974. declare module BABYLON {
  54975. /** @hidden */
  54976. export var blackAndWhitePixelShader: {
  54977. name: string;
  54978. shader: string;
  54979. };
  54980. }
  54981. declare module BABYLON {
  54982. /**
  54983. * Post process used to render in black and white
  54984. */
  54985. export class BlackAndWhitePostProcess extends PostProcess {
  54986. /**
  54987. * Linear about to convert he result to black and white (default: 1)
  54988. */
  54989. degree: number;
  54990. /**
  54991. * Creates a black and white post process
  54992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54993. * @param name The name of the effect.
  54994. * @param options The required width/height ratio to downsize to before computing the render pass.
  54995. * @param camera The camera to apply the render pass to.
  54996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54997. * @param engine The engine which the post process will be applied. (default: current engine)
  54998. * @param reusable If the post process can be reused on the same frame. (default: false)
  54999. */
  55000. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55001. }
  55002. }
  55003. declare module BABYLON {
  55004. /**
  55005. * This represents a set of one or more post processes in Babylon.
  55006. * A post process can be used to apply a shader to a texture after it is rendered.
  55007. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55008. */
  55009. export class PostProcessRenderEffect {
  55010. private _postProcesses;
  55011. private _getPostProcesses;
  55012. private _singleInstance;
  55013. private _cameras;
  55014. private _indicesForCamera;
  55015. /**
  55016. * Name of the effect
  55017. * @hidden
  55018. */
  55019. _name: string;
  55020. /**
  55021. * Instantiates a post process render effect.
  55022. * A post process can be used to apply a shader to a texture after it is rendered.
  55023. * @param engine The engine the effect is tied to
  55024. * @param name The name of the effect
  55025. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55026. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55027. */
  55028. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55029. /**
  55030. * Checks if all the post processes in the effect are supported.
  55031. */
  55032. readonly isSupported: boolean;
  55033. /**
  55034. * Updates the current state of the effect
  55035. * @hidden
  55036. */
  55037. _update(): void;
  55038. /**
  55039. * Attaches the effect on cameras
  55040. * @param cameras The camera to attach to.
  55041. * @hidden
  55042. */
  55043. _attachCameras(cameras: Camera): void;
  55044. /**
  55045. * Attaches the effect on cameras
  55046. * @param cameras The camera to attach to.
  55047. * @hidden
  55048. */
  55049. _attachCameras(cameras: Camera[]): void;
  55050. /**
  55051. * Detaches the effect on cameras
  55052. * @param cameras The camera to detatch from.
  55053. * @hidden
  55054. */
  55055. _detachCameras(cameras: Camera): void;
  55056. /**
  55057. * Detatches the effect on cameras
  55058. * @param cameras The camera to detatch from.
  55059. * @hidden
  55060. */
  55061. _detachCameras(cameras: Camera[]): void;
  55062. /**
  55063. * Enables the effect on given cameras
  55064. * @param cameras The camera to enable.
  55065. * @hidden
  55066. */
  55067. _enable(cameras: Camera): void;
  55068. /**
  55069. * Enables the effect on given cameras
  55070. * @param cameras The camera to enable.
  55071. * @hidden
  55072. */
  55073. _enable(cameras: Nullable<Camera[]>): void;
  55074. /**
  55075. * Disables the effect on the given cameras
  55076. * @param cameras The camera to disable.
  55077. * @hidden
  55078. */
  55079. _disable(cameras: Camera): void;
  55080. /**
  55081. * Disables the effect on the given cameras
  55082. * @param cameras The camera to disable.
  55083. * @hidden
  55084. */
  55085. _disable(cameras: Nullable<Camera[]>): void;
  55086. /**
  55087. * Gets a list of the post processes contained in the effect.
  55088. * @param camera The camera to get the post processes on.
  55089. * @returns The list of the post processes in the effect.
  55090. */
  55091. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55092. }
  55093. }
  55094. declare module BABYLON {
  55095. /** @hidden */
  55096. export var extractHighlightsPixelShader: {
  55097. name: string;
  55098. shader: string;
  55099. };
  55100. }
  55101. declare module BABYLON {
  55102. /**
  55103. * 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.
  55104. */
  55105. export class ExtractHighlightsPostProcess extends PostProcess {
  55106. /**
  55107. * The luminance threshold, pixels below this value will be set to black.
  55108. */
  55109. threshold: number;
  55110. /** @hidden */
  55111. _exposure: number;
  55112. /**
  55113. * Post process which has the input texture to be used when performing highlight extraction
  55114. * @hidden
  55115. */
  55116. _inputPostProcess: Nullable<PostProcess>;
  55117. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /** @hidden */
  55122. export var bloomMergePixelShader: {
  55123. name: string;
  55124. shader: string;
  55125. };
  55126. }
  55127. declare module BABYLON {
  55128. /**
  55129. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55130. */
  55131. export class BloomMergePostProcess extends PostProcess {
  55132. /** Weight of the bloom to be added to the original input. */
  55133. weight: number;
  55134. /**
  55135. * Creates a new instance of @see BloomMergePostProcess
  55136. * @param name The name of the effect.
  55137. * @param originalFromInput Post process which's input will be used for the merge.
  55138. * @param blurred Blurred highlights post process which's output will be used.
  55139. * @param weight Weight of the bloom to be added to the original input.
  55140. * @param options The required width/height ratio to downsize to before computing the render pass.
  55141. * @param camera The camera to apply the render pass to.
  55142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55143. * @param engine The engine which the post process will be applied. (default: current engine)
  55144. * @param reusable If the post process can be reused on the same frame. (default: false)
  55145. * @param textureType Type of textures used when performing the post process. (default: 0)
  55146. * @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)
  55147. */
  55148. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55149. /** Weight of the bloom to be added to the original input. */
  55150. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55151. }
  55152. }
  55153. declare module BABYLON {
  55154. /**
  55155. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55156. */
  55157. export class BloomEffect extends PostProcessRenderEffect {
  55158. private bloomScale;
  55159. /**
  55160. * @hidden Internal
  55161. */
  55162. _effects: Array<PostProcess>;
  55163. /**
  55164. * @hidden Internal
  55165. */
  55166. _downscale: ExtractHighlightsPostProcess;
  55167. private _blurX;
  55168. private _blurY;
  55169. private _merge;
  55170. /**
  55171. * The luminance threshold to find bright areas of the image to bloom.
  55172. */
  55173. threshold: number;
  55174. /**
  55175. * The strength of the bloom.
  55176. */
  55177. weight: number;
  55178. /**
  55179. * Specifies the size of the bloom blur kernel, relative to the final output size
  55180. */
  55181. kernel: number;
  55182. /**
  55183. * Creates a new instance of @see BloomEffect
  55184. * @param scene The scene the effect belongs to.
  55185. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55186. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55187. * @param bloomWeight The the strength of bloom.
  55188. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55189. * @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)
  55190. */
  55191. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55192. /**
  55193. * Disposes each of the internal effects for a given camera.
  55194. * @param camera The camera to dispose the effect on.
  55195. */
  55196. disposeEffects(camera: Camera): void;
  55197. /**
  55198. * @hidden Internal
  55199. */
  55200. _updateEffects(): void;
  55201. /**
  55202. * Internal
  55203. * @returns if all the contained post processes are ready.
  55204. * @hidden
  55205. */
  55206. _isReady(): boolean;
  55207. }
  55208. }
  55209. declare module BABYLON {
  55210. /** @hidden */
  55211. export var chromaticAberrationPixelShader: {
  55212. name: string;
  55213. shader: string;
  55214. };
  55215. }
  55216. declare module BABYLON {
  55217. /**
  55218. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55219. */
  55220. export class ChromaticAberrationPostProcess extends PostProcess {
  55221. /**
  55222. * The amount of seperation of rgb channels (default: 30)
  55223. */
  55224. aberrationAmount: number;
  55225. /**
  55226. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55227. */
  55228. radialIntensity: number;
  55229. /**
  55230. * 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))
  55231. */
  55232. direction: Vector2;
  55233. /**
  55234. * 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))
  55235. */
  55236. centerPosition: Vector2;
  55237. /**
  55238. * Creates a new instance ChromaticAberrationPostProcess
  55239. * @param name The name of the effect.
  55240. * @param screenWidth The width of the screen to apply the effect on.
  55241. * @param screenHeight The height of the screen to apply the effect on.
  55242. * @param options The required width/height ratio to downsize to before computing the render pass.
  55243. * @param camera The camera to apply the render pass to.
  55244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55245. * @param engine The engine which the post process will be applied. (default: current engine)
  55246. * @param reusable If the post process can be reused on the same frame. (default: false)
  55247. * @param textureType Type of textures used when performing the post process. (default: 0)
  55248. * @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)
  55249. */
  55250. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55251. }
  55252. }
  55253. declare module BABYLON {
  55254. /** @hidden */
  55255. export var circleOfConfusionPixelShader: {
  55256. name: string;
  55257. shader: string;
  55258. };
  55259. }
  55260. declare module BABYLON {
  55261. /**
  55262. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55263. */
  55264. export class CircleOfConfusionPostProcess extends PostProcess {
  55265. /**
  55266. * 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.
  55267. */
  55268. lensSize: number;
  55269. /**
  55270. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55271. */
  55272. fStop: number;
  55273. /**
  55274. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55275. */
  55276. focusDistance: number;
  55277. /**
  55278. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55279. */
  55280. focalLength: number;
  55281. private _depthTexture;
  55282. /**
  55283. * Creates a new instance CircleOfConfusionPostProcess
  55284. * @param name The name of the effect.
  55285. * @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.
  55286. * @param options The required width/height ratio to downsize to before computing the render pass.
  55287. * @param camera The camera to apply the render pass to.
  55288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55289. * @param engine The engine which the post process will be applied. (default: current engine)
  55290. * @param reusable If the post process can be reused on the same frame. (default: false)
  55291. * @param textureType Type of textures used when performing the post process. (default: 0)
  55292. * @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)
  55293. */
  55294. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55295. /**
  55296. * 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.
  55297. */
  55298. depthTexture: RenderTargetTexture;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /** @hidden */
  55303. export var colorCorrectionPixelShader: {
  55304. name: string;
  55305. shader: string;
  55306. };
  55307. }
  55308. declare module BABYLON {
  55309. /**
  55310. *
  55311. * This post-process allows the modification of rendered colors by using
  55312. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55313. *
  55314. * The object needs to be provided an url to a texture containing the color
  55315. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55316. * Use an image editing software to tweak the LUT to match your needs.
  55317. *
  55318. * For an example of a color LUT, see here:
  55319. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55320. * For explanations on color grading, see here:
  55321. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55322. *
  55323. */
  55324. export class ColorCorrectionPostProcess extends PostProcess {
  55325. private _colorTableTexture;
  55326. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55327. }
  55328. }
  55329. declare module BABYLON {
  55330. /** @hidden */
  55331. export var convolutionPixelShader: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module BABYLON {
  55337. /**
  55338. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55339. * input texture to perform effects such as edge detection or sharpening
  55340. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55341. */
  55342. export class ConvolutionPostProcess extends PostProcess {
  55343. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55344. kernel: number[];
  55345. /**
  55346. * Creates a new instance ConvolutionPostProcess
  55347. * @param name The name of the effect.
  55348. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55349. * @param options The required width/height ratio to downsize to before computing the render pass.
  55350. * @param camera The camera to apply the render pass to.
  55351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55352. * @param engine The engine which the post process will be applied. (default: current engine)
  55353. * @param reusable If the post process can be reused on the same frame. (default: false)
  55354. * @param textureType Type of textures used when performing the post process. (default: 0)
  55355. */
  55356. constructor(name: string,
  55357. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55358. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55359. /**
  55360. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55361. */
  55362. static EdgeDetect0Kernel: number[];
  55363. /**
  55364. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55365. */
  55366. static EdgeDetect1Kernel: number[];
  55367. /**
  55368. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55369. */
  55370. static EdgeDetect2Kernel: number[];
  55371. /**
  55372. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55373. */
  55374. static SharpenKernel: number[];
  55375. /**
  55376. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55377. */
  55378. static EmbossKernel: number[];
  55379. /**
  55380. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55381. */
  55382. static GaussianKernel: number[];
  55383. }
  55384. }
  55385. declare module BABYLON {
  55386. /**
  55387. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55388. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55389. * based on samples that have a large difference in distance than the center pixel.
  55390. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55391. */
  55392. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55393. direction: Vector2;
  55394. /**
  55395. * Creates a new instance CircleOfConfusionPostProcess
  55396. * @param name The name of the effect.
  55397. * @param scene The scene the effect belongs to.
  55398. * @param direction The direction the blur should be applied.
  55399. * @param kernel The size of the kernel used to blur.
  55400. * @param options The required width/height ratio to downsize to before computing the render pass.
  55401. * @param camera The camera to apply the render pass to.
  55402. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55403. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55405. * @param engine The engine which the post process will be applied. (default: current engine)
  55406. * @param reusable If the post process can be reused on the same frame. (default: false)
  55407. * @param textureType Type of textures used when performing the post process. (default: 0)
  55408. * @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)
  55409. */
  55410. 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);
  55411. }
  55412. }
  55413. declare module BABYLON {
  55414. /** @hidden */
  55415. export var depthOfFieldMergePixelShader: {
  55416. name: string;
  55417. shader: string;
  55418. };
  55419. }
  55420. declare module BABYLON {
  55421. /**
  55422. * Options to be set when merging outputs from the default pipeline.
  55423. */
  55424. export class DepthOfFieldMergePostProcessOptions {
  55425. /**
  55426. * The original image to merge on top of
  55427. */
  55428. originalFromInput: PostProcess;
  55429. /**
  55430. * Parameters to perform the merge of the depth of field effect
  55431. */
  55432. depthOfField?: {
  55433. circleOfConfusion: PostProcess;
  55434. blurSteps: Array<PostProcess>;
  55435. };
  55436. /**
  55437. * Parameters to perform the merge of bloom effect
  55438. */
  55439. bloom?: {
  55440. blurred: PostProcess;
  55441. weight: number;
  55442. };
  55443. }
  55444. /**
  55445. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55446. */
  55447. export class DepthOfFieldMergePostProcess extends PostProcess {
  55448. private blurSteps;
  55449. /**
  55450. * Creates a new instance of DepthOfFieldMergePostProcess
  55451. * @param name The name of the effect.
  55452. * @param originalFromInput Post process which's input will be used for the merge.
  55453. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55454. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55455. * @param options The required width/height ratio to downsize to before computing the render pass.
  55456. * @param camera The camera to apply the render pass to.
  55457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55458. * @param engine The engine which the post process will be applied. (default: current engine)
  55459. * @param reusable If the post process can be reused on the same frame. (default: false)
  55460. * @param textureType Type of textures used when performing the post process. (default: 0)
  55461. * @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)
  55462. */
  55463. 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);
  55464. /**
  55465. * Updates the effect with the current post process compile time values and recompiles the shader.
  55466. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55467. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55468. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55469. * @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
  55470. * @param onCompiled Called when the shader has been compiled.
  55471. * @param onError Called if there is an error when compiling a shader.
  55472. */
  55473. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55474. }
  55475. }
  55476. declare module BABYLON {
  55477. /**
  55478. * Specifies the level of max blur that should be applied when using the depth of field effect
  55479. */
  55480. export enum DepthOfFieldEffectBlurLevel {
  55481. /**
  55482. * Subtle blur
  55483. */
  55484. Low = 0,
  55485. /**
  55486. * Medium blur
  55487. */
  55488. Medium = 1,
  55489. /**
  55490. * Large blur
  55491. */
  55492. High = 2
  55493. }
  55494. /**
  55495. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55496. */
  55497. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55498. private _circleOfConfusion;
  55499. /**
  55500. * @hidden Internal, blurs from high to low
  55501. */
  55502. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55503. private _depthOfFieldBlurY;
  55504. private _dofMerge;
  55505. /**
  55506. * @hidden Internal post processes in depth of field effect
  55507. */
  55508. _effects: Array<PostProcess>;
  55509. /**
  55510. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55511. */
  55512. focalLength: number;
  55513. /**
  55514. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55515. */
  55516. fStop: number;
  55517. /**
  55518. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55519. */
  55520. focusDistance: number;
  55521. /**
  55522. * 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.
  55523. */
  55524. lensSize: number;
  55525. /**
  55526. * Creates a new instance DepthOfFieldEffect
  55527. * @param scene The scene the effect belongs to.
  55528. * @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.
  55529. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55530. * @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)
  55531. */
  55532. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55533. /**
  55534. * Get the current class name of the current effet
  55535. * @returns "DepthOfFieldEffect"
  55536. */
  55537. getClassName(): string;
  55538. /**
  55539. * 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.
  55540. */
  55541. depthTexture: RenderTargetTexture;
  55542. /**
  55543. * Disposes each of the internal effects for a given camera.
  55544. * @param camera The camera to dispose the effect on.
  55545. */
  55546. disposeEffects(camera: Camera): void;
  55547. /**
  55548. * @hidden Internal
  55549. */
  55550. _updateEffects(): void;
  55551. /**
  55552. * Internal
  55553. * @returns if all the contained post processes are ready.
  55554. * @hidden
  55555. */
  55556. _isReady(): boolean;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /** @hidden */
  55561. export var displayPassPixelShader: {
  55562. name: string;
  55563. shader: string;
  55564. };
  55565. }
  55566. declare module BABYLON {
  55567. /**
  55568. * DisplayPassPostProcess which produces an output the same as it's input
  55569. */
  55570. export class DisplayPassPostProcess extends PostProcess {
  55571. /**
  55572. * Creates the DisplayPassPostProcess
  55573. * @param name The name of the effect.
  55574. * @param options The required width/height ratio to downsize to before computing the render pass.
  55575. * @param camera The camera to apply the render pass to.
  55576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55577. * @param engine The engine which the post process will be applied. (default: current engine)
  55578. * @param reusable If the post process can be reused on the same frame. (default: false)
  55579. */
  55580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55581. }
  55582. }
  55583. declare module BABYLON {
  55584. /** @hidden */
  55585. export var filterPixelShader: {
  55586. name: string;
  55587. shader: string;
  55588. };
  55589. }
  55590. declare module BABYLON {
  55591. /**
  55592. * Applies a kernel filter to the image
  55593. */
  55594. export class FilterPostProcess extends PostProcess {
  55595. /** The matrix to be applied to the image */
  55596. kernelMatrix: Matrix;
  55597. /**
  55598. *
  55599. * @param name The name of the effect.
  55600. * @param kernelMatrix The matrix to be applied to the image
  55601. * @param options The required width/height ratio to downsize to before computing the render pass.
  55602. * @param camera The camera to apply the render pass to.
  55603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55604. * @param engine The engine which the post process will be applied. (default: current engine)
  55605. * @param reusable If the post process can be reused on the same frame. (default: false)
  55606. */
  55607. constructor(name: string,
  55608. /** The matrix to be applied to the image */
  55609. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55610. }
  55611. }
  55612. declare module BABYLON {
  55613. /** @hidden */
  55614. export var fxaaPixelShader: {
  55615. name: string;
  55616. shader: string;
  55617. };
  55618. }
  55619. declare module BABYLON {
  55620. /** @hidden */
  55621. export var fxaaVertexShader: {
  55622. name: string;
  55623. shader: string;
  55624. };
  55625. }
  55626. declare module BABYLON {
  55627. /**
  55628. * Fxaa post process
  55629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55630. */
  55631. export class FxaaPostProcess extends PostProcess {
  55632. /** @hidden */
  55633. texelWidth: number;
  55634. /** @hidden */
  55635. texelHeight: number;
  55636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55637. private _getDefines;
  55638. }
  55639. }
  55640. declare module BABYLON {
  55641. /** @hidden */
  55642. export var grainPixelShader: {
  55643. name: string;
  55644. shader: string;
  55645. };
  55646. }
  55647. declare module BABYLON {
  55648. /**
  55649. * The GrainPostProcess adds noise to the image at mid luminance levels
  55650. */
  55651. export class GrainPostProcess extends PostProcess {
  55652. /**
  55653. * The intensity of the grain added (default: 30)
  55654. */
  55655. intensity: number;
  55656. /**
  55657. * If the grain should be randomized on every frame
  55658. */
  55659. animated: boolean;
  55660. /**
  55661. * Creates a new instance of @see GrainPostProcess
  55662. * @param name The name of the effect.
  55663. * @param options The required width/height ratio to downsize to before computing the render pass.
  55664. * @param camera The camera to apply the render pass to.
  55665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55666. * @param engine The engine which the post process will be applied. (default: current engine)
  55667. * @param reusable If the post process can be reused on the same frame. (default: false)
  55668. * @param textureType Type of textures used when performing the post process. (default: 0)
  55669. * @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)
  55670. */
  55671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55672. }
  55673. }
  55674. declare module BABYLON {
  55675. /** @hidden */
  55676. export var highlightsPixelShader: {
  55677. name: string;
  55678. shader: string;
  55679. };
  55680. }
  55681. declare module BABYLON {
  55682. /**
  55683. * Extracts highlights from the image
  55684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55685. */
  55686. export class HighlightsPostProcess extends PostProcess {
  55687. /**
  55688. * Extracts highlights from the image
  55689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55690. * @param name The name of the effect.
  55691. * @param options The required width/height ratio to downsize to before computing the render pass.
  55692. * @param camera The camera to apply the render pass to.
  55693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55694. * @param engine The engine which the post process will be applied. (default: current engine)
  55695. * @param reusable If the post process can be reused on the same frame. (default: false)
  55696. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55697. */
  55698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55699. }
  55700. }
  55701. declare module BABYLON {
  55702. /** @hidden */
  55703. export var mrtFragmentDeclaration: {
  55704. name: string;
  55705. shader: string;
  55706. };
  55707. }
  55708. declare module BABYLON {
  55709. /** @hidden */
  55710. export var geometryPixelShader: {
  55711. name: string;
  55712. shader: string;
  55713. };
  55714. }
  55715. declare module BABYLON {
  55716. /** @hidden */
  55717. export var geometryVertexShader: {
  55718. name: string;
  55719. shader: string;
  55720. };
  55721. }
  55722. declare module BABYLON {
  55723. /** @hidden */
  55724. interface ISavedTransformationMatrix {
  55725. world: Matrix;
  55726. viewProjection: Matrix;
  55727. }
  55728. /**
  55729. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55730. */
  55731. export class GeometryBufferRenderer {
  55732. /**
  55733. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55734. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55735. */
  55736. static readonly POSITION_TEXTURE_TYPE: number;
  55737. /**
  55738. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55739. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55740. */
  55741. static readonly VELOCITY_TEXTURE_TYPE: number;
  55742. /**
  55743. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55744. * in order to compute objects velocities when enableVelocity is set to "true"
  55745. * @hidden
  55746. */
  55747. _previousTransformationMatrices: {
  55748. [index: number]: ISavedTransformationMatrix;
  55749. };
  55750. /**
  55751. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55752. * in order to compute objects velocities when enableVelocity is set to "true"
  55753. * @hidden
  55754. */
  55755. _previousBonesTransformationMatrices: {
  55756. [index: number]: Float32Array;
  55757. };
  55758. /**
  55759. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55760. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55761. */
  55762. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55763. private _scene;
  55764. private _multiRenderTarget;
  55765. private _ratio;
  55766. private _enablePosition;
  55767. private _enableVelocity;
  55768. private _positionIndex;
  55769. private _velocityIndex;
  55770. protected _effect: Effect;
  55771. protected _cachedDefines: string;
  55772. /**
  55773. * Set the render list (meshes to be rendered) used in the G buffer.
  55774. */
  55775. renderList: Mesh[];
  55776. /**
  55777. * Gets wether or not G buffer are supported by the running hardware.
  55778. * This requires draw buffer supports
  55779. */
  55780. readonly isSupported: boolean;
  55781. /**
  55782. * Returns the index of the given texture type in the G-Buffer textures array
  55783. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55784. * @returns the index of the given texture type in the G-Buffer textures array
  55785. */
  55786. getTextureIndex(textureType: number): number;
  55787. /**
  55788. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55789. */
  55790. /**
  55791. * Sets whether or not objects positions are enabled for the G buffer.
  55792. */
  55793. enablePosition: boolean;
  55794. /**
  55795. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55796. */
  55797. /**
  55798. * Sets wether or not objects velocities are enabled for the G buffer.
  55799. */
  55800. enableVelocity: boolean;
  55801. /**
  55802. * Gets the scene associated with the buffer.
  55803. */
  55804. readonly scene: Scene;
  55805. /**
  55806. * Gets the ratio used by the buffer during its creation.
  55807. * How big is the buffer related to the main canvas.
  55808. */
  55809. readonly ratio: number;
  55810. /** @hidden */
  55811. static _SceneComponentInitialization: (scene: Scene) => void;
  55812. /**
  55813. * Creates a new G Buffer for the scene
  55814. * @param scene The scene the buffer belongs to
  55815. * @param ratio How big is the buffer related to the main canvas.
  55816. */
  55817. constructor(scene: Scene, ratio?: number);
  55818. /**
  55819. * Checks wether everything is ready to render a submesh to the G buffer.
  55820. * @param subMesh the submesh to check readiness for
  55821. * @param useInstances is the mesh drawn using instance or not
  55822. * @returns true if ready otherwise false
  55823. */
  55824. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55825. /**
  55826. * Gets the current underlying G Buffer.
  55827. * @returns the buffer
  55828. */
  55829. getGBuffer(): MultiRenderTarget;
  55830. /**
  55831. * Gets the number of samples used to render the buffer (anti aliasing).
  55832. */
  55833. /**
  55834. * Sets the number of samples used to render the buffer (anti aliasing).
  55835. */
  55836. samples: number;
  55837. /**
  55838. * Disposes the renderer and frees up associated resources.
  55839. */
  55840. dispose(): void;
  55841. protected _createRenderTargets(): void;
  55842. private _copyBonesTransformationMatrices;
  55843. }
  55844. }
  55845. declare module BABYLON {
  55846. interface Scene {
  55847. /** @hidden (Backing field) */
  55848. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55849. /**
  55850. * Gets or Sets the current geometry buffer associated to the scene.
  55851. */
  55852. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55853. /**
  55854. * Enables a GeometryBufferRender and associates it with the scene
  55855. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55856. * @returns the GeometryBufferRenderer
  55857. */
  55858. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55859. /**
  55860. * Disables the GeometryBufferRender associated with the scene
  55861. */
  55862. disableGeometryBufferRenderer(): void;
  55863. }
  55864. /**
  55865. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55866. * in several rendering techniques.
  55867. */
  55868. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55869. /**
  55870. * The component name helpful to identify the component in the list of scene components.
  55871. */
  55872. readonly name: string;
  55873. /**
  55874. * The scene the component belongs to.
  55875. */
  55876. scene: Scene;
  55877. /**
  55878. * Creates a new instance of the component for the given scene
  55879. * @param scene Defines the scene to register the component in
  55880. */
  55881. constructor(scene: Scene);
  55882. /**
  55883. * Registers the component in a given scene
  55884. */
  55885. register(): void;
  55886. /**
  55887. * Rebuilds the elements related to this component in case of
  55888. * context lost for instance.
  55889. */
  55890. rebuild(): void;
  55891. /**
  55892. * Disposes the component and the associated ressources
  55893. */
  55894. dispose(): void;
  55895. private _gatherRenderTargets;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /** @hidden */
  55900. export var motionBlurPixelShader: {
  55901. name: string;
  55902. shader: string;
  55903. };
  55904. }
  55905. declare module BABYLON {
  55906. /**
  55907. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55908. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55909. * As an example, all you have to do is to create the post-process:
  55910. * var mb = new BABYLON.MotionBlurPostProcess(
  55911. * 'mb', // The name of the effect.
  55912. * scene, // The scene containing the objects to blur according to their velocity.
  55913. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55914. * camera // The camera to apply the render pass to.
  55915. * );
  55916. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55917. */
  55918. export class MotionBlurPostProcess extends PostProcess {
  55919. /**
  55920. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55921. */
  55922. motionStrength: number;
  55923. /**
  55924. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55925. */
  55926. /**
  55927. * Sets the number of iterations to be used for motion blur quality
  55928. */
  55929. motionBlurSamples: number;
  55930. private _motionBlurSamples;
  55931. private _geometryBufferRenderer;
  55932. /**
  55933. * Creates a new instance MotionBlurPostProcess
  55934. * @param name The name of the effect.
  55935. * @param scene The scene containing the objects to blur according to their velocity.
  55936. * @param options The required width/height ratio to downsize to before computing the render pass.
  55937. * @param camera The camera to apply the render pass to.
  55938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55939. * @param engine The engine which the post process will be applied. (default: current engine)
  55940. * @param reusable If the post process can be reused on the same frame. (default: false)
  55941. * @param textureType Type of textures used when performing the post process. (default: 0)
  55942. * @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)
  55943. */
  55944. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55945. /**
  55946. * Excludes the given skinned mesh from computing bones velocities.
  55947. * 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.
  55948. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55949. */
  55950. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55951. /**
  55952. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55953. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55954. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55955. */
  55956. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55957. /**
  55958. * Disposes the post process.
  55959. * @param camera The camera to dispose the post process on.
  55960. */
  55961. dispose(camera?: Camera): void;
  55962. }
  55963. }
  55964. declare module BABYLON {
  55965. /** @hidden */
  55966. export var refractionPixelShader: {
  55967. name: string;
  55968. shader: string;
  55969. };
  55970. }
  55971. declare module BABYLON {
  55972. /**
  55973. * Post process which applies a refractin texture
  55974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55975. */
  55976. export class RefractionPostProcess extends PostProcess {
  55977. /** the base color of the refraction (used to taint the rendering) */
  55978. color: Color3;
  55979. /** simulated refraction depth */
  55980. depth: number;
  55981. /** the coefficient of the base color (0 to remove base color tainting) */
  55982. colorLevel: number;
  55983. private _refTexture;
  55984. private _ownRefractionTexture;
  55985. /**
  55986. * Gets or sets the refraction texture
  55987. * Please note that you are responsible for disposing the texture if you set it manually
  55988. */
  55989. refractionTexture: Texture;
  55990. /**
  55991. * Initializes the RefractionPostProcess
  55992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55993. * @param name The name of the effect.
  55994. * @param refractionTextureUrl Url of the refraction texture to use
  55995. * @param color the base color of the refraction (used to taint the rendering)
  55996. * @param depth simulated refraction depth
  55997. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55998. * @param camera The camera to apply the render pass to.
  55999. * @param options The required width/height ratio to downsize to before computing the render pass.
  56000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56001. * @param engine The engine which the post process will be applied. (default: current engine)
  56002. * @param reusable If the post process can be reused on the same frame. (default: false)
  56003. */
  56004. constructor(name: string, refractionTextureUrl: string,
  56005. /** the base color of the refraction (used to taint the rendering) */
  56006. color: Color3,
  56007. /** simulated refraction depth */
  56008. depth: number,
  56009. /** the coefficient of the base color (0 to remove base color tainting) */
  56010. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56011. /**
  56012. * Disposes of the post process
  56013. * @param camera Camera to dispose post process on
  56014. */
  56015. dispose(camera: Camera): void;
  56016. }
  56017. }
  56018. declare module BABYLON {
  56019. /** @hidden */
  56020. export var sharpenPixelShader: {
  56021. name: string;
  56022. shader: string;
  56023. };
  56024. }
  56025. declare module BABYLON {
  56026. /**
  56027. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56028. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56029. */
  56030. export class SharpenPostProcess extends PostProcess {
  56031. /**
  56032. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56033. */
  56034. colorAmount: number;
  56035. /**
  56036. * How much sharpness should be applied (default: 0.3)
  56037. */
  56038. edgeAmount: number;
  56039. /**
  56040. * Creates a new instance ConvolutionPostProcess
  56041. * @param name The name of the effect.
  56042. * @param options The required width/height ratio to downsize to before computing the render pass.
  56043. * @param camera The camera to apply the render pass to.
  56044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56045. * @param engine The engine which the post process will be applied. (default: current engine)
  56046. * @param reusable If the post process can be reused on the same frame. (default: false)
  56047. * @param textureType Type of textures used when performing the post process. (default: 0)
  56048. * @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)
  56049. */
  56050. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * PostProcessRenderPipeline
  56056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56057. */
  56058. export class PostProcessRenderPipeline {
  56059. private engine;
  56060. private _renderEffects;
  56061. private _renderEffectsForIsolatedPass;
  56062. /**
  56063. * List of inspectable custom properties (used by the Inspector)
  56064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56065. */
  56066. inspectableCustomProperties: IInspectable[];
  56067. /**
  56068. * @hidden
  56069. */
  56070. protected _cameras: Camera[];
  56071. /** @hidden */
  56072. _name: string;
  56073. /**
  56074. * Gets pipeline name
  56075. */
  56076. readonly name: string;
  56077. /**
  56078. * Initializes a PostProcessRenderPipeline
  56079. * @param engine engine to add the pipeline to
  56080. * @param name name of the pipeline
  56081. */
  56082. constructor(engine: Engine, name: string);
  56083. /**
  56084. * Gets the class name
  56085. * @returns "PostProcessRenderPipeline"
  56086. */
  56087. getClassName(): string;
  56088. /**
  56089. * If all the render effects in the pipeline are supported
  56090. */
  56091. readonly isSupported: boolean;
  56092. /**
  56093. * Adds an effect to the pipeline
  56094. * @param renderEffect the effect to add
  56095. */
  56096. addEffect(renderEffect: PostProcessRenderEffect): void;
  56097. /** @hidden */
  56098. _rebuild(): void;
  56099. /** @hidden */
  56100. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56101. /** @hidden */
  56102. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56103. /** @hidden */
  56104. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56105. /** @hidden */
  56106. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56107. /** @hidden */
  56108. _attachCameras(cameras: Camera, unique: boolean): void;
  56109. /** @hidden */
  56110. _attachCameras(cameras: Camera[], unique: boolean): void;
  56111. /** @hidden */
  56112. _detachCameras(cameras: Camera): void;
  56113. /** @hidden */
  56114. _detachCameras(cameras: Nullable<Camera[]>): void;
  56115. /** @hidden */
  56116. _update(): void;
  56117. /** @hidden */
  56118. _reset(): void;
  56119. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56120. /**
  56121. * Disposes of the pipeline
  56122. */
  56123. dispose(): void;
  56124. }
  56125. }
  56126. declare module BABYLON {
  56127. /**
  56128. * PostProcessRenderPipelineManager class
  56129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56130. */
  56131. export class PostProcessRenderPipelineManager {
  56132. private _renderPipelines;
  56133. /**
  56134. * Initializes a PostProcessRenderPipelineManager
  56135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56136. */
  56137. constructor();
  56138. /**
  56139. * Gets the list of supported render pipelines
  56140. */
  56141. readonly supportedPipelines: PostProcessRenderPipeline[];
  56142. /**
  56143. * Adds a pipeline to the manager
  56144. * @param renderPipeline The pipeline to add
  56145. */
  56146. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56147. /**
  56148. * Attaches a camera to the pipeline
  56149. * @param renderPipelineName The name of the pipeline to attach to
  56150. * @param cameras the camera to attach
  56151. * @param unique if the camera can be attached multiple times to the pipeline
  56152. */
  56153. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56154. /**
  56155. * Detaches a camera from the pipeline
  56156. * @param renderPipelineName The name of the pipeline to detach from
  56157. * @param cameras the camera to detach
  56158. */
  56159. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56160. /**
  56161. * Enables an effect by name on a pipeline
  56162. * @param renderPipelineName the name of the pipeline to enable the effect in
  56163. * @param renderEffectName the name of the effect to enable
  56164. * @param cameras the cameras that the effect should be enabled on
  56165. */
  56166. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56167. /**
  56168. * Disables an effect by name on a pipeline
  56169. * @param renderPipelineName the name of the pipeline to disable the effect in
  56170. * @param renderEffectName the name of the effect to disable
  56171. * @param cameras the cameras that the effect should be disabled on
  56172. */
  56173. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56174. /**
  56175. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56176. */
  56177. update(): void;
  56178. /** @hidden */
  56179. _rebuild(): void;
  56180. /**
  56181. * Disposes of the manager and pipelines
  56182. */
  56183. dispose(): void;
  56184. }
  56185. }
  56186. declare module BABYLON {
  56187. interface Scene {
  56188. /** @hidden (Backing field) */
  56189. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56190. /**
  56191. * Gets the postprocess render pipeline manager
  56192. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56193. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56194. */
  56195. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56196. }
  56197. /**
  56198. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56199. */
  56200. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56201. /**
  56202. * The component name helpfull to identify the component in the list of scene components.
  56203. */
  56204. readonly name: string;
  56205. /**
  56206. * The scene the component belongs to.
  56207. */
  56208. scene: Scene;
  56209. /**
  56210. * Creates a new instance of the component for the given scene
  56211. * @param scene Defines the scene to register the component in
  56212. */
  56213. constructor(scene: Scene);
  56214. /**
  56215. * Registers the component in a given scene
  56216. */
  56217. register(): void;
  56218. /**
  56219. * Rebuilds the elements related to this component in case of
  56220. * context lost for instance.
  56221. */
  56222. rebuild(): void;
  56223. /**
  56224. * Disposes the component and the associated ressources
  56225. */
  56226. dispose(): void;
  56227. private _gatherRenderTargets;
  56228. }
  56229. }
  56230. declare module BABYLON {
  56231. /**
  56232. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56233. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56234. */
  56235. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56236. private _scene;
  56237. private _camerasToBeAttached;
  56238. /**
  56239. * ID of the sharpen post process,
  56240. */
  56241. private readonly SharpenPostProcessId;
  56242. /**
  56243. * @ignore
  56244. * ID of the image processing post process;
  56245. */
  56246. readonly ImageProcessingPostProcessId: string;
  56247. /**
  56248. * @ignore
  56249. * ID of the Fast Approximate Anti-Aliasing post process;
  56250. */
  56251. readonly FxaaPostProcessId: string;
  56252. /**
  56253. * ID of the chromatic aberration post process,
  56254. */
  56255. private readonly ChromaticAberrationPostProcessId;
  56256. /**
  56257. * ID of the grain post process
  56258. */
  56259. private readonly GrainPostProcessId;
  56260. /**
  56261. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56262. */
  56263. sharpen: SharpenPostProcess;
  56264. private _sharpenEffect;
  56265. private bloom;
  56266. /**
  56267. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56268. */
  56269. depthOfField: DepthOfFieldEffect;
  56270. /**
  56271. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56272. */
  56273. fxaa: FxaaPostProcess;
  56274. /**
  56275. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56276. */
  56277. imageProcessing: ImageProcessingPostProcess;
  56278. /**
  56279. * Chromatic aberration post process which will shift rgb colors in the image
  56280. */
  56281. chromaticAberration: ChromaticAberrationPostProcess;
  56282. private _chromaticAberrationEffect;
  56283. /**
  56284. * Grain post process which add noise to the image
  56285. */
  56286. grain: GrainPostProcess;
  56287. private _grainEffect;
  56288. /**
  56289. * Glow post process which adds a glow to emissive areas of the image
  56290. */
  56291. private _glowLayer;
  56292. /**
  56293. * Animations which can be used to tweak settings over a period of time
  56294. */
  56295. animations: Animation[];
  56296. private _imageProcessingConfigurationObserver;
  56297. private _sharpenEnabled;
  56298. private _bloomEnabled;
  56299. private _depthOfFieldEnabled;
  56300. private _depthOfFieldBlurLevel;
  56301. private _fxaaEnabled;
  56302. private _imageProcessingEnabled;
  56303. private _defaultPipelineTextureType;
  56304. private _bloomScale;
  56305. private _chromaticAberrationEnabled;
  56306. private _grainEnabled;
  56307. private _buildAllowed;
  56308. /**
  56309. * Gets active scene
  56310. */
  56311. readonly scene: Scene;
  56312. /**
  56313. * Enable or disable the sharpen process from the pipeline
  56314. */
  56315. sharpenEnabled: boolean;
  56316. private _resizeObserver;
  56317. private _hardwareScaleLevel;
  56318. private _bloomKernel;
  56319. /**
  56320. * Specifies the size of the bloom blur kernel, relative to the final output size
  56321. */
  56322. bloomKernel: number;
  56323. /**
  56324. * Specifies the weight of the bloom in the final rendering
  56325. */
  56326. private _bloomWeight;
  56327. /**
  56328. * Specifies the luma threshold for the area that will be blurred by the bloom
  56329. */
  56330. private _bloomThreshold;
  56331. private _hdr;
  56332. /**
  56333. * The strength of the bloom.
  56334. */
  56335. bloomWeight: number;
  56336. /**
  56337. * The strength of the bloom.
  56338. */
  56339. bloomThreshold: number;
  56340. /**
  56341. * The scale of the bloom, lower value will provide better performance.
  56342. */
  56343. bloomScale: number;
  56344. /**
  56345. * Enable or disable the bloom from the pipeline
  56346. */
  56347. bloomEnabled: boolean;
  56348. private _rebuildBloom;
  56349. /**
  56350. * If the depth of field is enabled.
  56351. */
  56352. depthOfFieldEnabled: boolean;
  56353. /**
  56354. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56355. */
  56356. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56357. /**
  56358. * If the anti aliasing is enabled.
  56359. */
  56360. fxaaEnabled: boolean;
  56361. private _samples;
  56362. /**
  56363. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56364. */
  56365. samples: number;
  56366. /**
  56367. * If image processing is enabled.
  56368. */
  56369. imageProcessingEnabled: boolean;
  56370. /**
  56371. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56372. */
  56373. glowLayerEnabled: boolean;
  56374. /**
  56375. * Gets the glow layer (or null if not defined)
  56376. */
  56377. readonly glowLayer: Nullable<GlowLayer>;
  56378. /**
  56379. * Enable or disable the chromaticAberration process from the pipeline
  56380. */
  56381. chromaticAberrationEnabled: boolean;
  56382. /**
  56383. * Enable or disable the grain process from the pipeline
  56384. */
  56385. grainEnabled: boolean;
  56386. /**
  56387. * @constructor
  56388. * @param name - The rendering pipeline name (default: "")
  56389. * @param hdr - If high dynamic range textures should be used (default: true)
  56390. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56391. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56392. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56393. */
  56394. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56395. /**
  56396. * Get the class name
  56397. * @returns "DefaultRenderingPipeline"
  56398. */
  56399. getClassName(): string;
  56400. /**
  56401. * Force the compilation of the entire pipeline.
  56402. */
  56403. prepare(): void;
  56404. private _hasCleared;
  56405. private _prevPostProcess;
  56406. private _prevPrevPostProcess;
  56407. private _setAutoClearAndTextureSharing;
  56408. private _depthOfFieldSceneObserver;
  56409. private _buildPipeline;
  56410. private _disposePostProcesses;
  56411. /**
  56412. * Adds a camera to the pipeline
  56413. * @param camera the camera to be added
  56414. */
  56415. addCamera(camera: Camera): void;
  56416. /**
  56417. * Removes a camera from the pipeline
  56418. * @param camera the camera to remove
  56419. */
  56420. removeCamera(camera: Camera): void;
  56421. /**
  56422. * Dispose of the pipeline and stop all post processes
  56423. */
  56424. dispose(): void;
  56425. /**
  56426. * Serialize the rendering pipeline (Used when exporting)
  56427. * @returns the serialized object
  56428. */
  56429. serialize(): any;
  56430. /**
  56431. * Parse the serialized pipeline
  56432. * @param source Source pipeline.
  56433. * @param scene The scene to load the pipeline to.
  56434. * @param rootUrl The URL of the serialized pipeline.
  56435. * @returns An instantiated pipeline from the serialized object.
  56436. */
  56437. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56438. }
  56439. }
  56440. declare module BABYLON {
  56441. /** @hidden */
  56442. export var lensHighlightsPixelShader: {
  56443. name: string;
  56444. shader: string;
  56445. };
  56446. }
  56447. declare module BABYLON {
  56448. /** @hidden */
  56449. export var depthOfFieldPixelShader: {
  56450. name: string;
  56451. shader: string;
  56452. };
  56453. }
  56454. declare module BABYLON {
  56455. /**
  56456. * BABYLON.JS Chromatic Aberration GLSL Shader
  56457. * Author: Olivier Guyot
  56458. * Separates very slightly R, G and B colors on the edges of the screen
  56459. * Inspired by Francois Tarlier & Martins Upitis
  56460. */
  56461. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56462. /**
  56463. * @ignore
  56464. * The chromatic aberration PostProcess id in the pipeline
  56465. */
  56466. LensChromaticAberrationEffect: string;
  56467. /**
  56468. * @ignore
  56469. * The highlights enhancing PostProcess id in the pipeline
  56470. */
  56471. HighlightsEnhancingEffect: string;
  56472. /**
  56473. * @ignore
  56474. * The depth-of-field PostProcess id in the pipeline
  56475. */
  56476. LensDepthOfFieldEffect: string;
  56477. private _scene;
  56478. private _depthTexture;
  56479. private _grainTexture;
  56480. private _chromaticAberrationPostProcess;
  56481. private _highlightsPostProcess;
  56482. private _depthOfFieldPostProcess;
  56483. private _edgeBlur;
  56484. private _grainAmount;
  56485. private _chromaticAberration;
  56486. private _distortion;
  56487. private _highlightsGain;
  56488. private _highlightsThreshold;
  56489. private _dofDistance;
  56490. private _dofAperture;
  56491. private _dofDarken;
  56492. private _dofPentagon;
  56493. private _blurNoise;
  56494. /**
  56495. * @constructor
  56496. *
  56497. * Effect parameters are as follow:
  56498. * {
  56499. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56500. * edge_blur: number; // from 0 to x (1 for realism)
  56501. * distortion: number; // from 0 to x (1 for realism)
  56502. * grain_amount: number; // from 0 to 1
  56503. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56504. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56505. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56506. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56507. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56508. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56509. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56510. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56511. * }
  56512. * Note: if an effect parameter is unset, effect is disabled
  56513. *
  56514. * @param name The rendering pipeline name
  56515. * @param parameters - An object containing all parameters (see above)
  56516. * @param scene The scene linked to this pipeline
  56517. * @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)
  56518. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56519. */
  56520. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56521. /**
  56522. * Get the class name
  56523. * @returns "LensRenderingPipeline"
  56524. */
  56525. getClassName(): string;
  56526. /**
  56527. * Gets associated scene
  56528. */
  56529. readonly scene: Scene;
  56530. /**
  56531. * Gets or sets the edge blur
  56532. */
  56533. edgeBlur: number;
  56534. /**
  56535. * Gets or sets the grain amount
  56536. */
  56537. grainAmount: number;
  56538. /**
  56539. * Gets or sets the chromatic aberration amount
  56540. */
  56541. chromaticAberration: number;
  56542. /**
  56543. * Gets or sets the depth of field aperture
  56544. */
  56545. dofAperture: number;
  56546. /**
  56547. * Gets or sets the edge distortion
  56548. */
  56549. edgeDistortion: number;
  56550. /**
  56551. * Gets or sets the depth of field distortion
  56552. */
  56553. dofDistortion: number;
  56554. /**
  56555. * Gets or sets the darken out of focus amount
  56556. */
  56557. darkenOutOfFocus: number;
  56558. /**
  56559. * Gets or sets a boolean indicating if blur noise is enabled
  56560. */
  56561. blurNoise: boolean;
  56562. /**
  56563. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56564. */
  56565. pentagonBokeh: boolean;
  56566. /**
  56567. * Gets or sets the highlight grain amount
  56568. */
  56569. highlightsGain: number;
  56570. /**
  56571. * Gets or sets the highlight threshold
  56572. */
  56573. highlightsThreshold: number;
  56574. /**
  56575. * Sets the amount of blur at the edges
  56576. * @param amount blur amount
  56577. */
  56578. setEdgeBlur(amount: number): void;
  56579. /**
  56580. * Sets edge blur to 0
  56581. */
  56582. disableEdgeBlur(): void;
  56583. /**
  56584. * Sets the amout of grain
  56585. * @param amount Amount of grain
  56586. */
  56587. setGrainAmount(amount: number): void;
  56588. /**
  56589. * Set grain amount to 0
  56590. */
  56591. disableGrain(): void;
  56592. /**
  56593. * Sets the chromatic aberration amount
  56594. * @param amount amount of chromatic aberration
  56595. */
  56596. setChromaticAberration(amount: number): void;
  56597. /**
  56598. * Sets chromatic aberration amount to 0
  56599. */
  56600. disableChromaticAberration(): void;
  56601. /**
  56602. * Sets the EdgeDistortion amount
  56603. * @param amount amount of EdgeDistortion
  56604. */
  56605. setEdgeDistortion(amount: number): void;
  56606. /**
  56607. * Sets edge distortion to 0
  56608. */
  56609. disableEdgeDistortion(): void;
  56610. /**
  56611. * Sets the FocusDistance amount
  56612. * @param amount amount of FocusDistance
  56613. */
  56614. setFocusDistance(amount: number): void;
  56615. /**
  56616. * Disables depth of field
  56617. */
  56618. disableDepthOfField(): void;
  56619. /**
  56620. * Sets the Aperture amount
  56621. * @param amount amount of Aperture
  56622. */
  56623. setAperture(amount: number): void;
  56624. /**
  56625. * Sets the DarkenOutOfFocus amount
  56626. * @param amount amount of DarkenOutOfFocus
  56627. */
  56628. setDarkenOutOfFocus(amount: number): void;
  56629. private _pentagonBokehIsEnabled;
  56630. /**
  56631. * Creates a pentagon bokeh effect
  56632. */
  56633. enablePentagonBokeh(): void;
  56634. /**
  56635. * Disables the pentagon bokeh effect
  56636. */
  56637. disablePentagonBokeh(): void;
  56638. /**
  56639. * Enables noise blur
  56640. */
  56641. enableNoiseBlur(): void;
  56642. /**
  56643. * Disables noise blur
  56644. */
  56645. disableNoiseBlur(): void;
  56646. /**
  56647. * Sets the HighlightsGain amount
  56648. * @param amount amount of HighlightsGain
  56649. */
  56650. setHighlightsGain(amount: number): void;
  56651. /**
  56652. * Sets the HighlightsThreshold amount
  56653. * @param amount amount of HighlightsThreshold
  56654. */
  56655. setHighlightsThreshold(amount: number): void;
  56656. /**
  56657. * Disables highlights
  56658. */
  56659. disableHighlights(): void;
  56660. /**
  56661. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56662. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56663. */
  56664. dispose(disableDepthRender?: boolean): void;
  56665. private _createChromaticAberrationPostProcess;
  56666. private _createHighlightsPostProcess;
  56667. private _createDepthOfFieldPostProcess;
  56668. private _createGrainTexture;
  56669. }
  56670. }
  56671. declare module BABYLON {
  56672. /** @hidden */
  56673. export var ssao2PixelShader: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module BABYLON {
  56679. /** @hidden */
  56680. export var ssaoCombinePixelShader: {
  56681. name: string;
  56682. shader: string;
  56683. };
  56684. }
  56685. declare module BABYLON {
  56686. /**
  56687. * Render pipeline to produce ssao effect
  56688. */
  56689. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56690. /**
  56691. * @ignore
  56692. * The PassPostProcess id in the pipeline that contains the original scene color
  56693. */
  56694. SSAOOriginalSceneColorEffect: string;
  56695. /**
  56696. * @ignore
  56697. * The SSAO PostProcess id in the pipeline
  56698. */
  56699. SSAORenderEffect: string;
  56700. /**
  56701. * @ignore
  56702. * The horizontal blur PostProcess id in the pipeline
  56703. */
  56704. SSAOBlurHRenderEffect: string;
  56705. /**
  56706. * @ignore
  56707. * The vertical blur PostProcess id in the pipeline
  56708. */
  56709. SSAOBlurVRenderEffect: string;
  56710. /**
  56711. * @ignore
  56712. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56713. */
  56714. SSAOCombineRenderEffect: string;
  56715. /**
  56716. * The output strength of the SSAO post-process. Default value is 1.0.
  56717. */
  56718. totalStrength: number;
  56719. /**
  56720. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56721. */
  56722. maxZ: number;
  56723. /**
  56724. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56725. */
  56726. minZAspect: number;
  56727. private _samples;
  56728. /**
  56729. * Number of samples used for the SSAO calculations. Default value is 8
  56730. */
  56731. samples: number;
  56732. private _textureSamples;
  56733. /**
  56734. * Number of samples to use for antialiasing
  56735. */
  56736. textureSamples: number;
  56737. /**
  56738. * Ratio object used for SSAO ratio and blur ratio
  56739. */
  56740. private _ratio;
  56741. /**
  56742. * Dynamically generated sphere sampler.
  56743. */
  56744. private _sampleSphere;
  56745. /**
  56746. * Blur filter offsets
  56747. */
  56748. private _samplerOffsets;
  56749. private _expensiveBlur;
  56750. /**
  56751. * If bilateral blur should be used
  56752. */
  56753. expensiveBlur: boolean;
  56754. /**
  56755. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56756. */
  56757. radius: number;
  56758. /**
  56759. * The base color of the SSAO post-process
  56760. * The final result is "base + ssao" between [0, 1]
  56761. */
  56762. base: number;
  56763. /**
  56764. * Support test.
  56765. */
  56766. static readonly IsSupported: boolean;
  56767. private _scene;
  56768. private _depthTexture;
  56769. private _normalTexture;
  56770. private _randomTexture;
  56771. private _originalColorPostProcess;
  56772. private _ssaoPostProcess;
  56773. private _blurHPostProcess;
  56774. private _blurVPostProcess;
  56775. private _ssaoCombinePostProcess;
  56776. private _firstUpdate;
  56777. /**
  56778. * Gets active scene
  56779. */
  56780. readonly scene: Scene;
  56781. /**
  56782. * @constructor
  56783. * @param name The rendering pipeline name
  56784. * @param scene The scene linked to this pipeline
  56785. * @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 }
  56786. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56787. */
  56788. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56789. /**
  56790. * Get the class name
  56791. * @returns "SSAO2RenderingPipeline"
  56792. */
  56793. getClassName(): string;
  56794. /**
  56795. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56796. */
  56797. dispose(disableGeometryBufferRenderer?: boolean): void;
  56798. private _createBlurPostProcess;
  56799. /** @hidden */
  56800. _rebuild(): void;
  56801. private _bits;
  56802. private _radicalInverse_VdC;
  56803. private _hammersley;
  56804. private _hemisphereSample_uniform;
  56805. private _generateHemisphere;
  56806. private _createSSAOPostProcess;
  56807. private _createSSAOCombinePostProcess;
  56808. private _createRandomTexture;
  56809. /**
  56810. * Serialize the rendering pipeline (Used when exporting)
  56811. * @returns the serialized object
  56812. */
  56813. serialize(): any;
  56814. /**
  56815. * Parse the serialized pipeline
  56816. * @param source Source pipeline.
  56817. * @param scene The scene to load the pipeline to.
  56818. * @param rootUrl The URL of the serialized pipeline.
  56819. * @returns An instantiated pipeline from the serialized object.
  56820. */
  56821. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56822. }
  56823. }
  56824. declare module BABYLON {
  56825. /** @hidden */
  56826. export var ssaoPixelShader: {
  56827. name: string;
  56828. shader: string;
  56829. };
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Render pipeline to produce ssao effect
  56834. */
  56835. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56836. /**
  56837. * @ignore
  56838. * The PassPostProcess id in the pipeline that contains the original scene color
  56839. */
  56840. SSAOOriginalSceneColorEffect: string;
  56841. /**
  56842. * @ignore
  56843. * The SSAO PostProcess id in the pipeline
  56844. */
  56845. SSAORenderEffect: string;
  56846. /**
  56847. * @ignore
  56848. * The horizontal blur PostProcess id in the pipeline
  56849. */
  56850. SSAOBlurHRenderEffect: string;
  56851. /**
  56852. * @ignore
  56853. * The vertical blur PostProcess id in the pipeline
  56854. */
  56855. SSAOBlurVRenderEffect: string;
  56856. /**
  56857. * @ignore
  56858. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56859. */
  56860. SSAOCombineRenderEffect: string;
  56861. /**
  56862. * The output strength of the SSAO post-process. Default value is 1.0.
  56863. */
  56864. totalStrength: number;
  56865. /**
  56866. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56867. */
  56868. radius: number;
  56869. /**
  56870. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56871. * Must not be equal to fallOff and superior to fallOff.
  56872. * Default value is 0.0075
  56873. */
  56874. area: number;
  56875. /**
  56876. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56877. * Must not be equal to area and inferior to area.
  56878. * Default value is 0.000001
  56879. */
  56880. fallOff: number;
  56881. /**
  56882. * The base color of the SSAO post-process
  56883. * The final result is "base + ssao" between [0, 1]
  56884. */
  56885. base: number;
  56886. private _scene;
  56887. private _depthTexture;
  56888. private _randomTexture;
  56889. private _originalColorPostProcess;
  56890. private _ssaoPostProcess;
  56891. private _blurHPostProcess;
  56892. private _blurVPostProcess;
  56893. private _ssaoCombinePostProcess;
  56894. private _firstUpdate;
  56895. /**
  56896. * Gets active scene
  56897. */
  56898. readonly scene: Scene;
  56899. /**
  56900. * @constructor
  56901. * @param name - The rendering pipeline name
  56902. * @param scene - The scene linked to this pipeline
  56903. * @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 }
  56904. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56905. */
  56906. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56907. /**
  56908. * Get the class name
  56909. * @returns "SSAORenderingPipeline"
  56910. */
  56911. getClassName(): string;
  56912. /**
  56913. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56914. */
  56915. dispose(disableDepthRender?: boolean): void;
  56916. private _createBlurPostProcess;
  56917. /** @hidden */
  56918. _rebuild(): void;
  56919. private _createSSAOPostProcess;
  56920. private _createSSAOCombinePostProcess;
  56921. private _createRandomTexture;
  56922. }
  56923. }
  56924. declare module BABYLON {
  56925. /** @hidden */
  56926. export var standardPixelShader: {
  56927. name: string;
  56928. shader: string;
  56929. };
  56930. }
  56931. declare module BABYLON {
  56932. /**
  56933. * Standard rendering pipeline
  56934. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56935. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56936. */
  56937. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56938. /**
  56939. * Public members
  56940. */
  56941. /**
  56942. * Post-process which contains the original scene color before the pipeline applies all the effects
  56943. */
  56944. originalPostProcess: Nullable<PostProcess>;
  56945. /**
  56946. * Post-process used to down scale an image x4
  56947. */
  56948. downSampleX4PostProcess: Nullable<PostProcess>;
  56949. /**
  56950. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56951. */
  56952. brightPassPostProcess: Nullable<PostProcess>;
  56953. /**
  56954. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56955. */
  56956. blurHPostProcesses: PostProcess[];
  56957. /**
  56958. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56959. */
  56960. blurVPostProcesses: PostProcess[];
  56961. /**
  56962. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56963. */
  56964. textureAdderPostProcess: Nullable<PostProcess>;
  56965. /**
  56966. * Post-process used to create volumetric lighting effect
  56967. */
  56968. volumetricLightPostProcess: Nullable<PostProcess>;
  56969. /**
  56970. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56971. */
  56972. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56973. /**
  56974. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56975. */
  56976. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56977. /**
  56978. * Post-process used to merge the volumetric light effect and the real scene color
  56979. */
  56980. volumetricLightMergePostProces: Nullable<PostProcess>;
  56981. /**
  56982. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56983. */
  56984. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56985. /**
  56986. * Base post-process used to calculate the average luminance of the final image for HDR
  56987. */
  56988. luminancePostProcess: Nullable<PostProcess>;
  56989. /**
  56990. * Post-processes used to create down sample post-processes in order to get
  56991. * the average luminance of the final image for HDR
  56992. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56993. */
  56994. luminanceDownSamplePostProcesses: PostProcess[];
  56995. /**
  56996. * Post-process used to create a HDR effect (light adaptation)
  56997. */
  56998. hdrPostProcess: Nullable<PostProcess>;
  56999. /**
  57000. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57001. */
  57002. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57003. /**
  57004. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57005. */
  57006. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57007. /**
  57008. * Post-process used to merge the final HDR post-process and the real scene color
  57009. */
  57010. hdrFinalPostProcess: Nullable<PostProcess>;
  57011. /**
  57012. * Post-process used to create a lens flare effect
  57013. */
  57014. lensFlarePostProcess: Nullable<PostProcess>;
  57015. /**
  57016. * Post-process that merges the result of the lens flare post-process and the real scene color
  57017. */
  57018. lensFlareComposePostProcess: Nullable<PostProcess>;
  57019. /**
  57020. * Post-process used to create a motion blur effect
  57021. */
  57022. motionBlurPostProcess: Nullable<PostProcess>;
  57023. /**
  57024. * Post-process used to create a depth of field effect
  57025. */
  57026. depthOfFieldPostProcess: Nullable<PostProcess>;
  57027. /**
  57028. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57029. */
  57030. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57031. /**
  57032. * Represents the brightness threshold in order to configure the illuminated surfaces
  57033. */
  57034. brightThreshold: number;
  57035. /**
  57036. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57037. */
  57038. blurWidth: number;
  57039. /**
  57040. * Sets if the blur for highlighted surfaces must be only horizontal
  57041. */
  57042. horizontalBlur: boolean;
  57043. /**
  57044. * Gets the overall exposure used by the pipeline
  57045. */
  57046. /**
  57047. * Sets the overall exposure used by the pipeline
  57048. */
  57049. exposure: number;
  57050. /**
  57051. * Texture used typically to simulate "dirty" on camera lens
  57052. */
  57053. lensTexture: Nullable<Texture>;
  57054. /**
  57055. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57056. */
  57057. volumetricLightCoefficient: number;
  57058. /**
  57059. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57060. */
  57061. volumetricLightPower: number;
  57062. /**
  57063. * Used the set the blur intensity to smooth the volumetric lights
  57064. */
  57065. volumetricLightBlurScale: number;
  57066. /**
  57067. * Light (spot or directional) used to generate the volumetric lights rays
  57068. * The source light must have a shadow generate so the pipeline can get its
  57069. * depth map
  57070. */
  57071. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57072. /**
  57073. * For eye adaptation, represents the minimum luminance the eye can see
  57074. */
  57075. hdrMinimumLuminance: number;
  57076. /**
  57077. * For eye adaptation, represents the decrease luminance speed
  57078. */
  57079. hdrDecreaseRate: number;
  57080. /**
  57081. * For eye adaptation, represents the increase luminance speed
  57082. */
  57083. hdrIncreaseRate: number;
  57084. /**
  57085. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57086. */
  57087. /**
  57088. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57089. */
  57090. hdrAutoExposure: boolean;
  57091. /**
  57092. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57093. */
  57094. lensColorTexture: Nullable<Texture>;
  57095. /**
  57096. * The overall strengh for the lens flare effect
  57097. */
  57098. lensFlareStrength: number;
  57099. /**
  57100. * Dispersion coefficient for lens flare ghosts
  57101. */
  57102. lensFlareGhostDispersal: number;
  57103. /**
  57104. * Main lens flare halo width
  57105. */
  57106. lensFlareHaloWidth: number;
  57107. /**
  57108. * Based on the lens distortion effect, defines how much the lens flare result
  57109. * is distorted
  57110. */
  57111. lensFlareDistortionStrength: number;
  57112. /**
  57113. * Lens star texture must be used to simulate rays on the flares and is available
  57114. * in the documentation
  57115. */
  57116. lensStarTexture: Nullable<Texture>;
  57117. /**
  57118. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57119. * flare effect by taking account of the dirt texture
  57120. */
  57121. lensFlareDirtTexture: Nullable<Texture>;
  57122. /**
  57123. * Represents the focal length for the depth of field effect
  57124. */
  57125. depthOfFieldDistance: number;
  57126. /**
  57127. * Represents the blur intensity for the blurred part of the depth of field effect
  57128. */
  57129. depthOfFieldBlurWidth: number;
  57130. /**
  57131. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57132. */
  57133. /**
  57134. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57135. */
  57136. motionStrength: number;
  57137. /**
  57138. * Gets wether or not the motion blur post-process is object based or screen based.
  57139. */
  57140. /**
  57141. * Sets wether or not the motion blur post-process should be object based or screen based
  57142. */
  57143. objectBasedMotionBlur: boolean;
  57144. /**
  57145. * List of animations for the pipeline (IAnimatable implementation)
  57146. */
  57147. animations: Animation[];
  57148. /**
  57149. * Private members
  57150. */
  57151. private _scene;
  57152. private _currentDepthOfFieldSource;
  57153. private _basePostProcess;
  57154. private _fixedExposure;
  57155. private _currentExposure;
  57156. private _hdrAutoExposure;
  57157. private _hdrCurrentLuminance;
  57158. private _motionStrength;
  57159. private _isObjectBasedMotionBlur;
  57160. private _floatTextureType;
  57161. private _ratio;
  57162. private _bloomEnabled;
  57163. private _depthOfFieldEnabled;
  57164. private _vlsEnabled;
  57165. private _lensFlareEnabled;
  57166. private _hdrEnabled;
  57167. private _motionBlurEnabled;
  57168. private _fxaaEnabled;
  57169. private _motionBlurSamples;
  57170. private _volumetricLightStepsCount;
  57171. private _samples;
  57172. /**
  57173. * @ignore
  57174. * Specifies if the bloom pipeline is enabled
  57175. */
  57176. BloomEnabled: boolean;
  57177. /**
  57178. * @ignore
  57179. * Specifies if the depth of field pipeline is enabed
  57180. */
  57181. DepthOfFieldEnabled: boolean;
  57182. /**
  57183. * @ignore
  57184. * Specifies if the lens flare pipeline is enabed
  57185. */
  57186. LensFlareEnabled: boolean;
  57187. /**
  57188. * @ignore
  57189. * Specifies if the HDR pipeline is enabled
  57190. */
  57191. HDREnabled: boolean;
  57192. /**
  57193. * @ignore
  57194. * Specifies if the volumetric lights scattering effect is enabled
  57195. */
  57196. VLSEnabled: boolean;
  57197. /**
  57198. * @ignore
  57199. * Specifies if the motion blur effect is enabled
  57200. */
  57201. MotionBlurEnabled: boolean;
  57202. /**
  57203. * Specifies if anti-aliasing is enabled
  57204. */
  57205. fxaaEnabled: boolean;
  57206. /**
  57207. * Specifies the number of steps used to calculate the volumetric lights
  57208. * Typically in interval [50, 200]
  57209. */
  57210. volumetricLightStepsCount: number;
  57211. /**
  57212. * Specifies the number of samples used for the motion blur effect
  57213. * Typically in interval [16, 64]
  57214. */
  57215. motionBlurSamples: number;
  57216. /**
  57217. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57218. */
  57219. samples: number;
  57220. /**
  57221. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57222. * @constructor
  57223. * @param name The rendering pipeline name
  57224. * @param scene The scene linked to this pipeline
  57225. * @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)
  57226. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57227. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57228. */
  57229. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57230. private _buildPipeline;
  57231. private _createDownSampleX4PostProcess;
  57232. private _createBrightPassPostProcess;
  57233. private _createBlurPostProcesses;
  57234. private _createTextureAdderPostProcess;
  57235. private _createVolumetricLightPostProcess;
  57236. private _createLuminancePostProcesses;
  57237. private _createHdrPostProcess;
  57238. private _createLensFlarePostProcess;
  57239. private _createDepthOfFieldPostProcess;
  57240. private _createMotionBlurPostProcess;
  57241. private _getDepthTexture;
  57242. private _disposePostProcesses;
  57243. /**
  57244. * Dispose of the pipeline and stop all post processes
  57245. */
  57246. dispose(): void;
  57247. /**
  57248. * Serialize the rendering pipeline (Used when exporting)
  57249. * @returns the serialized object
  57250. */
  57251. serialize(): any;
  57252. /**
  57253. * Parse the serialized pipeline
  57254. * @param source Source pipeline.
  57255. * @param scene The scene to load the pipeline to.
  57256. * @param rootUrl The URL of the serialized pipeline.
  57257. * @returns An instantiated pipeline from the serialized object.
  57258. */
  57259. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57260. /**
  57261. * Luminance steps
  57262. */
  57263. static LuminanceSteps: number;
  57264. }
  57265. }
  57266. declare module BABYLON {
  57267. /** @hidden */
  57268. export var tonemapPixelShader: {
  57269. name: string;
  57270. shader: string;
  57271. };
  57272. }
  57273. declare module BABYLON {
  57274. /** Defines operator used for tonemapping */
  57275. export enum TonemappingOperator {
  57276. /** Hable */
  57277. Hable = 0,
  57278. /** Reinhard */
  57279. Reinhard = 1,
  57280. /** HejiDawson */
  57281. HejiDawson = 2,
  57282. /** Photographic */
  57283. Photographic = 3
  57284. }
  57285. /**
  57286. * Defines a post process to apply tone mapping
  57287. */
  57288. export class TonemapPostProcess extends PostProcess {
  57289. private _operator;
  57290. /** Defines the required exposure adjustement */
  57291. exposureAdjustment: number;
  57292. /**
  57293. * Creates a new TonemapPostProcess
  57294. * @param name defines the name of the postprocess
  57295. * @param _operator defines the operator to use
  57296. * @param exposureAdjustment defines the required exposure adjustement
  57297. * @param camera defines the camera to use (can be null)
  57298. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57299. * @param engine defines the hosting engine (can be ignore if camera is set)
  57300. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57301. */
  57302. constructor(name: string, _operator: TonemappingOperator,
  57303. /** Defines the required exposure adjustement */
  57304. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57305. }
  57306. }
  57307. declare module BABYLON {
  57308. /** @hidden */
  57309. export var depthVertexShader: {
  57310. name: string;
  57311. shader: string;
  57312. };
  57313. }
  57314. declare module BABYLON {
  57315. /** @hidden */
  57316. export var volumetricLightScatteringPixelShader: {
  57317. name: string;
  57318. shader: string;
  57319. };
  57320. }
  57321. declare module BABYLON {
  57322. /** @hidden */
  57323. export var volumetricLightScatteringPassPixelShader: {
  57324. name: string;
  57325. shader: string;
  57326. };
  57327. }
  57328. declare module BABYLON {
  57329. /**
  57330. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57331. */
  57332. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57333. private _volumetricLightScatteringPass;
  57334. private _volumetricLightScatteringRTT;
  57335. private _viewPort;
  57336. private _screenCoordinates;
  57337. private _cachedDefines;
  57338. /**
  57339. * If not undefined, the mesh position is computed from the attached node position
  57340. */
  57341. attachedNode: {
  57342. position: Vector3;
  57343. };
  57344. /**
  57345. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57346. */
  57347. customMeshPosition: Vector3;
  57348. /**
  57349. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57350. */
  57351. useCustomMeshPosition: boolean;
  57352. /**
  57353. * If the post-process should inverse the light scattering direction
  57354. */
  57355. invert: boolean;
  57356. /**
  57357. * The internal mesh used by the post-process
  57358. */
  57359. mesh: Mesh;
  57360. /**
  57361. * @hidden
  57362. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57363. */
  57364. useDiffuseColor: boolean;
  57365. /**
  57366. * Array containing the excluded meshes not rendered in the internal pass
  57367. */
  57368. excludedMeshes: AbstractMesh[];
  57369. /**
  57370. * Controls the overall intensity of the post-process
  57371. */
  57372. exposure: number;
  57373. /**
  57374. * Dissipates each sample's contribution in range [0, 1]
  57375. */
  57376. decay: number;
  57377. /**
  57378. * Controls the overall intensity of each sample
  57379. */
  57380. weight: number;
  57381. /**
  57382. * Controls the density of each sample
  57383. */
  57384. density: number;
  57385. /**
  57386. * @constructor
  57387. * @param name The post-process name
  57388. * @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)
  57389. * @param camera The camera that the post-process will be attached to
  57390. * @param mesh The mesh used to create the light scattering
  57391. * @param samples The post-process quality, default 100
  57392. * @param samplingModeThe post-process filtering mode
  57393. * @param engine The babylon engine
  57394. * @param reusable If the post-process is reusable
  57395. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57396. */
  57397. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57398. /**
  57399. * Returns the string "VolumetricLightScatteringPostProcess"
  57400. * @returns "VolumetricLightScatteringPostProcess"
  57401. */
  57402. getClassName(): string;
  57403. private _isReady;
  57404. /**
  57405. * Sets the new light position for light scattering effect
  57406. * @param position The new custom light position
  57407. */
  57408. setCustomMeshPosition(position: Vector3): void;
  57409. /**
  57410. * Returns the light position for light scattering effect
  57411. * @return Vector3 The custom light position
  57412. */
  57413. getCustomMeshPosition(): Vector3;
  57414. /**
  57415. * Disposes the internal assets and detaches the post-process from the camera
  57416. */
  57417. dispose(camera: Camera): void;
  57418. /**
  57419. * Returns the render target texture used by the post-process
  57420. * @return the render target texture used by the post-process
  57421. */
  57422. getPass(): RenderTargetTexture;
  57423. private _meshExcluded;
  57424. private _createPass;
  57425. private _updateMeshScreenCoordinates;
  57426. /**
  57427. * Creates a default mesh for the Volumeric Light Scattering post-process
  57428. * @param name The mesh name
  57429. * @param scene The scene where to create the mesh
  57430. * @return the default mesh
  57431. */
  57432. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57433. }
  57434. }
  57435. declare module BABYLON {
  57436. interface Scene {
  57437. /** @hidden (Backing field) */
  57438. _boundingBoxRenderer: BoundingBoxRenderer;
  57439. /** @hidden (Backing field) */
  57440. _forceShowBoundingBoxes: boolean;
  57441. /**
  57442. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57443. */
  57444. forceShowBoundingBoxes: boolean;
  57445. /**
  57446. * Gets the bounding box renderer associated with the scene
  57447. * @returns a BoundingBoxRenderer
  57448. */
  57449. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57450. }
  57451. interface AbstractMesh {
  57452. /** @hidden (Backing field) */
  57453. _showBoundingBox: boolean;
  57454. /**
  57455. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57456. */
  57457. showBoundingBox: boolean;
  57458. }
  57459. /**
  57460. * Component responsible of rendering the bounding box of the meshes in a scene.
  57461. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57462. */
  57463. export class BoundingBoxRenderer implements ISceneComponent {
  57464. /**
  57465. * The component name helpfull to identify the component in the list of scene components.
  57466. */
  57467. readonly name: string;
  57468. /**
  57469. * The scene the component belongs to.
  57470. */
  57471. scene: Scene;
  57472. /**
  57473. * Color of the bounding box lines placed in front of an object
  57474. */
  57475. frontColor: Color3;
  57476. /**
  57477. * Color of the bounding box lines placed behind an object
  57478. */
  57479. backColor: Color3;
  57480. /**
  57481. * Defines if the renderer should show the back lines or not
  57482. */
  57483. showBackLines: boolean;
  57484. /**
  57485. * @hidden
  57486. */
  57487. renderList: SmartArray<BoundingBox>;
  57488. private _colorShader;
  57489. private _vertexBuffers;
  57490. private _indexBuffer;
  57491. private _fillIndexBuffer;
  57492. private _fillIndexData;
  57493. /**
  57494. * Instantiates a new bounding box renderer in a scene.
  57495. * @param scene the scene the renderer renders in
  57496. */
  57497. constructor(scene: Scene);
  57498. /**
  57499. * Registers the component in a given scene
  57500. */
  57501. register(): void;
  57502. private _evaluateSubMesh;
  57503. private _activeMesh;
  57504. private _prepareRessources;
  57505. private _createIndexBuffer;
  57506. /**
  57507. * Rebuilds the elements related to this component in case of
  57508. * context lost for instance.
  57509. */
  57510. rebuild(): void;
  57511. /**
  57512. * @hidden
  57513. */
  57514. reset(): void;
  57515. /**
  57516. * Render the bounding boxes of a specific rendering group
  57517. * @param renderingGroupId defines the rendering group to render
  57518. */
  57519. render(renderingGroupId: number): void;
  57520. /**
  57521. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57522. * @param mesh Define the mesh to render the occlusion bounding box for
  57523. */
  57524. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57525. /**
  57526. * Dispose and release the resources attached to this renderer.
  57527. */
  57528. dispose(): void;
  57529. }
  57530. }
  57531. declare module BABYLON {
  57532. /** @hidden */
  57533. export var depthPixelShader: {
  57534. name: string;
  57535. shader: string;
  57536. };
  57537. }
  57538. declare module BABYLON {
  57539. /**
  57540. * This represents a depth renderer in Babylon.
  57541. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57542. */
  57543. export class DepthRenderer {
  57544. private _scene;
  57545. private _depthMap;
  57546. private _effect;
  57547. private _cachedDefines;
  57548. private _camera;
  57549. /**
  57550. * Specifiess that the depth renderer will only be used within
  57551. * the camera it is created for.
  57552. * This can help forcing its rendering during the camera processing.
  57553. */
  57554. useOnlyInActiveCamera: boolean;
  57555. /** @hidden */
  57556. static _SceneComponentInitialization: (scene: Scene) => void;
  57557. /**
  57558. * Instantiates a depth renderer
  57559. * @param scene The scene the renderer belongs to
  57560. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57561. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57562. */
  57563. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57564. /**
  57565. * Creates the depth rendering effect and checks if the effect is ready.
  57566. * @param subMesh The submesh to be used to render the depth map of
  57567. * @param useInstances If multiple world instances should be used
  57568. * @returns if the depth renderer is ready to render the depth map
  57569. */
  57570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57571. /**
  57572. * Gets the texture which the depth map will be written to.
  57573. * @returns The depth map texture
  57574. */
  57575. getDepthMap(): RenderTargetTexture;
  57576. /**
  57577. * Disposes of the depth renderer.
  57578. */
  57579. dispose(): void;
  57580. }
  57581. }
  57582. declare module BABYLON {
  57583. interface Scene {
  57584. /** @hidden (Backing field) */
  57585. _depthRenderer: {
  57586. [id: string]: DepthRenderer;
  57587. };
  57588. /**
  57589. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57590. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57591. * @returns the created depth renderer
  57592. */
  57593. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57594. /**
  57595. * Disables a depth renderer for a given camera
  57596. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57597. */
  57598. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57599. }
  57600. /**
  57601. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57602. * in several rendering techniques.
  57603. */
  57604. export class DepthRendererSceneComponent implements ISceneComponent {
  57605. /**
  57606. * The component name helpfull to identify the component in the list of scene components.
  57607. */
  57608. readonly name: string;
  57609. /**
  57610. * The scene the component belongs to.
  57611. */
  57612. scene: Scene;
  57613. /**
  57614. * Creates a new instance of the component for the given scene
  57615. * @param scene Defines the scene to register the component in
  57616. */
  57617. constructor(scene: Scene);
  57618. /**
  57619. * Registers the component in a given scene
  57620. */
  57621. register(): void;
  57622. /**
  57623. * Rebuilds the elements related to this component in case of
  57624. * context lost for instance.
  57625. */
  57626. rebuild(): void;
  57627. /**
  57628. * Disposes the component and the associated ressources
  57629. */
  57630. dispose(): void;
  57631. private _gatherRenderTargets;
  57632. private _gatherActiveCameraRenderTargets;
  57633. }
  57634. }
  57635. declare module BABYLON {
  57636. /** @hidden */
  57637. export var outlinePixelShader: {
  57638. name: string;
  57639. shader: string;
  57640. };
  57641. }
  57642. declare module BABYLON {
  57643. /** @hidden */
  57644. export var outlineVertexShader: {
  57645. name: string;
  57646. shader: string;
  57647. };
  57648. }
  57649. declare module BABYLON {
  57650. interface Scene {
  57651. /** @hidden */
  57652. _outlineRenderer: OutlineRenderer;
  57653. /**
  57654. * Gets the outline renderer associated with the scene
  57655. * @returns a OutlineRenderer
  57656. */
  57657. getOutlineRenderer(): OutlineRenderer;
  57658. }
  57659. interface AbstractMesh {
  57660. /** @hidden (Backing field) */
  57661. _renderOutline: boolean;
  57662. /**
  57663. * Gets or sets a boolean indicating if the outline must be rendered as well
  57664. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57665. */
  57666. renderOutline: boolean;
  57667. /** @hidden (Backing field) */
  57668. _renderOverlay: boolean;
  57669. /**
  57670. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57671. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57672. */
  57673. renderOverlay: boolean;
  57674. }
  57675. /**
  57676. * This class is responsible to draw bothe outline/overlay of meshes.
  57677. * It should not be used directly but through the available method on mesh.
  57678. */
  57679. export class OutlineRenderer implements ISceneComponent {
  57680. /**
  57681. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57682. */
  57683. private static _StencilReference;
  57684. /**
  57685. * The name of the component. Each component must have a unique name.
  57686. */
  57687. name: string;
  57688. /**
  57689. * The scene the component belongs to.
  57690. */
  57691. scene: Scene;
  57692. /**
  57693. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57694. */
  57695. zOffset: number;
  57696. private _engine;
  57697. private _effect;
  57698. private _cachedDefines;
  57699. private _savedDepthWrite;
  57700. /**
  57701. * Instantiates a new outline renderer. (There could be only one per scene).
  57702. * @param scene Defines the scene it belongs to
  57703. */
  57704. constructor(scene: Scene);
  57705. /**
  57706. * Register the component to one instance of a scene.
  57707. */
  57708. register(): void;
  57709. /**
  57710. * Rebuilds the elements related to this component in case of
  57711. * context lost for instance.
  57712. */
  57713. rebuild(): void;
  57714. /**
  57715. * Disposes the component and the associated ressources.
  57716. */
  57717. dispose(): void;
  57718. /**
  57719. * Renders the outline in the canvas.
  57720. * @param subMesh Defines the sumesh to render
  57721. * @param batch Defines the batch of meshes in case of instances
  57722. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57723. */
  57724. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57725. /**
  57726. * Returns whether or not the outline renderer is ready for a given submesh.
  57727. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57728. * @param subMesh Defines the submesh to check readyness for
  57729. * @param useInstances Defines wheter wee are trying to render instances or not
  57730. * @returns true if ready otherwise false
  57731. */
  57732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57733. private _beforeRenderingMesh;
  57734. private _afterRenderingMesh;
  57735. }
  57736. }
  57737. declare module BABYLON {
  57738. /**
  57739. * Defines the list of states available for a task inside a AssetsManager
  57740. */
  57741. export enum AssetTaskState {
  57742. /**
  57743. * Initialization
  57744. */
  57745. INIT = 0,
  57746. /**
  57747. * Running
  57748. */
  57749. RUNNING = 1,
  57750. /**
  57751. * Done
  57752. */
  57753. DONE = 2,
  57754. /**
  57755. * Error
  57756. */
  57757. ERROR = 3
  57758. }
  57759. /**
  57760. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57761. */
  57762. export abstract class AbstractAssetTask {
  57763. /**
  57764. * Task name
  57765. */ name: string;
  57766. /**
  57767. * Callback called when the task is successful
  57768. */
  57769. onSuccess: (task: any) => void;
  57770. /**
  57771. * Callback called when the task is not successful
  57772. */
  57773. onError: (task: any, message?: string, exception?: any) => void;
  57774. /**
  57775. * Creates a new AssetsManager
  57776. * @param name defines the name of the task
  57777. */
  57778. constructor(
  57779. /**
  57780. * Task name
  57781. */ name: string);
  57782. private _isCompleted;
  57783. private _taskState;
  57784. private _errorObject;
  57785. /**
  57786. * Get if the task is completed
  57787. */
  57788. readonly isCompleted: boolean;
  57789. /**
  57790. * Gets the current state of the task
  57791. */
  57792. readonly taskState: AssetTaskState;
  57793. /**
  57794. * Gets the current error object (if task is in error)
  57795. */
  57796. readonly errorObject: {
  57797. message?: string;
  57798. exception?: any;
  57799. };
  57800. /**
  57801. * Internal only
  57802. * @hidden
  57803. */
  57804. _setErrorObject(message?: string, exception?: any): void;
  57805. /**
  57806. * Execute the current task
  57807. * @param scene defines the scene where you want your assets to be loaded
  57808. * @param onSuccess is a callback called when the task is successfully executed
  57809. * @param onError is a callback called if an error occurs
  57810. */
  57811. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57812. /**
  57813. * Execute the current task
  57814. * @param scene defines the scene where you want your assets to be loaded
  57815. * @param onSuccess is a callback called when the task is successfully executed
  57816. * @param onError is a callback called if an error occurs
  57817. */
  57818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57819. /**
  57820. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57821. * This can be used with failed tasks that have the reason for failure fixed.
  57822. */
  57823. reset(): void;
  57824. private onErrorCallback;
  57825. private onDoneCallback;
  57826. }
  57827. /**
  57828. * Define the interface used by progress events raised during assets loading
  57829. */
  57830. export interface IAssetsProgressEvent {
  57831. /**
  57832. * Defines the number of remaining tasks to process
  57833. */
  57834. remainingCount: number;
  57835. /**
  57836. * Defines the total number of tasks
  57837. */
  57838. totalCount: number;
  57839. /**
  57840. * Defines the task that was just processed
  57841. */
  57842. task: AbstractAssetTask;
  57843. }
  57844. /**
  57845. * Class used to share progress information about assets loading
  57846. */
  57847. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57848. /**
  57849. * Defines the number of remaining tasks to process
  57850. */
  57851. remainingCount: number;
  57852. /**
  57853. * Defines the total number of tasks
  57854. */
  57855. totalCount: number;
  57856. /**
  57857. * Defines the task that was just processed
  57858. */
  57859. task: AbstractAssetTask;
  57860. /**
  57861. * Creates a AssetsProgressEvent
  57862. * @param remainingCount defines the number of remaining tasks to process
  57863. * @param totalCount defines the total number of tasks
  57864. * @param task defines the task that was just processed
  57865. */
  57866. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57867. }
  57868. /**
  57869. * Define a task used by AssetsManager to load meshes
  57870. */
  57871. export class MeshAssetTask extends AbstractAssetTask {
  57872. /**
  57873. * Defines the name of the task
  57874. */
  57875. name: string;
  57876. /**
  57877. * Defines the list of mesh's names you want to load
  57878. */
  57879. meshesNames: any;
  57880. /**
  57881. * Defines the root url to use as a base to load your meshes and associated resources
  57882. */
  57883. rootUrl: string;
  57884. /**
  57885. * Defines the filename of the scene to load from
  57886. */
  57887. sceneFilename: string;
  57888. /**
  57889. * Gets the list of loaded meshes
  57890. */
  57891. loadedMeshes: Array<AbstractMesh>;
  57892. /**
  57893. * Gets the list of loaded particle systems
  57894. */
  57895. loadedParticleSystems: Array<IParticleSystem>;
  57896. /**
  57897. * Gets the list of loaded skeletons
  57898. */
  57899. loadedSkeletons: Array<Skeleton>;
  57900. /**
  57901. * Gets the list of loaded animation groups
  57902. */
  57903. loadedAnimationGroups: Array<AnimationGroup>;
  57904. /**
  57905. * Callback called when the task is successful
  57906. */
  57907. onSuccess: (task: MeshAssetTask) => void;
  57908. /**
  57909. * Callback called when the task is successful
  57910. */
  57911. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57912. /**
  57913. * Creates a new MeshAssetTask
  57914. * @param name defines the name of the task
  57915. * @param meshesNames defines the list of mesh's names you want to load
  57916. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57917. * @param sceneFilename defines the filename of the scene to load from
  57918. */
  57919. constructor(
  57920. /**
  57921. * Defines the name of the task
  57922. */
  57923. name: string,
  57924. /**
  57925. * Defines the list of mesh's names you want to load
  57926. */
  57927. meshesNames: any,
  57928. /**
  57929. * Defines the root url to use as a base to load your meshes and associated resources
  57930. */
  57931. rootUrl: string,
  57932. /**
  57933. * Defines the filename of the scene to load from
  57934. */
  57935. sceneFilename: string);
  57936. /**
  57937. * Execute the current task
  57938. * @param scene defines the scene where you want your assets to be loaded
  57939. * @param onSuccess is a callback called when the task is successfully executed
  57940. * @param onError is a callback called if an error occurs
  57941. */
  57942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57943. }
  57944. /**
  57945. * Define a task used by AssetsManager to load text content
  57946. */
  57947. export class TextFileAssetTask extends AbstractAssetTask {
  57948. /**
  57949. * Defines the name of the task
  57950. */
  57951. name: string;
  57952. /**
  57953. * Defines the location of the file to load
  57954. */
  57955. url: string;
  57956. /**
  57957. * Gets the loaded text string
  57958. */
  57959. text: string;
  57960. /**
  57961. * Callback called when the task is successful
  57962. */
  57963. onSuccess: (task: TextFileAssetTask) => void;
  57964. /**
  57965. * Callback called when the task is successful
  57966. */
  57967. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57968. /**
  57969. * Creates a new TextFileAssetTask object
  57970. * @param name defines the name of the task
  57971. * @param url defines the location of the file to load
  57972. */
  57973. constructor(
  57974. /**
  57975. * Defines the name of the task
  57976. */
  57977. name: string,
  57978. /**
  57979. * Defines the location of the file to load
  57980. */
  57981. url: string);
  57982. /**
  57983. * Execute the current task
  57984. * @param scene defines the scene where you want your assets to be loaded
  57985. * @param onSuccess is a callback called when the task is successfully executed
  57986. * @param onError is a callback called if an error occurs
  57987. */
  57988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57989. }
  57990. /**
  57991. * Define a task used by AssetsManager to load binary data
  57992. */
  57993. export class BinaryFileAssetTask extends AbstractAssetTask {
  57994. /**
  57995. * Defines the name of the task
  57996. */
  57997. name: string;
  57998. /**
  57999. * Defines the location of the file to load
  58000. */
  58001. url: string;
  58002. /**
  58003. * Gets the lodaded data (as an array buffer)
  58004. */
  58005. data: ArrayBuffer;
  58006. /**
  58007. * Callback called when the task is successful
  58008. */
  58009. onSuccess: (task: BinaryFileAssetTask) => void;
  58010. /**
  58011. * Callback called when the task is successful
  58012. */
  58013. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58014. /**
  58015. * Creates a new BinaryFileAssetTask object
  58016. * @param name defines the name of the new task
  58017. * @param url defines the location of the file to load
  58018. */
  58019. constructor(
  58020. /**
  58021. * Defines the name of the task
  58022. */
  58023. name: string,
  58024. /**
  58025. * Defines the location of the file to load
  58026. */
  58027. url: string);
  58028. /**
  58029. * Execute the current task
  58030. * @param scene defines the scene where you want your assets to be loaded
  58031. * @param onSuccess is a callback called when the task is successfully executed
  58032. * @param onError is a callback called if an error occurs
  58033. */
  58034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58035. }
  58036. /**
  58037. * Define a task used by AssetsManager to load images
  58038. */
  58039. export class ImageAssetTask extends AbstractAssetTask {
  58040. /**
  58041. * Defines the name of the task
  58042. */
  58043. name: string;
  58044. /**
  58045. * Defines the location of the image to load
  58046. */
  58047. url: string;
  58048. /**
  58049. * Gets the loaded images
  58050. */
  58051. image: HTMLImageElement;
  58052. /**
  58053. * Callback called when the task is successful
  58054. */
  58055. onSuccess: (task: ImageAssetTask) => void;
  58056. /**
  58057. * Callback called when the task is successful
  58058. */
  58059. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58060. /**
  58061. * Creates a new ImageAssetTask
  58062. * @param name defines the name of the task
  58063. * @param url defines the location of the image to load
  58064. */
  58065. constructor(
  58066. /**
  58067. * Defines the name of the task
  58068. */
  58069. name: string,
  58070. /**
  58071. * Defines the location of the image to load
  58072. */
  58073. url: string);
  58074. /**
  58075. * Execute the current task
  58076. * @param scene defines the scene where you want your assets to be loaded
  58077. * @param onSuccess is a callback called when the task is successfully executed
  58078. * @param onError is a callback called if an error occurs
  58079. */
  58080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58081. }
  58082. /**
  58083. * Defines the interface used by texture loading tasks
  58084. */
  58085. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58086. /**
  58087. * Gets the loaded texture
  58088. */
  58089. texture: TEX;
  58090. }
  58091. /**
  58092. * Define a task used by AssetsManager to load 2D textures
  58093. */
  58094. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58095. /**
  58096. * Defines the name of the task
  58097. */
  58098. name: string;
  58099. /**
  58100. * Defines the location of the file to load
  58101. */
  58102. url: string;
  58103. /**
  58104. * Defines if mipmap should not be generated (default is false)
  58105. */
  58106. noMipmap?: boolean | undefined;
  58107. /**
  58108. * Defines if texture must be inverted on Y axis (default is false)
  58109. */
  58110. invertY?: boolean | undefined;
  58111. /**
  58112. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58113. */
  58114. samplingMode: number;
  58115. /**
  58116. * Gets the loaded texture
  58117. */
  58118. texture: Texture;
  58119. /**
  58120. * Callback called when the task is successful
  58121. */
  58122. onSuccess: (task: TextureAssetTask) => void;
  58123. /**
  58124. * Callback called when the task is successful
  58125. */
  58126. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58127. /**
  58128. * Creates a new TextureAssetTask object
  58129. * @param name defines the name of the task
  58130. * @param url defines the location of the file to load
  58131. * @param noMipmap defines if mipmap should not be generated (default is false)
  58132. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58133. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58134. */
  58135. constructor(
  58136. /**
  58137. * Defines the name of the task
  58138. */
  58139. name: string,
  58140. /**
  58141. * Defines the location of the file to load
  58142. */
  58143. url: string,
  58144. /**
  58145. * Defines if mipmap should not be generated (default is false)
  58146. */
  58147. noMipmap?: boolean | undefined,
  58148. /**
  58149. * Defines if texture must be inverted on Y axis (default is false)
  58150. */
  58151. invertY?: boolean | undefined,
  58152. /**
  58153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58154. */
  58155. samplingMode?: number);
  58156. /**
  58157. * Execute the current task
  58158. * @param scene defines the scene where you want your assets to be loaded
  58159. * @param onSuccess is a callback called when the task is successfully executed
  58160. * @param onError is a callback called if an error occurs
  58161. */
  58162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58163. }
  58164. /**
  58165. * Define a task used by AssetsManager to load cube textures
  58166. */
  58167. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58168. /**
  58169. * Defines the name of the task
  58170. */
  58171. name: string;
  58172. /**
  58173. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58174. */
  58175. url: string;
  58176. /**
  58177. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58178. */
  58179. extensions?: string[] | undefined;
  58180. /**
  58181. * Defines if mipmaps should not be generated (default is false)
  58182. */
  58183. noMipmap?: boolean | undefined;
  58184. /**
  58185. * Defines the explicit list of files (undefined by default)
  58186. */
  58187. files?: string[] | undefined;
  58188. /**
  58189. * Gets the loaded texture
  58190. */
  58191. texture: CubeTexture;
  58192. /**
  58193. * Callback called when the task is successful
  58194. */
  58195. onSuccess: (task: CubeTextureAssetTask) => void;
  58196. /**
  58197. * Callback called when the task is successful
  58198. */
  58199. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58200. /**
  58201. * Creates a new CubeTextureAssetTask
  58202. * @param name defines the name of the task
  58203. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58204. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58205. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58206. * @param files defines the explicit list of files (undefined by default)
  58207. */
  58208. constructor(
  58209. /**
  58210. * Defines the name of the task
  58211. */
  58212. name: string,
  58213. /**
  58214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58215. */
  58216. url: string,
  58217. /**
  58218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58219. */
  58220. extensions?: string[] | undefined,
  58221. /**
  58222. * Defines if mipmaps should not be generated (default is false)
  58223. */
  58224. noMipmap?: boolean | undefined,
  58225. /**
  58226. * Defines the explicit list of files (undefined by default)
  58227. */
  58228. files?: string[] | undefined);
  58229. /**
  58230. * Execute the current task
  58231. * @param scene defines the scene where you want your assets to be loaded
  58232. * @param onSuccess is a callback called when the task is successfully executed
  58233. * @param onError is a callback called if an error occurs
  58234. */
  58235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58236. }
  58237. /**
  58238. * Define a task used by AssetsManager to load HDR cube textures
  58239. */
  58240. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58241. /**
  58242. * Defines the name of the task
  58243. */
  58244. name: string;
  58245. /**
  58246. * Defines the location of the file to load
  58247. */
  58248. url: string;
  58249. /**
  58250. * Defines the desired size (the more it increases the longer the generation will be)
  58251. */
  58252. size: number;
  58253. /**
  58254. * Defines if mipmaps should not be generated (default is false)
  58255. */
  58256. noMipmap: boolean;
  58257. /**
  58258. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58259. */
  58260. generateHarmonics: boolean;
  58261. /**
  58262. * 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)
  58263. */
  58264. gammaSpace: boolean;
  58265. /**
  58266. * Internal Use Only
  58267. */
  58268. reserved: boolean;
  58269. /**
  58270. * Gets the loaded texture
  58271. */
  58272. texture: HDRCubeTexture;
  58273. /**
  58274. * Callback called when the task is successful
  58275. */
  58276. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58277. /**
  58278. * Callback called when the task is successful
  58279. */
  58280. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58281. /**
  58282. * Creates a new HDRCubeTextureAssetTask object
  58283. * @param name defines the name of the task
  58284. * @param url defines the location of the file to load
  58285. * @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.
  58286. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58287. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58288. * @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)
  58289. * @param reserved Internal use only
  58290. */
  58291. constructor(
  58292. /**
  58293. * Defines the name of the task
  58294. */
  58295. name: string,
  58296. /**
  58297. * Defines the location of the file to load
  58298. */
  58299. url: string,
  58300. /**
  58301. * Defines the desired size (the more it increases the longer the generation will be)
  58302. */
  58303. size: number,
  58304. /**
  58305. * Defines if mipmaps should not be generated (default is false)
  58306. */
  58307. noMipmap?: boolean,
  58308. /**
  58309. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58310. */
  58311. generateHarmonics?: boolean,
  58312. /**
  58313. * 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)
  58314. */
  58315. gammaSpace?: boolean,
  58316. /**
  58317. * Internal Use Only
  58318. */
  58319. reserved?: boolean);
  58320. /**
  58321. * Execute the current task
  58322. * @param scene defines the scene where you want your assets to be loaded
  58323. * @param onSuccess is a callback called when the task is successfully executed
  58324. * @param onError is a callback called if an error occurs
  58325. */
  58326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58327. }
  58328. /**
  58329. * Define a task used by AssetsManager to load Equirectangular cube textures
  58330. */
  58331. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58332. /**
  58333. * Defines the name of the task
  58334. */
  58335. name: string;
  58336. /**
  58337. * Defines the location of the file to load
  58338. */
  58339. url: string;
  58340. /**
  58341. * Defines the desired size (the more it increases the longer the generation will be)
  58342. */
  58343. size: number;
  58344. /**
  58345. * Defines if mipmaps should not be generated (default is false)
  58346. */
  58347. noMipmap: boolean;
  58348. /**
  58349. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58350. * but the standard material would require them in Gamma space) (default is true)
  58351. */
  58352. gammaSpace: boolean;
  58353. /**
  58354. * Gets the loaded texture
  58355. */
  58356. texture: EquiRectangularCubeTexture;
  58357. /**
  58358. * Callback called when the task is successful
  58359. */
  58360. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58361. /**
  58362. * Callback called when the task is successful
  58363. */
  58364. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58365. /**
  58366. * Creates a new EquiRectangularCubeTextureAssetTask object
  58367. * @param name defines the name of the task
  58368. * @param url defines the location of the file to load
  58369. * @param size defines the desired size (the more it increases the longer the generation will be)
  58370. * If the size is omitted this implies you are using a preprocessed cubemap.
  58371. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58372. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58373. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58374. * (default is true)
  58375. */
  58376. constructor(
  58377. /**
  58378. * Defines the name of the task
  58379. */
  58380. name: string,
  58381. /**
  58382. * Defines the location of the file to load
  58383. */
  58384. url: string,
  58385. /**
  58386. * Defines the desired size (the more it increases the longer the generation will be)
  58387. */
  58388. size: number,
  58389. /**
  58390. * Defines if mipmaps should not be generated (default is false)
  58391. */
  58392. noMipmap?: boolean,
  58393. /**
  58394. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58395. * but the standard material would require them in Gamma space) (default is true)
  58396. */
  58397. gammaSpace?: boolean);
  58398. /**
  58399. * Execute the current task
  58400. * @param scene defines the scene where you want your assets to be loaded
  58401. * @param onSuccess is a callback called when the task is successfully executed
  58402. * @param onError is a callback called if an error occurs
  58403. */
  58404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58405. }
  58406. /**
  58407. * This class can be used to easily import assets into a scene
  58408. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58409. */
  58410. export class AssetsManager {
  58411. private _scene;
  58412. private _isLoading;
  58413. protected _tasks: AbstractAssetTask[];
  58414. protected _waitingTasksCount: number;
  58415. protected _totalTasksCount: number;
  58416. /**
  58417. * Callback called when all tasks are processed
  58418. */
  58419. onFinish: (tasks: AbstractAssetTask[]) => void;
  58420. /**
  58421. * Callback called when a task is successful
  58422. */
  58423. onTaskSuccess: (task: AbstractAssetTask) => void;
  58424. /**
  58425. * Callback called when a task had an error
  58426. */
  58427. onTaskError: (task: AbstractAssetTask) => void;
  58428. /**
  58429. * Callback called when a task is done (whatever the result is)
  58430. */
  58431. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58432. /**
  58433. * Observable called when all tasks are processed
  58434. */
  58435. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58436. /**
  58437. * Observable called when a task had an error
  58438. */
  58439. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58440. /**
  58441. * Observable called when all tasks were executed
  58442. */
  58443. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58444. /**
  58445. * Observable called when a task is done (whatever the result is)
  58446. */
  58447. onProgressObservable: Observable<IAssetsProgressEvent>;
  58448. /**
  58449. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58451. */
  58452. useDefaultLoadingScreen: boolean;
  58453. /**
  58454. * Creates a new AssetsManager
  58455. * @param scene defines the scene to work on
  58456. */
  58457. constructor(scene: Scene);
  58458. /**
  58459. * Add a MeshAssetTask to the list of active tasks
  58460. * @param taskName defines the name of the new task
  58461. * @param meshesNames defines the name of meshes to load
  58462. * @param rootUrl defines the root url to use to locate files
  58463. * @param sceneFilename defines the filename of the scene file
  58464. * @returns a new MeshAssetTask object
  58465. */
  58466. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58467. /**
  58468. * Add a TextFileAssetTask to the list of active tasks
  58469. * @param taskName defines the name of the new task
  58470. * @param url defines the url of the file to load
  58471. * @returns a new TextFileAssetTask object
  58472. */
  58473. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58474. /**
  58475. * Add a BinaryFileAssetTask to the list of active tasks
  58476. * @param taskName defines the name of the new task
  58477. * @param url defines the url of the file to load
  58478. * @returns a new BinaryFileAssetTask object
  58479. */
  58480. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58481. /**
  58482. * Add a ImageAssetTask to the list of active tasks
  58483. * @param taskName defines the name of the new task
  58484. * @param url defines the url of the file to load
  58485. * @returns a new ImageAssetTask object
  58486. */
  58487. addImageTask(taskName: string, url: string): ImageAssetTask;
  58488. /**
  58489. * Add a TextureAssetTask to the list of active tasks
  58490. * @param taskName defines the name of the new task
  58491. * @param url defines the url of the file to load
  58492. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58493. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58494. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58495. * @returns a new TextureAssetTask object
  58496. */
  58497. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58498. /**
  58499. * Add a CubeTextureAssetTask to the list of active tasks
  58500. * @param taskName defines the name of the new task
  58501. * @param url defines the url of the file to load
  58502. * @param extensions defines the extension to use to load the cube map (can be null)
  58503. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58504. * @param files defines the list of files to load (can be null)
  58505. * @returns a new CubeTextureAssetTask object
  58506. */
  58507. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58508. /**
  58509. *
  58510. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58511. * @param taskName defines the name of the new task
  58512. * @param url defines the url of the file to load
  58513. * @param size defines the size you want for the cubemap (can be null)
  58514. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58515. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58516. * @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)
  58517. * @param reserved Internal use only
  58518. * @returns a new HDRCubeTextureAssetTask object
  58519. */
  58520. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58521. /**
  58522. *
  58523. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58524. * @param taskName defines the name of the new task
  58525. * @param url defines the url of the file to load
  58526. * @param size defines the size you want for the cubemap (can be null)
  58527. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58528. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58529. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58530. * @returns a new EquiRectangularCubeTextureAssetTask object
  58531. */
  58532. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58533. /**
  58534. * Remove a task from the assets manager.
  58535. * @param task the task to remove
  58536. */
  58537. removeTask(task: AbstractAssetTask): void;
  58538. private _decreaseWaitingTasksCount;
  58539. private _runTask;
  58540. /**
  58541. * Reset the AssetsManager and remove all tasks
  58542. * @return the current instance of the AssetsManager
  58543. */
  58544. reset(): AssetsManager;
  58545. /**
  58546. * Start the loading process
  58547. * @return the current instance of the AssetsManager
  58548. */
  58549. load(): AssetsManager;
  58550. /**
  58551. * Start the loading process as an async operation
  58552. * @return a promise returning the list of failed tasks
  58553. */
  58554. loadAsync(): Promise<void>;
  58555. }
  58556. }
  58557. declare module BABYLON {
  58558. /**
  58559. * Wrapper class for promise with external resolve and reject.
  58560. */
  58561. export class Deferred<T> {
  58562. /**
  58563. * The promise associated with this deferred object.
  58564. */
  58565. readonly promise: Promise<T>;
  58566. private _resolve;
  58567. private _reject;
  58568. /**
  58569. * The resolve method of the promise associated with this deferred object.
  58570. */
  58571. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58572. /**
  58573. * The reject method of the promise associated with this deferred object.
  58574. */
  58575. readonly reject: (reason?: any) => void;
  58576. /**
  58577. * Constructor for this deferred object.
  58578. */
  58579. constructor();
  58580. }
  58581. }
  58582. declare module BABYLON {
  58583. /**
  58584. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58585. */
  58586. export class MeshExploder {
  58587. private _centerMesh;
  58588. private _meshes;
  58589. private _meshesOrigins;
  58590. private _toCenterVectors;
  58591. private _scaledDirection;
  58592. private _newPosition;
  58593. private _centerPosition;
  58594. /**
  58595. * Explodes meshes from a center mesh.
  58596. * @param meshes The meshes to explode.
  58597. * @param centerMesh The mesh to be center of explosion.
  58598. */
  58599. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58600. private _setCenterMesh;
  58601. /**
  58602. * Get class name
  58603. * @returns "MeshExploder"
  58604. */
  58605. getClassName(): string;
  58606. /**
  58607. * "Exploded meshes"
  58608. * @returns Array of meshes with the centerMesh at index 0.
  58609. */
  58610. getMeshes(): Array<Mesh>;
  58611. /**
  58612. * Explodes meshes giving a specific direction
  58613. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58614. */
  58615. explode(direction?: number): void;
  58616. }
  58617. }
  58618. declare module BABYLON {
  58619. /**
  58620. * Class used to help managing file picking and drag'n'drop
  58621. */
  58622. export class FilesInput {
  58623. /**
  58624. * List of files ready to be loaded
  58625. */
  58626. static readonly FilesToLoad: {
  58627. [key: string]: File;
  58628. };
  58629. /**
  58630. * Callback called when a file is processed
  58631. */
  58632. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58633. private _engine;
  58634. private _currentScene;
  58635. private _sceneLoadedCallback;
  58636. private _progressCallback;
  58637. private _additionalRenderLoopLogicCallback;
  58638. private _textureLoadingCallback;
  58639. private _startingProcessingFilesCallback;
  58640. private _onReloadCallback;
  58641. private _errorCallback;
  58642. private _elementToMonitor;
  58643. private _sceneFileToLoad;
  58644. private _filesToLoad;
  58645. /**
  58646. * Creates a new FilesInput
  58647. * @param engine defines the rendering engine
  58648. * @param scene defines the hosting scene
  58649. * @param sceneLoadedCallback callback called when scene is loaded
  58650. * @param progressCallback callback called to track progress
  58651. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58652. * @param textureLoadingCallback callback called when a texture is loading
  58653. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58654. * @param onReloadCallback callback called when a reload is requested
  58655. * @param errorCallback callback call if an error occurs
  58656. */
  58657. 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);
  58658. private _dragEnterHandler;
  58659. private _dragOverHandler;
  58660. private _dropHandler;
  58661. /**
  58662. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58663. * @param elementToMonitor defines the DOM element to track
  58664. */
  58665. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58666. /**
  58667. * Release all associated resources
  58668. */
  58669. dispose(): void;
  58670. private renderFunction;
  58671. private drag;
  58672. private drop;
  58673. private _traverseFolder;
  58674. private _processFiles;
  58675. /**
  58676. * Load files from a drop event
  58677. * @param event defines the drop event to use as source
  58678. */
  58679. loadFiles(event: any): void;
  58680. private _processReload;
  58681. /**
  58682. * Reload the current scene from the loaded files
  58683. */
  58684. reload(): void;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58691. */
  58692. export class SceneOptimization {
  58693. /**
  58694. * Defines the priority of this optimization (0 by default which means first in the list)
  58695. */
  58696. priority: number;
  58697. /**
  58698. * Gets a string describing the action executed by the current optimization
  58699. * @returns description string
  58700. */
  58701. getDescription(): string;
  58702. /**
  58703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58704. * @param scene defines the current scene where to apply this optimization
  58705. * @param optimizer defines the current optimizer
  58706. * @returns true if everything that can be done was applied
  58707. */
  58708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58709. /**
  58710. * Creates the SceneOptimization object
  58711. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58712. * @param desc defines the description associated with the optimization
  58713. */
  58714. constructor(
  58715. /**
  58716. * Defines the priority of this optimization (0 by default which means first in the list)
  58717. */
  58718. priority?: number);
  58719. }
  58720. /**
  58721. * Defines an optimization used to reduce the size of render target textures
  58722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58723. */
  58724. export class TextureOptimization extends SceneOptimization {
  58725. /**
  58726. * Defines the priority of this optimization (0 by default which means first in the list)
  58727. */
  58728. priority: number;
  58729. /**
  58730. * 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
  58731. */
  58732. maximumSize: number;
  58733. /**
  58734. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58735. */
  58736. step: number;
  58737. /**
  58738. * Gets a string describing the action executed by the current optimization
  58739. * @returns description string
  58740. */
  58741. getDescription(): string;
  58742. /**
  58743. * Creates the TextureOptimization object
  58744. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58745. * @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
  58746. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58747. */
  58748. constructor(
  58749. /**
  58750. * Defines the priority of this optimization (0 by default which means first in the list)
  58751. */
  58752. priority?: number,
  58753. /**
  58754. * 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
  58755. */
  58756. maximumSize?: number,
  58757. /**
  58758. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58759. */
  58760. step?: number);
  58761. /**
  58762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58763. * @param scene defines the current scene where to apply this optimization
  58764. * @param optimizer defines the current optimizer
  58765. * @returns true if everything that can be done was applied
  58766. */
  58767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58768. }
  58769. /**
  58770. * Defines an optimization used to increase or decrease the rendering resolution
  58771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58772. */
  58773. export class HardwareScalingOptimization extends SceneOptimization {
  58774. /**
  58775. * Defines the priority of this optimization (0 by default which means first in the list)
  58776. */
  58777. priority: number;
  58778. /**
  58779. * Defines the maximum scale to use (2 by default)
  58780. */
  58781. maximumScale: number;
  58782. /**
  58783. * Defines the step to use between two passes (0.5 by default)
  58784. */
  58785. step: number;
  58786. private _currentScale;
  58787. private _directionOffset;
  58788. /**
  58789. * Gets a string describing the action executed by the current optimization
  58790. * @return description string
  58791. */
  58792. getDescription(): string;
  58793. /**
  58794. * Creates the HardwareScalingOptimization object
  58795. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58796. * @param maximumScale defines the maximum scale to use (2 by default)
  58797. * @param step defines the step to use between two passes (0.5 by default)
  58798. */
  58799. constructor(
  58800. /**
  58801. * Defines the priority of this optimization (0 by default which means first in the list)
  58802. */
  58803. priority?: number,
  58804. /**
  58805. * Defines the maximum scale to use (2 by default)
  58806. */
  58807. maximumScale?: number,
  58808. /**
  58809. * Defines the step to use between two passes (0.5 by default)
  58810. */
  58811. step?: number);
  58812. /**
  58813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58814. * @param scene defines the current scene where to apply this optimization
  58815. * @param optimizer defines the current optimizer
  58816. * @returns true if everything that can be done was applied
  58817. */
  58818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58819. }
  58820. /**
  58821. * Defines an optimization used to remove shadows
  58822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58823. */
  58824. export class ShadowsOptimization extends SceneOptimization {
  58825. /**
  58826. * Gets a string describing the action executed by the current optimization
  58827. * @return description string
  58828. */
  58829. getDescription(): string;
  58830. /**
  58831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58832. * @param scene defines the current scene where to apply this optimization
  58833. * @param optimizer defines the current optimizer
  58834. * @returns true if everything that can be done was applied
  58835. */
  58836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58837. }
  58838. /**
  58839. * Defines an optimization used to turn post-processes off
  58840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58841. */
  58842. export class PostProcessesOptimization extends SceneOptimization {
  58843. /**
  58844. * Gets a string describing the action executed by the current optimization
  58845. * @return description string
  58846. */
  58847. getDescription(): string;
  58848. /**
  58849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58850. * @param scene defines the current scene where to apply this optimization
  58851. * @param optimizer defines the current optimizer
  58852. * @returns true if everything that can be done was applied
  58853. */
  58854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58855. }
  58856. /**
  58857. * Defines an optimization used to turn lens flares off
  58858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58859. */
  58860. export class LensFlaresOptimization extends SceneOptimization {
  58861. /**
  58862. * Gets a string describing the action executed by the current optimization
  58863. * @return description string
  58864. */
  58865. getDescription(): string;
  58866. /**
  58867. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58868. * @param scene defines the current scene where to apply this optimization
  58869. * @param optimizer defines the current optimizer
  58870. * @returns true if everything that can be done was applied
  58871. */
  58872. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58873. }
  58874. /**
  58875. * Defines an optimization based on user defined callback.
  58876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58877. */
  58878. export class CustomOptimization extends SceneOptimization {
  58879. /**
  58880. * Callback called to apply the custom optimization.
  58881. */
  58882. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58883. /**
  58884. * Callback called to get custom description
  58885. */
  58886. onGetDescription: () => string;
  58887. /**
  58888. * Gets a string describing the action executed by the current optimization
  58889. * @returns description string
  58890. */
  58891. getDescription(): string;
  58892. /**
  58893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58894. * @param scene defines the current scene where to apply this optimization
  58895. * @param optimizer defines the current optimizer
  58896. * @returns true if everything that can be done was applied
  58897. */
  58898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58899. }
  58900. /**
  58901. * Defines an optimization used to turn particles off
  58902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58903. */
  58904. export class ParticlesOptimization extends SceneOptimization {
  58905. /**
  58906. * Gets a string describing the action executed by the current optimization
  58907. * @return description string
  58908. */
  58909. getDescription(): string;
  58910. /**
  58911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58912. * @param scene defines the current scene where to apply this optimization
  58913. * @param optimizer defines the current optimizer
  58914. * @returns true if everything that can be done was applied
  58915. */
  58916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58917. }
  58918. /**
  58919. * Defines an optimization used to turn render targets off
  58920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58921. */
  58922. export class RenderTargetsOptimization extends SceneOptimization {
  58923. /**
  58924. * Gets a string describing the action executed by the current optimization
  58925. * @return description string
  58926. */
  58927. getDescription(): string;
  58928. /**
  58929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58930. * @param scene defines the current scene where to apply this optimization
  58931. * @param optimizer defines the current optimizer
  58932. * @returns true if everything that can be done was applied
  58933. */
  58934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58935. }
  58936. /**
  58937. * Defines an optimization used to merge meshes with compatible materials
  58938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58939. */
  58940. export class MergeMeshesOptimization extends SceneOptimization {
  58941. private static _UpdateSelectionTree;
  58942. /**
  58943. * Gets or sets a boolean which defines if optimization octree has to be updated
  58944. */
  58945. /**
  58946. * Gets or sets a boolean which defines if optimization octree has to be updated
  58947. */
  58948. static UpdateSelectionTree: boolean;
  58949. /**
  58950. * Gets a string describing the action executed by the current optimization
  58951. * @return description string
  58952. */
  58953. getDescription(): string;
  58954. private _canBeMerged;
  58955. /**
  58956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58957. * @param scene defines the current scene where to apply this optimization
  58958. * @param optimizer defines the current optimizer
  58959. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58960. * @returns true if everything that can be done was applied
  58961. */
  58962. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58963. }
  58964. /**
  58965. * Defines a list of options used by SceneOptimizer
  58966. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58967. */
  58968. export class SceneOptimizerOptions {
  58969. /**
  58970. * Defines the target frame rate to reach (60 by default)
  58971. */
  58972. targetFrameRate: number;
  58973. /**
  58974. * Defines the interval between two checkes (2000ms by default)
  58975. */
  58976. trackerDuration: number;
  58977. /**
  58978. * Gets the list of optimizations to apply
  58979. */
  58980. optimizations: SceneOptimization[];
  58981. /**
  58982. * Creates a new list of options used by SceneOptimizer
  58983. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58984. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58985. */
  58986. constructor(
  58987. /**
  58988. * Defines the target frame rate to reach (60 by default)
  58989. */
  58990. targetFrameRate?: number,
  58991. /**
  58992. * Defines the interval between two checkes (2000ms by default)
  58993. */
  58994. trackerDuration?: number);
  58995. /**
  58996. * Add a new optimization
  58997. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58998. * @returns the current SceneOptimizerOptions
  58999. */
  59000. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59001. /**
  59002. * Add a new custom optimization
  59003. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59004. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59005. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59006. * @returns the current SceneOptimizerOptions
  59007. */
  59008. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59009. /**
  59010. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59011. * @param targetFrameRate defines the target frame rate (60 by default)
  59012. * @returns a SceneOptimizerOptions object
  59013. */
  59014. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59015. /**
  59016. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59017. * @param targetFrameRate defines the target frame rate (60 by default)
  59018. * @returns a SceneOptimizerOptions object
  59019. */
  59020. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59021. /**
  59022. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59023. * @param targetFrameRate defines the target frame rate (60 by default)
  59024. * @returns a SceneOptimizerOptions object
  59025. */
  59026. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59027. }
  59028. /**
  59029. * Class used to run optimizations in order to reach a target frame rate
  59030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59031. */
  59032. export class SceneOptimizer implements IDisposable {
  59033. private _isRunning;
  59034. private _options;
  59035. private _scene;
  59036. private _currentPriorityLevel;
  59037. private _targetFrameRate;
  59038. private _trackerDuration;
  59039. private _currentFrameRate;
  59040. private _sceneDisposeObserver;
  59041. private _improvementMode;
  59042. /**
  59043. * Defines an observable called when the optimizer reaches the target frame rate
  59044. */
  59045. onSuccessObservable: Observable<SceneOptimizer>;
  59046. /**
  59047. * Defines an observable called when the optimizer enables an optimization
  59048. */
  59049. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59050. /**
  59051. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59052. */
  59053. onFailureObservable: Observable<SceneOptimizer>;
  59054. /**
  59055. * Gets a boolean indicating if the optimizer is in improvement mode
  59056. */
  59057. readonly isInImprovementMode: boolean;
  59058. /**
  59059. * Gets the current priority level (0 at start)
  59060. */
  59061. readonly currentPriorityLevel: number;
  59062. /**
  59063. * Gets the current frame rate checked by the SceneOptimizer
  59064. */
  59065. readonly currentFrameRate: number;
  59066. /**
  59067. * Gets or sets the current target frame rate (60 by default)
  59068. */
  59069. /**
  59070. * Gets or sets the current target frame rate (60 by default)
  59071. */
  59072. targetFrameRate: number;
  59073. /**
  59074. * Gets or sets the current interval between two checks (every 2000ms by default)
  59075. */
  59076. /**
  59077. * Gets or sets the current interval between two checks (every 2000ms by default)
  59078. */
  59079. trackerDuration: number;
  59080. /**
  59081. * Gets the list of active optimizations
  59082. */
  59083. readonly optimizations: SceneOptimization[];
  59084. /**
  59085. * Creates a new SceneOptimizer
  59086. * @param scene defines the scene to work on
  59087. * @param options defines the options to use with the SceneOptimizer
  59088. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59089. * @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)
  59090. */
  59091. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59092. /**
  59093. * Stops the current optimizer
  59094. */
  59095. stop(): void;
  59096. /**
  59097. * Reset the optimizer to initial step (current priority level = 0)
  59098. */
  59099. reset(): void;
  59100. /**
  59101. * Start the optimizer. By default it will try to reach a specific framerate
  59102. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59103. */
  59104. start(): void;
  59105. private _checkCurrentState;
  59106. /**
  59107. * Release all resources
  59108. */
  59109. dispose(): void;
  59110. /**
  59111. * Helper function to create a SceneOptimizer with one single line of code
  59112. * @param scene defines the scene to work on
  59113. * @param options defines the options to use with the SceneOptimizer
  59114. * @param onSuccess defines a callback to call on success
  59115. * @param onFailure defines a callback to call on failure
  59116. * @returns the new SceneOptimizer object
  59117. */
  59118. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59119. }
  59120. }
  59121. declare module BABYLON {
  59122. /**
  59123. * Class used to serialize a scene into a string
  59124. */
  59125. export class SceneSerializer {
  59126. /**
  59127. * Clear cache used by a previous serialization
  59128. */
  59129. static ClearCache(): void;
  59130. /**
  59131. * Serialize a scene into a JSON compatible object
  59132. * @param scene defines the scene to serialize
  59133. * @returns a JSON compatible object
  59134. */
  59135. static Serialize(scene: Scene): any;
  59136. /**
  59137. * Serialize a mesh into a JSON compatible object
  59138. * @param toSerialize defines the mesh to serialize
  59139. * @param withParents defines if parents must be serialized as well
  59140. * @param withChildren defines if children must be serialized as well
  59141. * @returns a JSON compatible object
  59142. */
  59143. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * Class used to host texture specific utilities
  59149. */
  59150. export class TextureTools {
  59151. /**
  59152. * Uses the GPU to create a copy texture rescaled at a given size
  59153. * @param texture Texture to copy from
  59154. * @param width defines the desired width
  59155. * @param height defines the desired height
  59156. * @param useBilinearMode defines if bilinear mode has to be used
  59157. * @return the generated texture
  59158. */
  59159. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59160. }
  59161. }
  59162. declare module BABYLON {
  59163. /**
  59164. * This represents the different options available for the video capture.
  59165. */
  59166. export interface VideoRecorderOptions {
  59167. /** Defines the mime type of the video. */
  59168. mimeType: string;
  59169. /** Defines the FPS the video should be recorded at. */
  59170. fps: number;
  59171. /** Defines the chunk size for the recording data. */
  59172. recordChunckSize: number;
  59173. /** The audio tracks to attach to the recording. */
  59174. audioTracks?: MediaStreamTrack[];
  59175. }
  59176. /**
  59177. * This can help with recording videos from BabylonJS.
  59178. * This is based on the available WebRTC functionalities of the browser.
  59179. *
  59180. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59181. */
  59182. export class VideoRecorder {
  59183. private static readonly _defaultOptions;
  59184. /**
  59185. * Returns whether or not the VideoRecorder is available in your browser.
  59186. * @param engine Defines the Babylon Engine.
  59187. * @returns true if supported otherwise false.
  59188. */
  59189. static IsSupported(engine: Engine): boolean;
  59190. private readonly _options;
  59191. private _canvas;
  59192. private _mediaRecorder;
  59193. private _recordedChunks;
  59194. private _fileName;
  59195. private _resolve;
  59196. private _reject;
  59197. /**
  59198. * True when a recording is already in progress.
  59199. */
  59200. readonly isRecording: boolean;
  59201. /**
  59202. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59203. * @param engine Defines the BabylonJS Engine you wish to record.
  59204. * @param options Defines options that can be used to customize the capture.
  59205. */
  59206. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59207. /**
  59208. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59209. */
  59210. stopRecording(): void;
  59211. /**
  59212. * Starts recording the canvas for a max duration specified in parameters.
  59213. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59214. * If null no automatic download will start and you can rely on the promise to get the data back.
  59215. * @param maxDuration Defines the maximum recording time in seconds.
  59216. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59217. * @return A promise callback at the end of the recording with the video data in Blob.
  59218. */
  59219. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59220. /**
  59221. * Releases internal resources used during the recording.
  59222. */
  59223. dispose(): void;
  59224. private _handleDataAvailable;
  59225. private _handleError;
  59226. private _handleStop;
  59227. }
  59228. }
  59229. declare module BABYLON {
  59230. /**
  59231. * Class containing a set of static utilities functions for screenshots
  59232. */
  59233. export class ScreenshotTools {
  59234. /**
  59235. * Captures a screenshot of the current rendering
  59236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59237. * @param engine defines the rendering engine
  59238. * @param camera defines the source camera
  59239. * @param size This parameter can be set to a single number or to an object with the
  59240. * following (optional) properties: precision, width, height. If a single number is passed,
  59241. * it will be used for both width and height. If an object is passed, the screenshot size
  59242. * will be derived from the parameters. The precision property is a multiplier allowing
  59243. * rendering at a higher or lower resolution
  59244. * @param successCallback defines the callback receives a single parameter which contains the
  59245. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59246. * src parameter of an <img> to display it
  59247. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59248. * Check your browser for supported MIME types
  59249. */
  59250. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59251. /**
  59252. * Generates an image screenshot from the specified camera.
  59253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59254. * @param engine The engine to use for rendering
  59255. * @param camera The camera to use for rendering
  59256. * @param size This parameter can be set to a single number or to an object with the
  59257. * following (optional) properties: precision, width, height. If a single number is passed,
  59258. * it will be used for both width and height. If an object is passed, the screenshot size
  59259. * will be derived from the parameters. The precision property is a multiplier allowing
  59260. * rendering at a higher or lower resolution
  59261. * @param successCallback The callback receives a single parameter which contains the
  59262. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59263. * src parameter of an <img> to display it
  59264. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59265. * Check your browser for supported MIME types
  59266. * @param samples Texture samples (default: 1)
  59267. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59268. * @param fileName A name for for the downloaded file.
  59269. */
  59270. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59271. }
  59272. }
  59273. declare module BABYLON {
  59274. /**
  59275. * A cursor which tracks a point on a path
  59276. */
  59277. export class PathCursor {
  59278. private path;
  59279. /**
  59280. * Stores path cursor callbacks for when an onchange event is triggered
  59281. */
  59282. private _onchange;
  59283. /**
  59284. * The value of the path cursor
  59285. */
  59286. value: number;
  59287. /**
  59288. * The animation array of the path cursor
  59289. */
  59290. animations: Animation[];
  59291. /**
  59292. * Initializes the path cursor
  59293. * @param path The path to track
  59294. */
  59295. constructor(path: Path2);
  59296. /**
  59297. * Gets the cursor point on the path
  59298. * @returns A point on the path cursor at the cursor location
  59299. */
  59300. getPoint(): Vector3;
  59301. /**
  59302. * Moves the cursor ahead by the step amount
  59303. * @param step The amount to move the cursor forward
  59304. * @returns This path cursor
  59305. */
  59306. moveAhead(step?: number): PathCursor;
  59307. /**
  59308. * Moves the cursor behind by the step amount
  59309. * @param step The amount to move the cursor back
  59310. * @returns This path cursor
  59311. */
  59312. moveBack(step?: number): PathCursor;
  59313. /**
  59314. * Moves the cursor by the step amount
  59315. * If the step amount is greater than one, an exception is thrown
  59316. * @param step The amount to move the cursor
  59317. * @returns This path cursor
  59318. */
  59319. move(step: number): PathCursor;
  59320. /**
  59321. * Ensures that the value is limited between zero and one
  59322. * @returns This path cursor
  59323. */
  59324. private ensureLimits;
  59325. /**
  59326. * Runs onchange callbacks on change (used by the animation engine)
  59327. * @returns This path cursor
  59328. */
  59329. private raiseOnChange;
  59330. /**
  59331. * Executes a function on change
  59332. * @param f A path cursor onchange callback
  59333. * @returns This path cursor
  59334. */
  59335. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59336. }
  59337. }
  59338. declare module BABYLON {
  59339. /** @hidden */
  59340. export var blurPixelShader: {
  59341. name: string;
  59342. shader: string;
  59343. };
  59344. }
  59345. declare module BABYLON {
  59346. /** @hidden */
  59347. export var pointCloudVertexDeclaration: {
  59348. name: string;
  59349. shader: string;
  59350. };
  59351. }
  59352. // Mixins
  59353. interface Window {
  59354. mozIndexedDB: IDBFactory;
  59355. webkitIndexedDB: IDBFactory;
  59356. msIndexedDB: IDBFactory;
  59357. webkitURL: typeof URL;
  59358. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59359. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59360. WebGLRenderingContext: WebGLRenderingContext;
  59361. MSGesture: MSGesture;
  59362. CANNON: any;
  59363. AudioContext: AudioContext;
  59364. webkitAudioContext: AudioContext;
  59365. PointerEvent: any;
  59366. Math: Math;
  59367. Uint8Array: Uint8ArrayConstructor;
  59368. Float32Array: Float32ArrayConstructor;
  59369. mozURL: typeof URL;
  59370. msURL: typeof URL;
  59371. VRFrameData: any; // WebVR, from specs 1.1
  59372. DracoDecoderModule: any;
  59373. setImmediate(handler: (...args: any[]) => void): number;
  59374. }
  59375. interface HTMLCanvasElement {
  59376. requestPointerLock(): void;
  59377. msRequestPointerLock?(): void;
  59378. mozRequestPointerLock?(): void;
  59379. webkitRequestPointerLock?(): void;
  59380. /** Track wether a record is in progress */
  59381. isRecording: boolean;
  59382. /** Capture Stream method defined by some browsers */
  59383. captureStream(fps?: number): MediaStream;
  59384. }
  59385. interface CanvasRenderingContext2D {
  59386. msImageSmoothingEnabled: boolean;
  59387. }
  59388. interface MouseEvent {
  59389. mozMovementX: number;
  59390. mozMovementY: number;
  59391. webkitMovementX: number;
  59392. webkitMovementY: number;
  59393. msMovementX: number;
  59394. msMovementY: number;
  59395. }
  59396. interface Navigator {
  59397. mozGetVRDevices: (any: any) => any;
  59398. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59399. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59400. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59401. webkitGetGamepads(): Gamepad[];
  59402. msGetGamepads(): Gamepad[];
  59403. webkitGamepads(): Gamepad[];
  59404. }
  59405. interface HTMLVideoElement {
  59406. mozSrcObject: any;
  59407. }
  59408. interface Math {
  59409. fround(x: number): number;
  59410. imul(a: number, b: number): number;
  59411. }
  59412. interface WebGLRenderingContext {
  59413. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59414. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59415. vertexAttribDivisor(index: number, divisor: number): void;
  59416. createVertexArray(): any;
  59417. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59418. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59419. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59420. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59421. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59422. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59423. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59424. // Queries
  59425. createQuery(): WebGLQuery;
  59426. deleteQuery(query: WebGLQuery): void;
  59427. beginQuery(target: number, query: WebGLQuery): void;
  59428. endQuery(target: number): void;
  59429. getQueryParameter(query: WebGLQuery, pname: number): any;
  59430. getQuery(target: number, pname: number): any;
  59431. MAX_SAMPLES: number;
  59432. RGBA8: number;
  59433. READ_FRAMEBUFFER: number;
  59434. DRAW_FRAMEBUFFER: number;
  59435. UNIFORM_BUFFER: number;
  59436. HALF_FLOAT_OES: number;
  59437. RGBA16F: number;
  59438. RGBA32F: number;
  59439. R32F: number;
  59440. RG32F: number;
  59441. RGB32F: number;
  59442. R16F: number;
  59443. RG16F: number;
  59444. RGB16F: number;
  59445. RED: number;
  59446. RG: number;
  59447. R8: number;
  59448. RG8: number;
  59449. UNSIGNED_INT_24_8: number;
  59450. DEPTH24_STENCIL8: number;
  59451. /* Multiple Render Targets */
  59452. drawBuffers(buffers: number[]): void;
  59453. readBuffer(src: number): void;
  59454. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59455. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59456. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59457. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59458. // Occlusion Query
  59459. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59460. ANY_SAMPLES_PASSED: number;
  59461. QUERY_RESULT_AVAILABLE: number;
  59462. QUERY_RESULT: number;
  59463. }
  59464. interface WebGLProgram {
  59465. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59466. }
  59467. interface EXT_disjoint_timer_query {
  59468. QUERY_COUNTER_BITS_EXT: number;
  59469. TIME_ELAPSED_EXT: number;
  59470. TIMESTAMP_EXT: number;
  59471. GPU_DISJOINT_EXT: number;
  59472. QUERY_RESULT_EXT: number;
  59473. QUERY_RESULT_AVAILABLE_EXT: number;
  59474. queryCounterEXT(query: WebGLQuery, target: number): void;
  59475. createQueryEXT(): WebGLQuery;
  59476. beginQueryEXT(target: number, query: WebGLQuery): void;
  59477. endQueryEXT(target: number): void;
  59478. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59479. deleteQueryEXT(query: WebGLQuery): void;
  59480. }
  59481. interface WebGLUniformLocation {
  59482. _currentState: any;
  59483. }
  59484. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59485. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59486. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59487. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59488. interface WebGLRenderingContext {
  59489. readonly RASTERIZER_DISCARD: number;
  59490. readonly DEPTH_COMPONENT24: number;
  59491. readonly TEXTURE_3D: number;
  59492. readonly TEXTURE_2D_ARRAY: number;
  59493. readonly TEXTURE_COMPARE_FUNC: number;
  59494. readonly TEXTURE_COMPARE_MODE: number;
  59495. readonly COMPARE_REF_TO_TEXTURE: number;
  59496. readonly TEXTURE_WRAP_R: number;
  59497. readonly HALF_FLOAT: number;
  59498. readonly RGB8: number;
  59499. readonly RED_INTEGER: number;
  59500. readonly RG_INTEGER: number;
  59501. readonly RGB_INTEGER: number;
  59502. readonly RGBA_INTEGER: number;
  59503. readonly R8_SNORM: number;
  59504. readonly RG8_SNORM: number;
  59505. readonly RGB8_SNORM: number;
  59506. readonly RGBA8_SNORM: number;
  59507. readonly R8I: number;
  59508. readonly RG8I: number;
  59509. readonly RGB8I: number;
  59510. readonly RGBA8I: number;
  59511. readonly R8UI: number;
  59512. readonly RG8UI: number;
  59513. readonly RGB8UI: number;
  59514. readonly RGBA8UI: number;
  59515. readonly R16I: number;
  59516. readonly RG16I: number;
  59517. readonly RGB16I: number;
  59518. readonly RGBA16I: number;
  59519. readonly R16UI: number;
  59520. readonly RG16UI: number;
  59521. readonly RGB16UI: number;
  59522. readonly RGBA16UI: number;
  59523. readonly R32I: number;
  59524. readonly RG32I: number;
  59525. readonly RGB32I: number;
  59526. readonly RGBA32I: number;
  59527. readonly R32UI: number;
  59528. readonly RG32UI: number;
  59529. readonly RGB32UI: number;
  59530. readonly RGBA32UI: number;
  59531. readonly RGB10_A2UI: number;
  59532. readonly R11F_G11F_B10F: number;
  59533. readonly RGB9_E5: number;
  59534. readonly RGB10_A2: number;
  59535. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59536. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59537. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59538. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59539. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59540. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59541. 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;
  59542. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59543. readonly TRANSFORM_FEEDBACK: number;
  59544. readonly INTERLEAVED_ATTRIBS: number;
  59545. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59546. createTransformFeedback(): WebGLTransformFeedback;
  59547. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59548. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59549. beginTransformFeedback(primitiveMode: number): void;
  59550. endTransformFeedback(): void;
  59551. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59552. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59553. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59554. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59555. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59556. }
  59557. interface ImageBitmap {
  59558. readonly width: number;
  59559. readonly height: number;
  59560. close(): void;
  59561. }
  59562. interface WebGLQuery extends WebGLObject {
  59563. }
  59564. declare var WebGLQuery: {
  59565. prototype: WebGLQuery;
  59566. new(): WebGLQuery;
  59567. };
  59568. interface WebGLSampler extends WebGLObject {
  59569. }
  59570. declare var WebGLSampler: {
  59571. prototype: WebGLSampler;
  59572. new(): WebGLSampler;
  59573. };
  59574. interface WebGLSync extends WebGLObject {
  59575. }
  59576. declare var WebGLSync: {
  59577. prototype: WebGLSync;
  59578. new(): WebGLSync;
  59579. };
  59580. interface WebGLTransformFeedback extends WebGLObject {
  59581. }
  59582. declare var WebGLTransformFeedback: {
  59583. prototype: WebGLTransformFeedback;
  59584. new(): WebGLTransformFeedback;
  59585. };
  59586. interface WebGLVertexArrayObject extends WebGLObject {
  59587. }
  59588. declare var WebGLVertexArrayObject: {
  59589. prototype: WebGLVertexArrayObject;
  59590. new(): WebGLVertexArrayObject;
  59591. };
  59592. // Type definitions for WebVR API
  59593. // Project: https://w3c.github.io/webvr/
  59594. // Definitions by: six a <https://github.com/lostfictions>
  59595. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59596. interface VRDisplay extends EventTarget {
  59597. /**
  59598. * Dictionary of capabilities describing the VRDisplay.
  59599. */
  59600. readonly capabilities: VRDisplayCapabilities;
  59601. /**
  59602. * z-depth defining the far plane of the eye view frustum
  59603. * enables mapping of values in the render target depth
  59604. * attachment to scene coordinates. Initially set to 10000.0.
  59605. */
  59606. depthFar: number;
  59607. /**
  59608. * z-depth defining the near plane of the eye view frustum
  59609. * enables mapping of values in the render target depth
  59610. * attachment to scene coordinates. Initially set to 0.01.
  59611. */
  59612. depthNear: number;
  59613. /**
  59614. * An identifier for this distinct VRDisplay. Used as an
  59615. * association point in the Gamepad API.
  59616. */
  59617. readonly displayId: number;
  59618. /**
  59619. * A display name, a user-readable name identifying it.
  59620. */
  59621. readonly displayName: string;
  59622. readonly isConnected: boolean;
  59623. readonly isPresenting: boolean;
  59624. /**
  59625. * If this VRDisplay supports room-scale experiences, the optional
  59626. * stage attribute contains details on the room-scale parameters.
  59627. */
  59628. readonly stageParameters: VRStageParameters | null;
  59629. /**
  59630. * Passing the value returned by `requestAnimationFrame` to
  59631. * `cancelAnimationFrame` will unregister the callback.
  59632. * @param handle Define the hanle of the request to cancel
  59633. */
  59634. cancelAnimationFrame(handle: number): void;
  59635. /**
  59636. * Stops presenting to the VRDisplay.
  59637. * @returns a promise to know when it stopped
  59638. */
  59639. exitPresent(): Promise<void>;
  59640. /**
  59641. * Return the current VREyeParameters for the given eye.
  59642. * @param whichEye Define the eye we want the parameter for
  59643. * @returns the eye parameters
  59644. */
  59645. getEyeParameters(whichEye: string): VREyeParameters;
  59646. /**
  59647. * Populates the passed VRFrameData with the information required to render
  59648. * the current frame.
  59649. * @param frameData Define the data structure to populate
  59650. * @returns true if ok otherwise false
  59651. */
  59652. getFrameData(frameData: VRFrameData): boolean;
  59653. /**
  59654. * Get the layers currently being presented.
  59655. * @returns the list of VR layers
  59656. */
  59657. getLayers(): VRLayer[];
  59658. /**
  59659. * Return a VRPose containing the future predicted pose of the VRDisplay
  59660. * when the current frame will be presented. The value returned will not
  59661. * change until JavaScript has returned control to the browser.
  59662. *
  59663. * The VRPose will contain the position, orientation, velocity,
  59664. * and acceleration of each of these properties.
  59665. * @returns the pose object
  59666. */
  59667. getPose(): VRPose;
  59668. /**
  59669. * Return the current instantaneous pose of the VRDisplay, with no
  59670. * prediction applied.
  59671. * @returns the current instantaneous pose
  59672. */
  59673. getImmediatePose(): VRPose;
  59674. /**
  59675. * The callback passed to `requestAnimationFrame` will be called
  59676. * any time a new frame should be rendered. When the VRDisplay is
  59677. * presenting the callback will be called at the native refresh
  59678. * rate of the HMD. When not presenting this function acts
  59679. * identically to how window.requestAnimationFrame acts. Content should
  59680. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59681. * asynchronously from other displays and at differing refresh rates.
  59682. * @param callback Define the eaction to run next frame
  59683. * @returns the request handle it
  59684. */
  59685. requestAnimationFrame(callback: FrameRequestCallback): number;
  59686. /**
  59687. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59688. * Repeat calls while already presenting will update the VRLayers being displayed.
  59689. * @param layers Define the list of layer to present
  59690. * @returns a promise to know when the request has been fulfilled
  59691. */
  59692. requestPresent(layers: VRLayer[]): Promise<void>;
  59693. /**
  59694. * Reset the pose for this display, treating its current position and
  59695. * orientation as the "origin/zero" values. VRPose.position,
  59696. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59697. * updated when calling resetPose(). This should be called in only
  59698. * sitting-space experiences.
  59699. */
  59700. resetPose(): void;
  59701. /**
  59702. * The VRLayer provided to the VRDisplay will be captured and presented
  59703. * in the HMD. Calling this function has the same effect on the source
  59704. * canvas as any other operation that uses its source image, and canvases
  59705. * created without preserveDrawingBuffer set to true will be cleared.
  59706. * @param pose Define the pose to submit
  59707. */
  59708. submitFrame(pose?: VRPose): void;
  59709. }
  59710. declare var VRDisplay: {
  59711. prototype: VRDisplay;
  59712. new(): VRDisplay;
  59713. };
  59714. interface VRLayer {
  59715. leftBounds?: number[] | Float32Array | null;
  59716. rightBounds?: number[] | Float32Array | null;
  59717. source?: HTMLCanvasElement | null;
  59718. }
  59719. interface VRDisplayCapabilities {
  59720. readonly canPresent: boolean;
  59721. readonly hasExternalDisplay: boolean;
  59722. readonly hasOrientation: boolean;
  59723. readonly hasPosition: boolean;
  59724. readonly maxLayers: number;
  59725. }
  59726. interface VREyeParameters {
  59727. /** @deprecated */
  59728. readonly fieldOfView: VRFieldOfView;
  59729. readonly offset: Float32Array;
  59730. readonly renderHeight: number;
  59731. readonly renderWidth: number;
  59732. }
  59733. interface VRFieldOfView {
  59734. readonly downDegrees: number;
  59735. readonly leftDegrees: number;
  59736. readonly rightDegrees: number;
  59737. readonly upDegrees: number;
  59738. }
  59739. interface VRFrameData {
  59740. readonly leftProjectionMatrix: Float32Array;
  59741. readonly leftViewMatrix: Float32Array;
  59742. readonly pose: VRPose;
  59743. readonly rightProjectionMatrix: Float32Array;
  59744. readonly rightViewMatrix: Float32Array;
  59745. readonly timestamp: number;
  59746. }
  59747. interface VRPose {
  59748. readonly angularAcceleration: Float32Array | null;
  59749. readonly angularVelocity: Float32Array | null;
  59750. readonly linearAcceleration: Float32Array | null;
  59751. readonly linearVelocity: Float32Array | null;
  59752. readonly orientation: Float32Array | null;
  59753. readonly position: Float32Array | null;
  59754. readonly timestamp: number;
  59755. }
  59756. interface VRStageParameters {
  59757. sittingToStandingTransform?: Float32Array;
  59758. sizeX?: number;
  59759. sizeY?: number;
  59760. }
  59761. interface Navigator {
  59762. getVRDisplays(): Promise<VRDisplay[]>;
  59763. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59764. }
  59765. interface Window {
  59766. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59767. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59768. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59769. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59770. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59771. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59772. }
  59773. interface Gamepad {
  59774. readonly displayId: number;
  59775. }
  59776. interface XRDevice {
  59777. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59778. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59779. }
  59780. interface XRSession {
  59781. getInputSources(): Array<any>;
  59782. baseLayer: XRWebGLLayer;
  59783. requestFrameOfReference(type: string): Promise<void>;
  59784. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59785. end(): Promise<void>;
  59786. requestAnimationFrame: Function;
  59787. addEventListener: Function;
  59788. }
  59789. interface XRSessionCreationOptions {
  59790. outputContext?: WebGLRenderingContext | null;
  59791. immersive?: boolean;
  59792. environmentIntegration?: boolean;
  59793. }
  59794. interface XRLayer {
  59795. getViewport: Function;
  59796. framebufferWidth: number;
  59797. framebufferHeight: number;
  59798. }
  59799. interface XRView {
  59800. projectionMatrix: Float32Array;
  59801. }
  59802. interface XRFrame {
  59803. getDevicePose: Function;
  59804. getInputPose: Function;
  59805. views: Array<XRView>;
  59806. baseLayer: XRLayer;
  59807. }
  59808. interface XRFrameOfReference {
  59809. }
  59810. interface XRWebGLLayer extends XRLayer {
  59811. framebuffer: WebGLFramebuffer;
  59812. }
  59813. declare var XRWebGLLayer: {
  59814. prototype: XRWebGLLayer;
  59815. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59816. };
  59817. declare module BABYLON.GUI {
  59818. /**
  59819. * Class used to specific a value and its associated unit
  59820. */
  59821. export class ValueAndUnit {
  59822. /** defines the unit to store */
  59823. unit: number;
  59824. /** defines a boolean indicating if the value can be negative */
  59825. negativeValueAllowed: boolean;
  59826. private _value;
  59827. private _originalUnit;
  59828. /**
  59829. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59830. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59831. */
  59832. ignoreAdaptiveScaling: boolean;
  59833. /**
  59834. * Creates a new ValueAndUnit
  59835. * @param value defines the value to store
  59836. * @param unit defines the unit to store
  59837. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59838. */
  59839. constructor(value: number,
  59840. /** defines the unit to store */
  59841. unit?: number,
  59842. /** defines a boolean indicating if the value can be negative */
  59843. negativeValueAllowed?: boolean);
  59844. /** Gets a boolean indicating if the value is a percentage */
  59845. readonly isPercentage: boolean;
  59846. /** Gets a boolean indicating if the value is store as pixel */
  59847. readonly isPixel: boolean;
  59848. /** Gets direct internal value */
  59849. readonly internalValue: number;
  59850. /**
  59851. * Gets value as pixel
  59852. * @param host defines the root host
  59853. * @param refValue defines the reference value for percentages
  59854. * @returns the value as pixel
  59855. */
  59856. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59857. /**
  59858. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59859. * @param value defines the value to store
  59860. * @param unit defines the unit to store
  59861. * @returns the current ValueAndUnit
  59862. */
  59863. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59864. /**
  59865. * Gets the value accordingly to its unit
  59866. * @param host defines the root host
  59867. * @returns the value
  59868. */
  59869. getValue(host: AdvancedDynamicTexture): number;
  59870. /**
  59871. * Gets a string representation of the value
  59872. * @param host defines the root host
  59873. * @param decimals defines an optional number of decimals to display
  59874. * @returns a string
  59875. */
  59876. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59877. /**
  59878. * Store a value parsed from a string
  59879. * @param source defines the source string
  59880. * @returns true if the value was successfully parsed
  59881. */
  59882. fromString(source: string | number): boolean;
  59883. private static _Regex;
  59884. private static _UNITMODE_PERCENTAGE;
  59885. private static _UNITMODE_PIXEL;
  59886. /** UNITMODE_PERCENTAGE */
  59887. static readonly UNITMODE_PERCENTAGE: number;
  59888. /** UNITMODE_PIXEL */
  59889. static readonly UNITMODE_PIXEL: number;
  59890. }
  59891. }
  59892. declare module BABYLON.GUI {
  59893. /**
  59894. * Define a style used by control to automatically setup properties based on a template.
  59895. * Only support font related properties so far
  59896. */
  59897. export class Style implements BABYLON.IDisposable {
  59898. private _fontFamily;
  59899. private _fontStyle;
  59900. private _fontWeight;
  59901. /** @hidden */
  59902. _host: AdvancedDynamicTexture;
  59903. /** @hidden */
  59904. _fontSize: ValueAndUnit;
  59905. /**
  59906. * BABYLON.Observable raised when the style values are changed
  59907. */
  59908. onChangedObservable: BABYLON.Observable<Style>;
  59909. /**
  59910. * Creates a new style object
  59911. * @param host defines the AdvancedDynamicTexture which hosts this style
  59912. */
  59913. constructor(host: AdvancedDynamicTexture);
  59914. /**
  59915. * Gets or sets the font size
  59916. */
  59917. fontSize: string | number;
  59918. /**
  59919. * Gets or sets the font family
  59920. */
  59921. fontFamily: string;
  59922. /**
  59923. * Gets or sets the font style
  59924. */
  59925. fontStyle: string;
  59926. /** Gets or sets font weight */
  59927. fontWeight: string;
  59928. /** Dispose all associated resources */
  59929. dispose(): void;
  59930. }
  59931. }
  59932. declare module BABYLON.GUI {
  59933. /**
  59934. * Class used to transport BABYLON.Vector2 information for pointer events
  59935. */
  59936. export class Vector2WithInfo extends BABYLON.Vector2 {
  59937. /** defines the current mouse button index */
  59938. buttonIndex: number;
  59939. /**
  59940. * Creates a new Vector2WithInfo
  59941. * @param source defines the vector2 data to transport
  59942. * @param buttonIndex defines the current mouse button index
  59943. */
  59944. constructor(source: BABYLON.Vector2,
  59945. /** defines the current mouse button index */
  59946. buttonIndex?: number);
  59947. }
  59948. /** Class used to provide 2D matrix features */
  59949. export class Matrix2D {
  59950. /** Gets the internal array of 6 floats used to store matrix data */
  59951. m: Float32Array;
  59952. /**
  59953. * Creates a new matrix
  59954. * @param m00 defines value for (0, 0)
  59955. * @param m01 defines value for (0, 1)
  59956. * @param m10 defines value for (1, 0)
  59957. * @param m11 defines value for (1, 1)
  59958. * @param m20 defines value for (2, 0)
  59959. * @param m21 defines value for (2, 1)
  59960. */
  59961. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59962. /**
  59963. * Fills the matrix from direct values
  59964. * @param m00 defines value for (0, 0)
  59965. * @param m01 defines value for (0, 1)
  59966. * @param m10 defines value for (1, 0)
  59967. * @param m11 defines value for (1, 1)
  59968. * @param m20 defines value for (2, 0)
  59969. * @param m21 defines value for (2, 1)
  59970. * @returns the current modified matrix
  59971. */
  59972. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59973. /**
  59974. * Gets matrix determinant
  59975. * @returns the determinant
  59976. */
  59977. determinant(): number;
  59978. /**
  59979. * Inverses the matrix and stores it in a target matrix
  59980. * @param result defines the target matrix
  59981. * @returns the current matrix
  59982. */
  59983. invertToRef(result: Matrix2D): Matrix2D;
  59984. /**
  59985. * Multiplies the current matrix with another one
  59986. * @param other defines the second operand
  59987. * @param result defines the target matrix
  59988. * @returns the current matrix
  59989. */
  59990. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59991. /**
  59992. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59993. * @param x defines the x coordinate to transform
  59994. * @param y defines the x coordinate to transform
  59995. * @param result defines the target vector2
  59996. * @returns the current matrix
  59997. */
  59998. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59999. /**
  60000. * Creates an identity matrix
  60001. * @returns a new matrix
  60002. */
  60003. static Identity(): Matrix2D;
  60004. /**
  60005. * Creates a translation matrix and stores it in a target matrix
  60006. * @param x defines the x coordinate of the translation
  60007. * @param y defines the y coordinate of the translation
  60008. * @param result defines the target matrix
  60009. */
  60010. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60011. /**
  60012. * Creates a scaling matrix and stores it in a target matrix
  60013. * @param x defines the x coordinate of the scaling
  60014. * @param y defines the y coordinate of the scaling
  60015. * @param result defines the target matrix
  60016. */
  60017. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60018. /**
  60019. * Creates a rotation matrix and stores it in a target matrix
  60020. * @param angle defines the rotation angle
  60021. * @param result defines the target matrix
  60022. */
  60023. static RotationToRef(angle: number, result: Matrix2D): void;
  60024. private static _TempPreTranslationMatrix;
  60025. private static _TempPostTranslationMatrix;
  60026. private static _TempRotationMatrix;
  60027. private static _TempScalingMatrix;
  60028. private static _TempCompose0;
  60029. private static _TempCompose1;
  60030. private static _TempCompose2;
  60031. /**
  60032. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60033. * @param tx defines the x coordinate of the translation
  60034. * @param ty defines the y coordinate of the translation
  60035. * @param angle defines the rotation angle
  60036. * @param scaleX defines the x coordinate of the scaling
  60037. * @param scaleY defines the y coordinate of the scaling
  60038. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60039. * @param result defines the target matrix
  60040. */
  60041. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60042. }
  60043. }
  60044. declare module BABYLON.GUI {
  60045. /**
  60046. * Class used to store 2D control sizes
  60047. */
  60048. export class Measure {
  60049. /** defines left coordinate */
  60050. left: number;
  60051. /** defines top coordinate */
  60052. top: number;
  60053. /** defines width dimension */
  60054. width: number;
  60055. /** defines height dimension */
  60056. height: number;
  60057. /**
  60058. * Creates a new measure
  60059. * @param left defines left coordinate
  60060. * @param top defines top coordinate
  60061. * @param width defines width dimension
  60062. * @param height defines height dimension
  60063. */
  60064. constructor(
  60065. /** defines left coordinate */
  60066. left: number,
  60067. /** defines top coordinate */
  60068. top: number,
  60069. /** defines width dimension */
  60070. width: number,
  60071. /** defines height dimension */
  60072. height: number);
  60073. /**
  60074. * Copy from another measure
  60075. * @param other defines the other measure to copy from
  60076. */
  60077. copyFrom(other: Measure): void;
  60078. /**
  60079. * Copy from a group of 4 floats
  60080. * @param left defines left coordinate
  60081. * @param top defines top coordinate
  60082. * @param width defines width dimension
  60083. * @param height defines height dimension
  60084. */
  60085. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60086. /**
  60087. * Computes the axis aligned bounding box measure for two given measures
  60088. * @param a Input measure
  60089. * @param b Input measure
  60090. * @param result the resulting bounding measure
  60091. */
  60092. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60093. /**
  60094. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60095. * @param transform the matrix to transform the measure before computing the AABB
  60096. * @param result the resulting AABB
  60097. */
  60098. transformToRef(transform: Matrix2D, result: Measure): void;
  60099. /**
  60100. * Check equality between this measure and another one
  60101. * @param other defines the other measures
  60102. * @returns true if both measures are equals
  60103. */
  60104. isEqualsTo(other: Measure): boolean;
  60105. /**
  60106. * Creates an empty measure
  60107. * @returns a new measure
  60108. */
  60109. static Empty(): Measure;
  60110. }
  60111. }
  60112. declare module BABYLON.GUI {
  60113. /**
  60114. * Interface used to define a control that can receive focus
  60115. */
  60116. export interface IFocusableControl {
  60117. /**
  60118. * Function called when the control receives the focus
  60119. */
  60120. onFocus(): void;
  60121. /**
  60122. * Function called when the control loses the focus
  60123. */
  60124. onBlur(): void;
  60125. /**
  60126. * Function called to let the control handle keyboard events
  60127. * @param evt defines the current keyboard event
  60128. */
  60129. processKeyboard(evt: KeyboardEvent): void;
  60130. /**
  60131. * Function called to get the list of controls that should not steal the focus from this control
  60132. * @returns an array of controls
  60133. */
  60134. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60135. }
  60136. /**
  60137. * Class used to create texture to support 2D GUI elements
  60138. * @see http://doc.babylonjs.com/how_to/gui
  60139. */
  60140. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60141. private _isDirty;
  60142. private _renderObserver;
  60143. private _resizeObserver;
  60144. private _preKeyboardObserver;
  60145. private _pointerMoveObserver;
  60146. private _pointerObserver;
  60147. private _canvasPointerOutObserver;
  60148. private _background;
  60149. /** @hidden */
  60150. _rootContainer: Container;
  60151. /** @hidden */
  60152. _lastPickedControl: Control;
  60153. /** @hidden */
  60154. _lastControlOver: {
  60155. [pointerId: number]: Control;
  60156. };
  60157. /** @hidden */
  60158. _lastControlDown: {
  60159. [pointerId: number]: Control;
  60160. };
  60161. /** @hidden */
  60162. _capturingControl: {
  60163. [pointerId: number]: Control;
  60164. };
  60165. /** @hidden */
  60166. _shouldBlockPointer: boolean;
  60167. /** @hidden */
  60168. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60169. /** @hidden */
  60170. _linkedControls: Control[];
  60171. private _isFullscreen;
  60172. private _fullscreenViewport;
  60173. private _idealWidth;
  60174. private _idealHeight;
  60175. private _useSmallestIdeal;
  60176. private _renderAtIdealSize;
  60177. private _focusedControl;
  60178. private _blockNextFocusCheck;
  60179. private _renderScale;
  60180. private _rootCanvas;
  60181. private _cursorChanged;
  60182. /**
  60183. * Define type to string to ensure compatibility across browsers
  60184. * Safari doesn't support DataTransfer constructor
  60185. */
  60186. private _clipboardData;
  60187. /**
  60188. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60189. */
  60190. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60191. /**
  60192. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60193. */
  60194. onControlPickedObservable: BABYLON.Observable<Control>;
  60195. /**
  60196. * BABYLON.Observable event triggered before layout is evaluated
  60197. */
  60198. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60199. /**
  60200. * BABYLON.Observable event triggered after the layout was evaluated
  60201. */
  60202. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60203. /**
  60204. * BABYLON.Observable event triggered before the texture is rendered
  60205. */
  60206. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60207. /**
  60208. * BABYLON.Observable event triggered after the texture was rendered
  60209. */
  60210. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60211. /**
  60212. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60213. */
  60214. premulAlpha: boolean;
  60215. /**
  60216. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60217. * Useful when you want more antialiasing
  60218. */
  60219. renderScale: number;
  60220. /** Gets or sets the background color */
  60221. background: string;
  60222. /**
  60223. * Gets or sets the ideal width used to design controls.
  60224. * The GUI will then rescale everything accordingly
  60225. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60226. */
  60227. idealWidth: number;
  60228. /**
  60229. * Gets or sets the ideal height used to design controls.
  60230. * The GUI will then rescale everything accordingly
  60231. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60232. */
  60233. idealHeight: number;
  60234. /**
  60235. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60236. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60237. */
  60238. useSmallestIdeal: boolean;
  60239. /**
  60240. * Gets or sets a boolean indicating if adaptive scaling must be used
  60241. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60242. */
  60243. renderAtIdealSize: boolean;
  60244. /**
  60245. * Gets the underlying layer used to render the texture when in fullscreen mode
  60246. */
  60247. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60248. /**
  60249. * Gets the root container control
  60250. */
  60251. readonly rootContainer: Container;
  60252. /**
  60253. * Returns an array containing the root container.
  60254. * This is mostly used to let the Inspector introspects the ADT
  60255. * @returns an array containing the rootContainer
  60256. */
  60257. getChildren(): Array<Container>;
  60258. /**
  60259. * Will return all controls that are inside this texture
  60260. * @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
  60261. * @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
  60262. * @return all child controls
  60263. */
  60264. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60265. /**
  60266. * Gets or sets the current focused control
  60267. */
  60268. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60269. /**
  60270. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60271. */
  60272. isForeground: boolean;
  60273. /**
  60274. * Gets or set information about clipboardData
  60275. */
  60276. clipboardData: string;
  60277. /**
  60278. * Creates a new AdvancedDynamicTexture
  60279. * @param name defines the name of the texture
  60280. * @param width defines the width of the texture
  60281. * @param height defines the height of the texture
  60282. * @param scene defines the hosting scene
  60283. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60284. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60285. */
  60286. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60287. /**
  60288. * Get the current class name of the texture useful for serialization or dynamic coding.
  60289. * @returns "AdvancedDynamicTexture"
  60290. */
  60291. getClassName(): string;
  60292. /**
  60293. * Function used to execute a function on all controls
  60294. * @param func defines the function to execute
  60295. * @param container defines the container where controls belong. If null the root container will be used
  60296. */
  60297. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60298. private _useInvalidateRectOptimization;
  60299. /**
  60300. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60301. */
  60302. useInvalidateRectOptimization: boolean;
  60303. private _invalidatedRectangle;
  60304. /**
  60305. * Invalidates a rectangle area on the gui texture
  60306. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60307. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60308. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60309. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60310. */
  60311. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60312. /**
  60313. * Marks the texture as dirty forcing a complete update
  60314. */
  60315. markAsDirty(): void;
  60316. /**
  60317. * Helper function used to create a new style
  60318. * @returns a new style
  60319. * @see http://doc.babylonjs.com/how_to/gui#styles
  60320. */
  60321. createStyle(): Style;
  60322. /**
  60323. * Adds a new control to the root container
  60324. * @param control defines the control to add
  60325. * @returns the current texture
  60326. */
  60327. addControl(control: Control): AdvancedDynamicTexture;
  60328. /**
  60329. * Removes a control from the root container
  60330. * @param control defines the control to remove
  60331. * @returns the current texture
  60332. */
  60333. removeControl(control: Control): AdvancedDynamicTexture;
  60334. /**
  60335. * Release all resources
  60336. */
  60337. dispose(): void;
  60338. private _onResize;
  60339. /** @hidden */
  60340. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60341. /**
  60342. * Get screen coordinates for a vector3
  60343. * @param position defines the position to project
  60344. * @param worldMatrix defines the world matrix to use
  60345. * @returns the projected position
  60346. */
  60347. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60348. private _checkUpdate;
  60349. private _clearMeasure;
  60350. private _render;
  60351. /** @hidden */
  60352. _changeCursor(cursor: string): void;
  60353. /** @hidden */
  60354. _registerLastControlDown(control: Control, pointerId: number): void;
  60355. private _doPicking;
  60356. /** @hidden */
  60357. _cleanControlAfterRemovalFromList(list: {
  60358. [pointerId: number]: Control;
  60359. }, control: Control): void;
  60360. /** @hidden */
  60361. _cleanControlAfterRemoval(control: Control): void;
  60362. /** Attach to all scene events required to support pointer events */
  60363. attach(): void;
  60364. /** @hidden */
  60365. private onClipboardCopy;
  60366. /** @hidden */
  60367. private onClipboardCut;
  60368. /** @hidden */
  60369. private onClipboardPaste;
  60370. /**
  60371. * Register the clipboard Events onto the canvas
  60372. */
  60373. registerClipboardEvents(): void;
  60374. /**
  60375. * Unregister the clipboard Events from the canvas
  60376. */
  60377. unRegisterClipboardEvents(): void;
  60378. /**
  60379. * Connect the texture to a hosting mesh to enable interactions
  60380. * @param mesh defines the mesh to attach to
  60381. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60382. */
  60383. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60384. /**
  60385. * Move the focus to a specific control
  60386. * @param control defines the control which will receive the focus
  60387. */
  60388. moveFocusToControl(control: IFocusableControl): void;
  60389. private _manageFocus;
  60390. private _attachToOnPointerOut;
  60391. /**
  60392. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60393. * @param mesh defines the mesh which will receive the texture
  60394. * @param width defines the texture width (1024 by default)
  60395. * @param height defines the texture height (1024 by default)
  60396. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60397. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60398. * @returns a new AdvancedDynamicTexture
  60399. */
  60400. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60401. /**
  60402. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60403. * In this mode the texture will rely on a layer for its rendering.
  60404. * This allows it to be treated like any other layer.
  60405. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60406. * LayerMask is set through advancedTexture.layer.layerMask
  60407. * @param name defines name for the texture
  60408. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60409. * @param scene defines the hsoting scene
  60410. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60411. * @returns a new AdvancedDynamicTexture
  60412. */
  60413. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60414. }
  60415. }
  60416. declare module BABYLON.GUI {
  60417. /**
  60418. * Root class used for all 2D controls
  60419. * @see http://doc.babylonjs.com/how_to/gui#controls
  60420. */
  60421. export class Control {
  60422. /** defines the name of the control */
  60423. name?: string | undefined;
  60424. /**
  60425. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60426. */
  60427. static AllowAlphaInheritance: boolean;
  60428. private _alpha;
  60429. private _alphaSet;
  60430. private _zIndex;
  60431. /** @hidden */
  60432. _host: AdvancedDynamicTexture;
  60433. /** Gets or sets the control parent */
  60434. parent: BABYLON.Nullable<Container>;
  60435. /** @hidden */
  60436. _currentMeasure: Measure;
  60437. private _fontFamily;
  60438. private _fontStyle;
  60439. private _fontWeight;
  60440. private _fontSize;
  60441. private _font;
  60442. /** @hidden */
  60443. _width: ValueAndUnit;
  60444. /** @hidden */
  60445. _height: ValueAndUnit;
  60446. /** @hidden */
  60447. protected _fontOffset: {
  60448. ascent: number;
  60449. height: number;
  60450. descent: number;
  60451. };
  60452. private _color;
  60453. private _style;
  60454. private _styleObserver;
  60455. /** @hidden */
  60456. protected _horizontalAlignment: number;
  60457. /** @hidden */
  60458. protected _verticalAlignment: number;
  60459. /** @hidden */
  60460. protected _isDirty: boolean;
  60461. /** @hidden */
  60462. protected _wasDirty: boolean;
  60463. /** @hidden */
  60464. _tempParentMeasure: Measure;
  60465. /** @hidden */
  60466. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60467. /** @hidden */
  60468. protected _cachedParentMeasure: Measure;
  60469. private _paddingLeft;
  60470. private _paddingRight;
  60471. private _paddingTop;
  60472. private _paddingBottom;
  60473. /** @hidden */
  60474. _left: ValueAndUnit;
  60475. /** @hidden */
  60476. _top: ValueAndUnit;
  60477. private _scaleX;
  60478. private _scaleY;
  60479. private _rotation;
  60480. private _transformCenterX;
  60481. private _transformCenterY;
  60482. /** @hidden */
  60483. _transformMatrix: Matrix2D;
  60484. /** @hidden */
  60485. protected _invertTransformMatrix: Matrix2D;
  60486. /** @hidden */
  60487. protected _transformedPosition: BABYLON.Vector2;
  60488. private _isMatrixDirty;
  60489. private _cachedOffsetX;
  60490. private _cachedOffsetY;
  60491. private _isVisible;
  60492. private _isHighlighted;
  60493. /** @hidden */
  60494. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60495. private _fontSet;
  60496. private _dummyVector2;
  60497. private _downCount;
  60498. private _enterCount;
  60499. private _doNotRender;
  60500. private _downPointerIds;
  60501. protected _isEnabled: boolean;
  60502. protected _disabledColor: string;
  60503. /** @hidden */
  60504. protected _rebuildLayout: boolean;
  60505. /** @hidden */
  60506. _isClipped: boolean;
  60507. /** @hidden */
  60508. _tag: any;
  60509. /**
  60510. * 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
  60511. */
  60512. uniqueId: number;
  60513. /**
  60514. * Gets or sets an object used to store user defined information for the node
  60515. */
  60516. metadata: any;
  60517. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60518. isHitTestVisible: boolean;
  60519. /** Gets or sets a boolean indicating if the control can block pointer events */
  60520. isPointerBlocker: boolean;
  60521. /** Gets or sets a boolean indicating if the control can be focusable */
  60522. isFocusInvisible: boolean;
  60523. /**
  60524. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60525. * 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
  60526. */
  60527. clipChildren: boolean;
  60528. /**
  60529. * Gets or sets a boolean indicating that control content must be clipped
  60530. * 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
  60531. */
  60532. clipContent: boolean;
  60533. /**
  60534. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60535. */
  60536. useBitmapCache: boolean;
  60537. private _cacheData;
  60538. private _shadowOffsetX;
  60539. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60540. shadowOffsetX: number;
  60541. private _shadowOffsetY;
  60542. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60543. shadowOffsetY: number;
  60544. private _shadowBlur;
  60545. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60546. shadowBlur: number;
  60547. private _shadowColor;
  60548. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60549. shadowColor: string;
  60550. /** Gets or sets the cursor to use when the control is hovered */
  60551. hoverCursor: string;
  60552. /** @hidden */
  60553. protected _linkOffsetX: ValueAndUnit;
  60554. /** @hidden */
  60555. protected _linkOffsetY: ValueAndUnit;
  60556. /** Gets the control type name */
  60557. readonly typeName: string;
  60558. /**
  60559. * Get the current class name of the control.
  60560. * @returns current class name
  60561. */
  60562. getClassName(): string;
  60563. /**
  60564. * An event triggered when the pointer move over the control.
  60565. */
  60566. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60567. /**
  60568. * An event triggered when the pointer move out of the control.
  60569. */
  60570. onPointerOutObservable: BABYLON.Observable<Control>;
  60571. /**
  60572. * An event triggered when the pointer taps the control
  60573. */
  60574. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60575. /**
  60576. * An event triggered when pointer up
  60577. */
  60578. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60579. /**
  60580. * An event triggered when a control is clicked on
  60581. */
  60582. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60583. /**
  60584. * An event triggered when pointer enters the control
  60585. */
  60586. onPointerEnterObservable: BABYLON.Observable<Control>;
  60587. /**
  60588. * An event triggered when the control is marked as dirty
  60589. */
  60590. onDirtyObservable: BABYLON.Observable<Control>;
  60591. /**
  60592. * An event triggered before drawing the control
  60593. */
  60594. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60595. /**
  60596. * An event triggered after the control was drawn
  60597. */
  60598. onAfterDrawObservable: BABYLON.Observable<Control>;
  60599. /**
  60600. * Get the hosting AdvancedDynamicTexture
  60601. */
  60602. readonly host: AdvancedDynamicTexture;
  60603. /** Gets or set information about font offsets (used to render and align text) */
  60604. fontOffset: {
  60605. ascent: number;
  60606. height: number;
  60607. descent: number;
  60608. };
  60609. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60610. alpha: number;
  60611. /**
  60612. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60613. */
  60614. isHighlighted: boolean;
  60615. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60616. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60617. */
  60618. scaleX: number;
  60619. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60620. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60621. */
  60622. scaleY: number;
  60623. /** Gets or sets the rotation angle (0 by default)
  60624. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60625. */
  60626. rotation: number;
  60627. /** Gets or sets the transformation center on Y axis (0 by default)
  60628. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60629. */
  60630. transformCenterY: number;
  60631. /** Gets or sets the transformation center on X axis (0 by default)
  60632. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60633. */
  60634. transformCenterX: number;
  60635. /**
  60636. * Gets or sets the horizontal alignment
  60637. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60638. */
  60639. horizontalAlignment: number;
  60640. /**
  60641. * Gets or sets the vertical alignment
  60642. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60643. */
  60644. verticalAlignment: number;
  60645. /**
  60646. * Gets or sets control width
  60647. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60648. */
  60649. width: string | number;
  60650. /**
  60651. * Gets or sets the control width in pixel
  60652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60653. */
  60654. widthInPixels: number;
  60655. /**
  60656. * Gets or sets control height
  60657. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60658. */
  60659. height: string | number;
  60660. /**
  60661. * Gets or sets control height in pixel
  60662. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60663. */
  60664. heightInPixels: number;
  60665. /** Gets or set font family */
  60666. fontFamily: string;
  60667. /** Gets or sets font style */
  60668. fontStyle: string;
  60669. /** Gets or sets font weight */
  60670. fontWeight: string;
  60671. /**
  60672. * Gets or sets style
  60673. * @see http://doc.babylonjs.com/how_to/gui#styles
  60674. */
  60675. style: BABYLON.Nullable<Style>;
  60676. /** @hidden */
  60677. readonly _isFontSizeInPercentage: boolean;
  60678. /** Gets or sets font size in pixels */
  60679. fontSizeInPixels: number;
  60680. /** Gets or sets font size */
  60681. fontSize: string | number;
  60682. /** Gets or sets foreground color */
  60683. color: string;
  60684. /** Gets or sets z index which is used to reorder controls on the z axis */
  60685. zIndex: number;
  60686. /** Gets or sets a boolean indicating if the control can be rendered */
  60687. notRenderable: boolean;
  60688. /** Gets or sets a boolean indicating if the control is visible */
  60689. isVisible: boolean;
  60690. /** Gets a boolean indicating that the control needs to update its rendering */
  60691. readonly isDirty: boolean;
  60692. /**
  60693. * Gets the current linked mesh (or null if none)
  60694. */
  60695. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60696. /**
  60697. * Gets or sets a value indicating the padding to use on the left of the control
  60698. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60699. */
  60700. paddingLeft: string | number;
  60701. /**
  60702. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60704. */
  60705. paddingLeftInPixels: number;
  60706. /**
  60707. * Gets or sets a value indicating the padding to use on the right of the control
  60708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60709. */
  60710. paddingRight: string | number;
  60711. /**
  60712. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60714. */
  60715. paddingRightInPixels: number;
  60716. /**
  60717. * Gets or sets a value indicating the padding to use on the top of the control
  60718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60719. */
  60720. paddingTop: string | number;
  60721. /**
  60722. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60724. */
  60725. paddingTopInPixels: number;
  60726. /**
  60727. * Gets or sets a value indicating the padding to use on the bottom of the control
  60728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60729. */
  60730. paddingBottom: string | number;
  60731. /**
  60732. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60734. */
  60735. paddingBottomInPixels: number;
  60736. /**
  60737. * Gets or sets a value indicating the left coordinate of the control
  60738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60739. */
  60740. left: string | number;
  60741. /**
  60742. * Gets or sets a value indicating the left coordinate in pixels of the control
  60743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60744. */
  60745. leftInPixels: number;
  60746. /**
  60747. * Gets or sets a value indicating the top coordinate of the control
  60748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60749. */
  60750. top: string | number;
  60751. /**
  60752. * Gets or sets a value indicating the top coordinate in pixels of the control
  60753. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60754. */
  60755. topInPixels: number;
  60756. /**
  60757. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60758. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60759. */
  60760. linkOffsetX: string | number;
  60761. /**
  60762. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60763. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60764. */
  60765. linkOffsetXInPixels: number;
  60766. /**
  60767. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60768. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60769. */
  60770. linkOffsetY: string | number;
  60771. /**
  60772. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60773. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60774. */
  60775. linkOffsetYInPixels: number;
  60776. /** Gets the center coordinate on X axis */
  60777. readonly centerX: number;
  60778. /** Gets the center coordinate on Y axis */
  60779. readonly centerY: number;
  60780. /** Gets or sets if control is Enabled*/
  60781. isEnabled: boolean;
  60782. /** Gets or sets background color of control if it's disabled*/
  60783. disabledColor: string;
  60784. /**
  60785. * Creates a new control
  60786. * @param name defines the name of the control
  60787. */
  60788. constructor(
  60789. /** defines the name of the control */
  60790. name?: string | undefined);
  60791. /** @hidden */
  60792. protected _getTypeName(): string;
  60793. /**
  60794. * Gets the first ascendant in the hierarchy of the given type
  60795. * @param className defines the required type
  60796. * @returns the ascendant or null if not found
  60797. */
  60798. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60799. /** @hidden */
  60800. _resetFontCache(): void;
  60801. /**
  60802. * Determines if a container is an ascendant of the current control
  60803. * @param container defines the container to look for
  60804. * @returns true if the container is one of the ascendant of the control
  60805. */
  60806. isAscendant(container: Control): boolean;
  60807. /**
  60808. * Gets coordinates in local control space
  60809. * @param globalCoordinates defines the coordinates to transform
  60810. * @returns the new coordinates in local space
  60811. */
  60812. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60813. /**
  60814. * Gets coordinates in local control space
  60815. * @param globalCoordinates defines the coordinates to transform
  60816. * @param result defines the target vector2 where to store the result
  60817. * @returns the current control
  60818. */
  60819. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60820. /**
  60821. * Gets coordinates in parent local control space
  60822. * @param globalCoordinates defines the coordinates to transform
  60823. * @returns the new coordinates in parent local space
  60824. */
  60825. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60826. /**
  60827. * Move the current control to a vector3 position projected onto the screen.
  60828. * @param position defines the target position
  60829. * @param scene defines the hosting scene
  60830. */
  60831. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60832. /** @hidden */
  60833. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60834. /**
  60835. * Will return all controls that have this control as ascendant
  60836. * @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
  60837. * @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
  60838. * @return all child controls
  60839. */
  60840. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60841. /**
  60842. * Link current control with a target mesh
  60843. * @param mesh defines the mesh to link with
  60844. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60845. */
  60846. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60847. /** @hidden */
  60848. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60849. /** @hidden */
  60850. _offsetLeft(offset: number): void;
  60851. /** @hidden */
  60852. _offsetTop(offset: number): void;
  60853. /** @hidden */
  60854. _markMatrixAsDirty(): void;
  60855. /** @hidden */
  60856. _flagDescendantsAsMatrixDirty(): void;
  60857. /** @hidden */
  60858. _intersectsRect(rect: Measure): boolean;
  60859. /** @hidden */
  60860. protected invalidateRect(): void;
  60861. /** @hidden */
  60862. _markAsDirty(force?: boolean): void;
  60863. /** @hidden */
  60864. _markAllAsDirty(): void;
  60865. /** @hidden */
  60866. _link(host: AdvancedDynamicTexture): void;
  60867. /** @hidden */
  60868. protected _transform(context?: CanvasRenderingContext2D): void;
  60869. /** @hidden */
  60870. _renderHighlight(context: CanvasRenderingContext2D): void;
  60871. /** @hidden */
  60872. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60873. /** @hidden */
  60874. protected _applyStates(context: CanvasRenderingContext2D): void;
  60875. /** @hidden */
  60876. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60877. /** @hidden */
  60878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60879. protected _evaluateClippingState(parentMeasure: Measure): void;
  60880. /** @hidden */
  60881. _measure(): void;
  60882. /** @hidden */
  60883. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60884. /** @hidden */
  60885. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60886. /** @hidden */
  60887. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60888. /** @hidden */
  60889. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60890. private static _ClipMeasure;
  60891. private _tmpMeasureA;
  60892. private _clip;
  60893. /** @hidden */
  60894. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60895. /** @hidden */
  60896. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60897. /**
  60898. * Tests if a given coordinates belong to the current control
  60899. * @param x defines x coordinate to test
  60900. * @param y defines y coordinate to test
  60901. * @returns true if the coordinates are inside the control
  60902. */
  60903. contains(x: number, y: number): boolean;
  60904. /** @hidden */
  60905. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60906. /** @hidden */
  60907. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60908. /** @hidden */
  60909. _onPointerEnter(target: Control): boolean;
  60910. /** @hidden */
  60911. _onPointerOut(target: Control, force?: boolean): void;
  60912. /** @hidden */
  60913. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60914. /** @hidden */
  60915. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60916. /** @hidden */
  60917. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60918. /** @hidden */
  60919. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60920. private _prepareFont;
  60921. /** Releases associated resources */
  60922. dispose(): void;
  60923. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60924. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60925. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60926. private static _VERTICAL_ALIGNMENT_TOP;
  60927. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60928. private static _VERTICAL_ALIGNMENT_CENTER;
  60929. /** HORIZONTAL_ALIGNMENT_LEFT */
  60930. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60931. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60932. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60933. /** HORIZONTAL_ALIGNMENT_CENTER */
  60934. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60935. /** VERTICAL_ALIGNMENT_TOP */
  60936. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60937. /** VERTICAL_ALIGNMENT_BOTTOM */
  60938. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60939. /** VERTICAL_ALIGNMENT_CENTER */
  60940. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60941. private static _FontHeightSizes;
  60942. /** @hidden */
  60943. static _GetFontOffset(font: string): {
  60944. ascent: number;
  60945. height: number;
  60946. descent: number;
  60947. };
  60948. /**
  60949. * Creates a stack panel that can be used to render headers
  60950. * @param control defines the control to associate with the header
  60951. * @param text defines the text of the header
  60952. * @param size defines the size of the header
  60953. * @param options defines options used to configure the header
  60954. * @returns a new StackPanel
  60955. * @ignore
  60956. * @hidden
  60957. */
  60958. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60959. isHorizontal: boolean;
  60960. controlFirst: boolean;
  60961. }) => any;
  60962. /** @hidden */
  60963. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60964. }
  60965. }
  60966. declare module BABYLON.GUI {
  60967. /**
  60968. * Root class for 2D containers
  60969. * @see http://doc.babylonjs.com/how_to/gui#containers
  60970. */
  60971. export class Container extends Control {
  60972. name?: string | undefined;
  60973. /** @hidden */
  60974. protected _children: Control[];
  60975. /** @hidden */
  60976. protected _measureForChildren: Measure;
  60977. /** @hidden */
  60978. protected _background: string;
  60979. /** @hidden */
  60980. protected _adaptWidthToChildren: boolean;
  60981. /** @hidden */
  60982. protected _adaptHeightToChildren: boolean;
  60983. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60984. adaptHeightToChildren: boolean;
  60985. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60986. adaptWidthToChildren: boolean;
  60987. /** Gets or sets background color */
  60988. background: string;
  60989. /** Gets the list of children */
  60990. readonly children: Control[];
  60991. /**
  60992. * Creates a new Container
  60993. * @param name defines the name of the container
  60994. */
  60995. constructor(name?: string | undefined);
  60996. protected _getTypeName(): string;
  60997. _flagDescendantsAsMatrixDirty(): void;
  60998. /**
  60999. * Gets a child using its name
  61000. * @param name defines the child name to look for
  61001. * @returns the child control if found
  61002. */
  61003. getChildByName(name: string): BABYLON.Nullable<Control>;
  61004. /**
  61005. * Gets a child using its type and its name
  61006. * @param name defines the child name to look for
  61007. * @param type defines the child type to look for
  61008. * @returns the child control if found
  61009. */
  61010. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61011. /**
  61012. * Search for a specific control in children
  61013. * @param control defines the control to look for
  61014. * @returns true if the control is in child list
  61015. */
  61016. containsControl(control: Control): boolean;
  61017. /**
  61018. * Adds a new control to the current container
  61019. * @param control defines the control to add
  61020. * @returns the current container
  61021. */
  61022. addControl(control: BABYLON.Nullable<Control>): Container;
  61023. /**
  61024. * Removes all controls from the current container
  61025. * @returns the current container
  61026. */
  61027. clearControls(): Container;
  61028. /**
  61029. * Removes a control from the current container
  61030. * @param control defines the control to remove
  61031. * @returns the current container
  61032. */
  61033. removeControl(control: Control): Container;
  61034. /** @hidden */
  61035. _reOrderControl(control: Control): void;
  61036. /** @hidden */
  61037. _offsetLeft(offset: number): void;
  61038. /** @hidden */
  61039. _offsetTop(offset: number): void;
  61040. /** @hidden */
  61041. _markAllAsDirty(): void;
  61042. /** @hidden */
  61043. protected _localDraw(context: CanvasRenderingContext2D): void;
  61044. /** @hidden */
  61045. _link(host: AdvancedDynamicTexture): void;
  61046. /** @hidden */
  61047. protected _beforeLayout(): void;
  61048. /** @hidden */
  61049. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61050. /** @hidden */
  61051. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61052. protected _postMeasure(): void;
  61053. /** @hidden */
  61054. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61055. /** @hidden */
  61056. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61057. /** @hidden */
  61058. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61059. /** @hidden */
  61060. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61061. /** Releases associated resources */
  61062. dispose(): void;
  61063. }
  61064. }
  61065. declare module BABYLON.GUI {
  61066. /** Class used to create rectangle container */
  61067. export class Rectangle extends Container {
  61068. name?: string | undefined;
  61069. private _thickness;
  61070. private _cornerRadius;
  61071. /** Gets or sets border thickness */
  61072. thickness: number;
  61073. /** Gets or sets the corner radius angle */
  61074. cornerRadius: number;
  61075. /**
  61076. * Creates a new Rectangle
  61077. * @param name defines the control name
  61078. */
  61079. constructor(name?: string | undefined);
  61080. protected _getTypeName(): string;
  61081. protected _localDraw(context: CanvasRenderingContext2D): void;
  61082. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61083. private _drawRoundedRect;
  61084. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61085. }
  61086. }
  61087. declare module BABYLON.GUI {
  61088. /**
  61089. * Enum that determines the text-wrapping mode to use.
  61090. */
  61091. export enum TextWrapping {
  61092. /**
  61093. * Clip the text when it's larger than Control.width; this is the default mode.
  61094. */
  61095. Clip = 0,
  61096. /**
  61097. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61098. */
  61099. WordWrap = 1,
  61100. /**
  61101. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61102. */
  61103. Ellipsis = 2
  61104. }
  61105. /**
  61106. * Class used to create text block control
  61107. */
  61108. export class TextBlock extends Control {
  61109. /**
  61110. * Defines the name of the control
  61111. */
  61112. name?: string | undefined;
  61113. private _text;
  61114. private _textWrapping;
  61115. private _textHorizontalAlignment;
  61116. private _textVerticalAlignment;
  61117. private _lines;
  61118. private _resizeToFit;
  61119. private _lineSpacing;
  61120. private _outlineWidth;
  61121. private _outlineColor;
  61122. /**
  61123. * An event triggered after the text is changed
  61124. */
  61125. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61126. /**
  61127. * An event triggered after the text was broken up into lines
  61128. */
  61129. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61130. /**
  61131. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61132. */
  61133. readonly lines: any[];
  61134. /**
  61135. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61136. */
  61137. /**
  61138. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61139. */
  61140. resizeToFit: boolean;
  61141. /**
  61142. * Gets or sets a boolean indicating if text must be wrapped
  61143. */
  61144. /**
  61145. * Gets or sets a boolean indicating if text must be wrapped
  61146. */
  61147. textWrapping: TextWrapping | boolean;
  61148. /**
  61149. * Gets or sets text to display
  61150. */
  61151. /**
  61152. * Gets or sets text to display
  61153. */
  61154. text: string;
  61155. /**
  61156. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61157. */
  61158. /**
  61159. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61160. */
  61161. textHorizontalAlignment: number;
  61162. /**
  61163. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61164. */
  61165. /**
  61166. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61167. */
  61168. textVerticalAlignment: number;
  61169. /**
  61170. * Gets or sets line spacing value
  61171. */
  61172. /**
  61173. * Gets or sets line spacing value
  61174. */
  61175. lineSpacing: string | number;
  61176. /**
  61177. * Gets or sets outlineWidth of the text to display
  61178. */
  61179. /**
  61180. * Gets or sets outlineWidth of the text to display
  61181. */
  61182. outlineWidth: number;
  61183. /**
  61184. * Gets or sets outlineColor of the text to display
  61185. */
  61186. /**
  61187. * Gets or sets outlineColor of the text to display
  61188. */
  61189. outlineColor: string;
  61190. /**
  61191. * Creates a new TextBlock object
  61192. * @param name defines the name of the control
  61193. * @param text defines the text to display (emptry string by default)
  61194. */
  61195. constructor(
  61196. /**
  61197. * Defines the name of the control
  61198. */
  61199. name?: string | undefined, text?: string);
  61200. protected _getTypeName(): string;
  61201. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61202. private _drawText;
  61203. /** @hidden */
  61204. _draw(context: CanvasRenderingContext2D): void;
  61205. protected _applyStates(context: CanvasRenderingContext2D): void;
  61206. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61207. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61208. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61209. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61210. protected _renderLines(context: CanvasRenderingContext2D): void;
  61211. /**
  61212. * Given a width constraint applied on the text block, find the expected height
  61213. * @returns expected height
  61214. */
  61215. computeExpectedHeight(): number;
  61216. dispose(): void;
  61217. }
  61218. }
  61219. declare module BABYLON.GUI {
  61220. /**
  61221. * Class used to create 2D images
  61222. */
  61223. export class Image extends Control {
  61224. name?: string | undefined;
  61225. private static _WorkingCanvas;
  61226. private _domImage;
  61227. private _imageWidth;
  61228. private _imageHeight;
  61229. private _loaded;
  61230. private _stretch;
  61231. private _source;
  61232. private _autoScale;
  61233. private _sourceLeft;
  61234. private _sourceTop;
  61235. private _sourceWidth;
  61236. private _sourceHeight;
  61237. private _cellWidth;
  61238. private _cellHeight;
  61239. private _cellId;
  61240. private _populateNinePatchSlicesFromImage;
  61241. private _sliceLeft;
  61242. private _sliceRight;
  61243. private _sliceTop;
  61244. private _sliceBottom;
  61245. private _detectPointerOnOpaqueOnly;
  61246. /**
  61247. * BABYLON.Observable notified when the content is loaded
  61248. */
  61249. onImageLoadedObservable: BABYLON.Observable<Image>;
  61250. /**
  61251. * Gets a boolean indicating that the content is loaded
  61252. */
  61253. readonly isLoaded: boolean;
  61254. /**
  61255. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61256. */
  61257. populateNinePatchSlicesFromImage: boolean;
  61258. /**
  61259. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61260. * Beware using this as this will comsume more memory as the image has to be stored twice
  61261. */
  61262. detectPointerOnOpaqueOnly: boolean;
  61263. /**
  61264. * Gets or sets the left value for slicing (9-patch)
  61265. */
  61266. sliceLeft: number;
  61267. /**
  61268. * Gets or sets the right value for slicing (9-patch)
  61269. */
  61270. sliceRight: number;
  61271. /**
  61272. * Gets or sets the top value for slicing (9-patch)
  61273. */
  61274. sliceTop: number;
  61275. /**
  61276. * Gets or sets the bottom value for slicing (9-patch)
  61277. */
  61278. sliceBottom: number;
  61279. /**
  61280. * Gets or sets the left coordinate in the source image
  61281. */
  61282. sourceLeft: number;
  61283. /**
  61284. * Gets or sets the top coordinate in the source image
  61285. */
  61286. sourceTop: number;
  61287. /**
  61288. * Gets or sets the width to capture in the source image
  61289. */
  61290. sourceWidth: number;
  61291. /**
  61292. * Gets or sets the height to capture in the source image
  61293. */
  61294. sourceHeight: number;
  61295. /**
  61296. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61297. * @see http://doc.babylonjs.com/how_to/gui#image
  61298. */
  61299. autoScale: boolean;
  61300. /** Gets or sets the streching mode used by the image */
  61301. stretch: number;
  61302. /**
  61303. * Gets or sets the internal DOM image used to render the control
  61304. */
  61305. domImage: HTMLImageElement;
  61306. private _onImageLoaded;
  61307. private _extractNinePatchSliceDataFromImage;
  61308. /**
  61309. * Gets or sets image source url
  61310. */
  61311. source: BABYLON.Nullable<string>;
  61312. /**
  61313. * Gets or sets the cell width to use when animation sheet is enabled
  61314. * @see http://doc.babylonjs.com/how_to/gui#image
  61315. */
  61316. cellWidth: number;
  61317. /**
  61318. * Gets or sets the cell height to use when animation sheet is enabled
  61319. * @see http://doc.babylonjs.com/how_to/gui#image
  61320. */
  61321. cellHeight: number;
  61322. /**
  61323. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61324. * @see http://doc.babylonjs.com/how_to/gui#image
  61325. */
  61326. cellId: number;
  61327. /**
  61328. * Creates a new Image
  61329. * @param name defines the control name
  61330. * @param url defines the image url
  61331. */
  61332. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61333. /**
  61334. * Tests if a given coordinates belong to the current control
  61335. * @param x defines x coordinate to test
  61336. * @param y defines y coordinate to test
  61337. * @returns true if the coordinates are inside the control
  61338. */
  61339. contains(x: number, y: number): boolean;
  61340. protected _getTypeName(): string;
  61341. /** Force the control to synchronize with its content */
  61342. synchronizeSizeWithContent(): void;
  61343. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61344. private _prepareWorkingCanvasForOpaqueDetection;
  61345. private _drawImage;
  61346. _draw(context: CanvasRenderingContext2D): void;
  61347. private _renderCornerPatch;
  61348. private _renderNinePatch;
  61349. dispose(): void;
  61350. /** STRETCH_NONE */
  61351. static readonly STRETCH_NONE: number;
  61352. /** STRETCH_FILL */
  61353. static readonly STRETCH_FILL: number;
  61354. /** STRETCH_UNIFORM */
  61355. static readonly STRETCH_UNIFORM: number;
  61356. /** STRETCH_EXTEND */
  61357. static readonly STRETCH_EXTEND: number;
  61358. /** NINE_PATCH */
  61359. static readonly STRETCH_NINE_PATCH: number;
  61360. }
  61361. }
  61362. declare module BABYLON.GUI {
  61363. /**
  61364. * Class used to create 2D buttons
  61365. */
  61366. export class Button extends Rectangle {
  61367. name?: string | undefined;
  61368. /**
  61369. * Function called to generate a pointer enter animation
  61370. */
  61371. pointerEnterAnimation: () => void;
  61372. /**
  61373. * Function called to generate a pointer out animation
  61374. */
  61375. pointerOutAnimation: () => void;
  61376. /**
  61377. * Function called to generate a pointer down animation
  61378. */
  61379. pointerDownAnimation: () => void;
  61380. /**
  61381. * Function called to generate a pointer up animation
  61382. */
  61383. pointerUpAnimation: () => void;
  61384. private _image;
  61385. /**
  61386. * Returns the image part of the button (if any)
  61387. */
  61388. readonly image: BABYLON.Nullable<Image>;
  61389. private _textBlock;
  61390. /**
  61391. * Returns the image part of the button (if any)
  61392. */
  61393. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61394. /**
  61395. * Creates a new Button
  61396. * @param name defines the name of the button
  61397. */
  61398. constructor(name?: string | undefined);
  61399. protected _getTypeName(): string;
  61400. /** @hidden */
  61401. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61402. /** @hidden */
  61403. _onPointerEnter(target: Control): boolean;
  61404. /** @hidden */
  61405. _onPointerOut(target: Control, force?: boolean): void;
  61406. /** @hidden */
  61407. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61408. /** @hidden */
  61409. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61410. /**
  61411. * Creates a new button made with an image and a text
  61412. * @param name defines the name of the button
  61413. * @param text defines the text of the button
  61414. * @param imageUrl defines the url of the image
  61415. * @returns a new Button
  61416. */
  61417. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61418. /**
  61419. * Creates a new button made with an image
  61420. * @param name defines the name of the button
  61421. * @param imageUrl defines the url of the image
  61422. * @returns a new Button
  61423. */
  61424. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61425. /**
  61426. * Creates a new button made with a text
  61427. * @param name defines the name of the button
  61428. * @param text defines the text of the button
  61429. * @returns a new Button
  61430. */
  61431. static CreateSimpleButton(name: string, text: string): Button;
  61432. /**
  61433. * Creates a new button made with an image and a centered text
  61434. * @param name defines the name of the button
  61435. * @param text defines the text of the button
  61436. * @param imageUrl defines the url of the image
  61437. * @returns a new Button
  61438. */
  61439. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61440. }
  61441. }
  61442. declare module BABYLON.GUI {
  61443. /**
  61444. * Class used to create a 2D stack panel container
  61445. */
  61446. export class StackPanel extends Container {
  61447. name?: string | undefined;
  61448. private _isVertical;
  61449. private _manualWidth;
  61450. private _manualHeight;
  61451. private _doNotTrackManualChanges;
  61452. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61453. isVertical: boolean;
  61454. /**
  61455. * Gets or sets panel width.
  61456. * This value should not be set when in horizontal mode as it will be computed automatically
  61457. */
  61458. width: string | number;
  61459. /**
  61460. * Gets or sets panel height.
  61461. * This value should not be set when in vertical mode as it will be computed automatically
  61462. */
  61463. height: string | number;
  61464. /**
  61465. * Creates a new StackPanel
  61466. * @param name defines control name
  61467. */
  61468. constructor(name?: string | undefined);
  61469. protected _getTypeName(): string;
  61470. /** @hidden */
  61471. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61472. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61473. protected _postMeasure(): void;
  61474. }
  61475. }
  61476. declare module BABYLON.GUI {
  61477. /**
  61478. * Class used to represent a 2D checkbox
  61479. */
  61480. export class Checkbox extends Control {
  61481. name?: string | undefined;
  61482. private _isChecked;
  61483. private _background;
  61484. private _checkSizeRatio;
  61485. private _thickness;
  61486. /** Gets or sets border thickness */
  61487. thickness: number;
  61488. /**
  61489. * BABYLON.Observable raised when isChecked property changes
  61490. */
  61491. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61492. /** Gets or sets a value indicating the ratio between overall size and check size */
  61493. checkSizeRatio: number;
  61494. /** Gets or sets background color */
  61495. background: string;
  61496. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61497. isChecked: boolean;
  61498. /**
  61499. * Creates a new CheckBox
  61500. * @param name defines the control name
  61501. */
  61502. constructor(name?: string | undefined);
  61503. protected _getTypeName(): string;
  61504. /** @hidden */
  61505. _draw(context: CanvasRenderingContext2D): void;
  61506. /** @hidden */
  61507. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61508. /**
  61509. * Utility function to easily create a checkbox with a header
  61510. * @param title defines the label to use for the header
  61511. * @param onValueChanged defines the callback to call when value changes
  61512. * @returns a StackPanel containing the checkbox and a textBlock
  61513. */
  61514. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61515. }
  61516. }
  61517. declare module BABYLON.GUI {
  61518. /**
  61519. * Class used to store key control properties
  61520. */
  61521. export class KeyPropertySet {
  61522. /** Width */
  61523. width?: string;
  61524. /** Height */
  61525. height?: string;
  61526. /** Left padding */
  61527. paddingLeft?: string;
  61528. /** Right padding */
  61529. paddingRight?: string;
  61530. /** Top padding */
  61531. paddingTop?: string;
  61532. /** Bottom padding */
  61533. paddingBottom?: string;
  61534. /** Foreground color */
  61535. color?: string;
  61536. /** Background color */
  61537. background?: string;
  61538. }
  61539. /**
  61540. * Class used to create virtual keyboard
  61541. */
  61542. export class VirtualKeyboard extends StackPanel {
  61543. /** BABYLON.Observable raised when a key is pressed */
  61544. onKeyPressObservable: BABYLON.Observable<string>;
  61545. /** Gets or sets default key button width */
  61546. defaultButtonWidth: string;
  61547. /** Gets or sets default key button height */
  61548. defaultButtonHeight: string;
  61549. /** Gets or sets default key button left padding */
  61550. defaultButtonPaddingLeft: string;
  61551. /** Gets or sets default key button right padding */
  61552. defaultButtonPaddingRight: string;
  61553. /** Gets or sets default key button top padding */
  61554. defaultButtonPaddingTop: string;
  61555. /** Gets or sets default key button bottom padding */
  61556. defaultButtonPaddingBottom: string;
  61557. /** Gets or sets default key button foreground color */
  61558. defaultButtonColor: string;
  61559. /** Gets or sets default key button background color */
  61560. defaultButtonBackground: string;
  61561. /** Gets or sets shift button foreground color */
  61562. shiftButtonColor: string;
  61563. /** Gets or sets shift button thickness*/
  61564. selectedShiftThickness: number;
  61565. /** Gets shift key state */
  61566. shiftState: number;
  61567. protected _getTypeName(): string;
  61568. private _createKey;
  61569. /**
  61570. * Adds a new row of keys
  61571. * @param keys defines the list of keys to add
  61572. * @param propertySets defines the associated property sets
  61573. */
  61574. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61575. /**
  61576. * Set the shift key to a specific state
  61577. * @param shiftState defines the new shift state
  61578. */
  61579. applyShiftState(shiftState: number): void;
  61580. private _currentlyConnectedInputText;
  61581. private _connectedInputTexts;
  61582. private _onKeyPressObserver;
  61583. /** Gets the input text control currently attached to the keyboard */
  61584. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61585. /**
  61586. * Connects the keyboard with an input text control
  61587. *
  61588. * @param input defines the target control
  61589. */
  61590. connect(input: InputText): void;
  61591. /**
  61592. * Disconnects the keyboard from connected InputText controls
  61593. *
  61594. * @param input optionally defines a target control, otherwise all are disconnected
  61595. */
  61596. disconnect(input?: InputText): void;
  61597. private _removeConnectedInputObservables;
  61598. /**
  61599. * Release all resources
  61600. */
  61601. dispose(): void;
  61602. /**
  61603. * Creates a new keyboard using a default layout
  61604. *
  61605. * @param name defines control name
  61606. * @returns a new VirtualKeyboard
  61607. */
  61608. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61609. }
  61610. }
  61611. declare module BABYLON.GUI {
  61612. /**
  61613. * Class used to create input text control
  61614. */
  61615. export class InputText extends Control implements IFocusableControl {
  61616. name?: string | undefined;
  61617. private _text;
  61618. private _placeholderText;
  61619. private _background;
  61620. private _focusedBackground;
  61621. private _focusedColor;
  61622. private _placeholderColor;
  61623. private _thickness;
  61624. private _margin;
  61625. private _autoStretchWidth;
  61626. private _maxWidth;
  61627. private _isFocused;
  61628. private _blinkTimeout;
  61629. private _blinkIsEven;
  61630. private _cursorOffset;
  61631. private _scrollLeft;
  61632. private _textWidth;
  61633. private _clickedCoordinate;
  61634. private _deadKey;
  61635. private _addKey;
  61636. private _currentKey;
  61637. private _isTextHighlightOn;
  61638. private _textHighlightColor;
  61639. private _highligherOpacity;
  61640. private _highlightedText;
  61641. private _startHighlightIndex;
  61642. private _endHighlightIndex;
  61643. private _cursorIndex;
  61644. private _onFocusSelectAll;
  61645. private _isPointerDown;
  61646. private _onClipboardObserver;
  61647. private _onPointerDblTapObserver;
  61648. /** @hidden */
  61649. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61650. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61651. promptMessage: string;
  61652. /** BABYLON.Observable raised when the text changes */
  61653. onTextChangedObservable: BABYLON.Observable<InputText>;
  61654. /** BABYLON.Observable raised just before an entered character is to be added */
  61655. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61656. /** BABYLON.Observable raised when the control gets the focus */
  61657. onFocusObservable: BABYLON.Observable<InputText>;
  61658. /** BABYLON.Observable raised when the control loses the focus */
  61659. onBlurObservable: BABYLON.Observable<InputText>;
  61660. /**Observable raised when the text is highlighted */
  61661. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61662. /**Observable raised when copy event is triggered */
  61663. onTextCopyObservable: BABYLON.Observable<InputText>;
  61664. /** BABYLON.Observable raised when cut event is triggered */
  61665. onTextCutObservable: BABYLON.Observable<InputText>;
  61666. /** BABYLON.Observable raised when paste event is triggered */
  61667. onTextPasteObservable: BABYLON.Observable<InputText>;
  61668. /** BABYLON.Observable raised when a key event was processed */
  61669. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61670. /** Gets or sets the maximum width allowed by the control */
  61671. maxWidth: string | number;
  61672. /** Gets the maximum width allowed by the control in pixels */
  61673. readonly maxWidthInPixels: number;
  61674. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61675. highligherOpacity: number;
  61676. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61677. onFocusSelectAll: boolean;
  61678. /** Gets or sets the text hightlight color */
  61679. textHighlightColor: string;
  61680. /** Gets or sets control margin */
  61681. margin: string;
  61682. /** Gets control margin in pixels */
  61683. readonly marginInPixels: number;
  61684. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61685. autoStretchWidth: boolean;
  61686. /** Gets or sets border thickness */
  61687. thickness: number;
  61688. /** Gets or sets the background color when focused */
  61689. focusedBackground: string;
  61690. /** Gets or sets the background color when focused */
  61691. focusedColor: string;
  61692. /** Gets or sets the background color */
  61693. background: string;
  61694. /** Gets or sets the placeholder color */
  61695. placeholderColor: string;
  61696. /** Gets or sets the text displayed when the control is empty */
  61697. placeholderText: string;
  61698. /** Gets or sets the dead key flag */
  61699. deadKey: boolean;
  61700. /** Gets or sets the highlight text */
  61701. highlightedText: string;
  61702. /** Gets or sets if the current key should be added */
  61703. addKey: boolean;
  61704. /** Gets or sets the value of the current key being entered */
  61705. currentKey: string;
  61706. /** Gets or sets the text displayed in the control */
  61707. text: string;
  61708. /** Gets or sets control width */
  61709. width: string | number;
  61710. /**
  61711. * Creates a new InputText
  61712. * @param name defines the control name
  61713. * @param text defines the text of the control
  61714. */
  61715. constructor(name?: string | undefined, text?: string);
  61716. /** @hidden */
  61717. onBlur(): void;
  61718. /** @hidden */
  61719. onFocus(): void;
  61720. protected _getTypeName(): string;
  61721. /**
  61722. * Function called to get the list of controls that should not steal the focus from this control
  61723. * @returns an array of controls
  61724. */
  61725. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61726. /** @hidden */
  61727. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61728. /** @hidden */
  61729. private _updateValueFromCursorIndex;
  61730. /** @hidden */
  61731. private _processDblClick;
  61732. /** @hidden */
  61733. private _selectAllText;
  61734. /**
  61735. * Handles the keyboard event
  61736. * @param evt Defines the KeyboardEvent
  61737. */
  61738. processKeyboard(evt: KeyboardEvent): void;
  61739. /** @hidden */
  61740. private _onCopyText;
  61741. /** @hidden */
  61742. private _onCutText;
  61743. /** @hidden */
  61744. private _onPasteText;
  61745. _draw(context: CanvasRenderingContext2D): void;
  61746. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61747. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61748. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61749. protected _beforeRenderText(text: string): string;
  61750. dispose(): void;
  61751. }
  61752. }
  61753. declare module BABYLON.GUI {
  61754. /**
  61755. * Class used to create a 2D grid container
  61756. */
  61757. export class Grid extends Container {
  61758. name?: string | undefined;
  61759. private _rowDefinitions;
  61760. private _columnDefinitions;
  61761. private _cells;
  61762. private _childControls;
  61763. /**
  61764. * Gets the number of columns
  61765. */
  61766. readonly columnCount: number;
  61767. /**
  61768. * Gets the number of rows
  61769. */
  61770. readonly rowCount: number;
  61771. /** Gets the list of children */
  61772. readonly children: Control[];
  61773. /** Gets the list of cells (e.g. the containers) */
  61774. readonly cells: {
  61775. [key: string]: Container;
  61776. };
  61777. /**
  61778. * Gets the definition of a specific row
  61779. * @param index defines the index of the row
  61780. * @returns the row definition
  61781. */
  61782. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61783. /**
  61784. * Gets the definition of a specific column
  61785. * @param index defines the index of the column
  61786. * @returns the column definition
  61787. */
  61788. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61789. /**
  61790. * Adds a new row to the grid
  61791. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61792. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61793. * @returns the current grid
  61794. */
  61795. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61796. /**
  61797. * Adds a new column to the grid
  61798. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61799. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61800. * @returns the current grid
  61801. */
  61802. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61803. /**
  61804. * Update a row definition
  61805. * @param index defines the index of the row to update
  61806. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61807. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61808. * @returns the current grid
  61809. */
  61810. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61811. /**
  61812. * Update a column definition
  61813. * @param index defines the index of the column to update
  61814. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61815. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61816. * @returns the current grid
  61817. */
  61818. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61819. /**
  61820. * Gets the list of children stored in a specific cell
  61821. * @param row defines the row to check
  61822. * @param column defines the column to check
  61823. * @returns the list of controls
  61824. */
  61825. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61826. /**
  61827. * Gets a string representing the child cell info (row x column)
  61828. * @param child defines the control to get info from
  61829. * @returns a string containing the child cell info (row x column)
  61830. */
  61831. getChildCellInfo(child: Control): string;
  61832. private _removeCell;
  61833. private _offsetCell;
  61834. /**
  61835. * Remove a column definition at specified index
  61836. * @param index defines the index of the column to remove
  61837. * @returns the current grid
  61838. */
  61839. removeColumnDefinition(index: number): Grid;
  61840. /**
  61841. * Remove a row definition at specified index
  61842. * @param index defines the index of the row to remove
  61843. * @returns the current grid
  61844. */
  61845. removeRowDefinition(index: number): Grid;
  61846. /**
  61847. * Adds a new control to the current grid
  61848. * @param control defines the control to add
  61849. * @param row defines the row where to add the control (0 by default)
  61850. * @param column defines the column where to add the control (0 by default)
  61851. * @returns the current grid
  61852. */
  61853. addControl(control: Control, row?: number, column?: number): Grid;
  61854. /**
  61855. * Removes a control from the current container
  61856. * @param control defines the control to remove
  61857. * @returns the current container
  61858. */
  61859. removeControl(control: Control): Container;
  61860. /**
  61861. * Creates a new Grid
  61862. * @param name defines control name
  61863. */
  61864. constructor(name?: string | undefined);
  61865. protected _getTypeName(): string;
  61866. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61867. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61868. _flagDescendantsAsMatrixDirty(): void;
  61869. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61870. /** Releases associated resources */
  61871. dispose(): void;
  61872. }
  61873. }
  61874. declare module BABYLON.GUI {
  61875. /** Class used to create color pickers */
  61876. export class ColorPicker extends Control {
  61877. name?: string | undefined;
  61878. private static _Epsilon;
  61879. private _colorWheelCanvas;
  61880. private _value;
  61881. private _tmpColor;
  61882. private _pointerStartedOnSquare;
  61883. private _pointerStartedOnWheel;
  61884. private _squareLeft;
  61885. private _squareTop;
  61886. private _squareSize;
  61887. private _h;
  61888. private _s;
  61889. private _v;
  61890. private _lastPointerDownID;
  61891. /**
  61892. * BABYLON.Observable raised when the value changes
  61893. */
  61894. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61895. /** Gets or sets the color of the color picker */
  61896. value: BABYLON.Color3;
  61897. /**
  61898. * Gets or sets control width
  61899. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61900. */
  61901. width: string | number;
  61902. /**
  61903. * Gets or sets control height
  61904. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61905. */
  61906. /** Gets or sets control height */
  61907. height: string | number;
  61908. /** Gets or sets control size */
  61909. size: string | number;
  61910. /**
  61911. * Creates a new ColorPicker
  61912. * @param name defines the control name
  61913. */
  61914. constructor(name?: string | undefined);
  61915. protected _getTypeName(): string;
  61916. /** @hidden */
  61917. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61918. private _updateSquareProps;
  61919. private _drawGradientSquare;
  61920. private _drawCircle;
  61921. private _createColorWheelCanvas;
  61922. /** @hidden */
  61923. _draw(context: CanvasRenderingContext2D): void;
  61924. private _pointerIsDown;
  61925. private _updateValueFromPointer;
  61926. private _isPointOnSquare;
  61927. private _isPointOnWheel;
  61928. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61929. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61930. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61931. /**
  61932. * This function expands the color picker by creating a color picker dialog with manual
  61933. * color value input and the ability to save colors into an array to be used later in
  61934. * subsequent launches of the dialogue.
  61935. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61936. * @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.
  61937. * @returns picked color as a hex string and the saved colors array as hex strings.
  61938. */
  61939. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61940. pickerWidth?: string;
  61941. pickerHeight?: string;
  61942. headerHeight?: string;
  61943. lastColor?: string;
  61944. swatchLimit?: number;
  61945. numSwatchesPerLine?: number;
  61946. savedColors?: Array<string>;
  61947. }): Promise<{
  61948. savedColors?: string[];
  61949. pickedColor: string;
  61950. }>;
  61951. }
  61952. }
  61953. declare module BABYLON.GUI {
  61954. /** Class used to create 2D ellipse containers */
  61955. export class Ellipse extends Container {
  61956. name?: string | undefined;
  61957. private _thickness;
  61958. /** Gets or sets border thickness */
  61959. thickness: number;
  61960. /**
  61961. * Creates a new Ellipse
  61962. * @param name defines the control name
  61963. */
  61964. constructor(name?: string | undefined);
  61965. protected _getTypeName(): string;
  61966. protected _localDraw(context: CanvasRenderingContext2D): void;
  61967. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61968. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61969. }
  61970. }
  61971. declare module BABYLON.GUI {
  61972. /**
  61973. * Class used to create a password control
  61974. */
  61975. export class InputPassword extends InputText {
  61976. protected _beforeRenderText(text: string): string;
  61977. }
  61978. }
  61979. declare module BABYLON.GUI {
  61980. /** Class used to render 2D lines */
  61981. export class Line extends Control {
  61982. name?: string | undefined;
  61983. private _lineWidth;
  61984. private _x1;
  61985. private _y1;
  61986. private _x2;
  61987. private _y2;
  61988. private _dash;
  61989. private _connectedControl;
  61990. private _connectedControlDirtyObserver;
  61991. /** Gets or sets the dash pattern */
  61992. dash: Array<number>;
  61993. /** Gets or sets the control connected with the line end */
  61994. connectedControl: Control;
  61995. /** Gets or sets start coordinates on X axis */
  61996. x1: string | number;
  61997. /** Gets or sets start coordinates on Y axis */
  61998. y1: string | number;
  61999. /** Gets or sets end coordinates on X axis */
  62000. x2: string | number;
  62001. /** Gets or sets end coordinates on Y axis */
  62002. y2: string | number;
  62003. /** Gets or sets line width */
  62004. lineWidth: number;
  62005. /** Gets or sets horizontal alignment */
  62006. horizontalAlignment: number;
  62007. /** Gets or sets vertical alignment */
  62008. verticalAlignment: number;
  62009. private readonly _effectiveX2;
  62010. private readonly _effectiveY2;
  62011. /**
  62012. * Creates a new Line
  62013. * @param name defines the control name
  62014. */
  62015. constructor(name?: string | undefined);
  62016. protected _getTypeName(): string;
  62017. _draw(context: CanvasRenderingContext2D): void;
  62018. _measure(): void;
  62019. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62020. /**
  62021. * Move one end of the line given 3D cartesian coordinates.
  62022. * @param position Targeted world position
  62023. * @param scene BABYLON.Scene
  62024. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62025. */
  62026. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62027. /**
  62028. * Move one end of the line to a position in screen absolute space.
  62029. * @param projectedPosition Position in screen absolute space (X, Y)
  62030. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62031. */
  62032. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62033. }
  62034. }
  62035. declare module BABYLON.GUI {
  62036. /**
  62037. * Class used to store a point for a MultiLine object.
  62038. * The point can be pure 2D coordinates, a mesh or a control
  62039. */
  62040. export class MultiLinePoint {
  62041. private _multiLine;
  62042. private _x;
  62043. private _y;
  62044. private _control;
  62045. private _mesh;
  62046. private _controlObserver;
  62047. private _meshObserver;
  62048. /** @hidden */
  62049. _point: BABYLON.Vector2;
  62050. /**
  62051. * Creates a new MultiLinePoint
  62052. * @param multiLine defines the source MultiLine object
  62053. */
  62054. constructor(multiLine: MultiLine);
  62055. /** Gets or sets x coordinate */
  62056. x: string | number;
  62057. /** Gets or sets y coordinate */
  62058. y: string | number;
  62059. /** Gets or sets the control associated with this point */
  62060. control: BABYLON.Nullable<Control>;
  62061. /** Gets or sets the mesh associated with this point */
  62062. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62063. /** Resets links */
  62064. resetLinks(): void;
  62065. /**
  62066. * Gets a translation vector
  62067. * @returns the translation vector
  62068. */
  62069. translate(): BABYLON.Vector2;
  62070. private _translatePoint;
  62071. /** Release associated resources */
  62072. dispose(): void;
  62073. }
  62074. }
  62075. declare module BABYLON.GUI {
  62076. /**
  62077. * Class used to create multi line control
  62078. */
  62079. export class MultiLine extends Control {
  62080. name?: string | undefined;
  62081. private _lineWidth;
  62082. private _dash;
  62083. private _points;
  62084. private _minX;
  62085. private _minY;
  62086. private _maxX;
  62087. private _maxY;
  62088. /**
  62089. * Creates a new MultiLine
  62090. * @param name defines the control name
  62091. */
  62092. constructor(name?: string | undefined);
  62093. /** Gets or sets dash pattern */
  62094. dash: Array<number>;
  62095. /**
  62096. * Gets point stored at specified index
  62097. * @param index defines the index to look for
  62098. * @returns the requested point if found
  62099. */
  62100. getAt(index: number): MultiLinePoint;
  62101. /** Function called when a point is updated */
  62102. onPointUpdate: () => void;
  62103. /**
  62104. * Adds new points to the point collection
  62105. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62106. * @returns the list of created MultiLinePoint
  62107. */
  62108. add(...items: (AbstractMesh | Control | {
  62109. x: string | number;
  62110. y: string | number;
  62111. })[]): MultiLinePoint[];
  62112. /**
  62113. * Adds a new point to the point collection
  62114. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62115. * @returns the created MultiLinePoint
  62116. */
  62117. push(item?: (AbstractMesh | Control | {
  62118. x: string | number;
  62119. y: string | number;
  62120. })): MultiLinePoint;
  62121. /**
  62122. * Remove a specific value or point from the active point collection
  62123. * @param value defines the value or point to remove
  62124. */
  62125. remove(value: number | MultiLinePoint): void;
  62126. /**
  62127. * Resets this object to initial state (no point)
  62128. */
  62129. reset(): void;
  62130. /**
  62131. * Resets all links
  62132. */
  62133. resetLinks(): void;
  62134. /** Gets or sets line width */
  62135. lineWidth: number;
  62136. horizontalAlignment: number;
  62137. verticalAlignment: number;
  62138. protected _getTypeName(): string;
  62139. _draw(context: CanvasRenderingContext2D): void;
  62140. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62141. _measure(): void;
  62142. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62143. dispose(): void;
  62144. }
  62145. }
  62146. declare module BABYLON.GUI {
  62147. /**
  62148. * Class used to create radio button controls
  62149. */
  62150. export class RadioButton extends Control {
  62151. name?: string | undefined;
  62152. private _isChecked;
  62153. private _background;
  62154. private _checkSizeRatio;
  62155. private _thickness;
  62156. /** Gets or sets border thickness */
  62157. thickness: number;
  62158. /** Gets or sets group name */
  62159. group: string;
  62160. /** BABYLON.Observable raised when isChecked is changed */
  62161. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62162. /** Gets or sets a value indicating the ratio between overall size and check size */
  62163. checkSizeRatio: number;
  62164. /** Gets or sets background color */
  62165. background: string;
  62166. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62167. isChecked: boolean;
  62168. /**
  62169. * Creates a new RadioButton
  62170. * @param name defines the control name
  62171. */
  62172. constructor(name?: string | undefined);
  62173. protected _getTypeName(): string;
  62174. _draw(context: CanvasRenderingContext2D): void;
  62175. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62176. /**
  62177. * Utility function to easily create a radio button with a header
  62178. * @param title defines the label to use for the header
  62179. * @param group defines the group to use for the radio button
  62180. * @param isChecked defines the initial state of the radio button
  62181. * @param onValueChanged defines the callback to call when value changes
  62182. * @returns a StackPanel containing the radio button and a textBlock
  62183. */
  62184. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62185. }
  62186. }
  62187. declare module BABYLON.GUI {
  62188. /**
  62189. * Class used to create slider controls
  62190. */
  62191. export class BaseSlider extends Control {
  62192. name?: string | undefined;
  62193. protected _thumbWidth: ValueAndUnit;
  62194. private _minimum;
  62195. private _maximum;
  62196. private _value;
  62197. private _isVertical;
  62198. protected _barOffset: ValueAndUnit;
  62199. private _isThumbClamped;
  62200. protected _displayThumb: boolean;
  62201. private _step;
  62202. private _lastPointerDownID;
  62203. protected _effectiveBarOffset: number;
  62204. protected _renderLeft: number;
  62205. protected _renderTop: number;
  62206. protected _renderWidth: number;
  62207. protected _renderHeight: number;
  62208. protected _backgroundBoxLength: number;
  62209. protected _backgroundBoxThickness: number;
  62210. protected _effectiveThumbThickness: number;
  62211. /** BABYLON.Observable raised when the sldier value changes */
  62212. onValueChangedObservable: BABYLON.Observable<number>;
  62213. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62214. displayThumb: boolean;
  62215. /** Gets or sets a step to apply to values (0 by default) */
  62216. step: number;
  62217. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62218. barOffset: string | number;
  62219. /** Gets main bar offset in pixels*/
  62220. readonly barOffsetInPixels: number;
  62221. /** Gets or sets thumb width */
  62222. thumbWidth: string | number;
  62223. /** Gets thumb width in pixels */
  62224. readonly thumbWidthInPixels: number;
  62225. /** Gets or sets minimum value */
  62226. minimum: number;
  62227. /** Gets or sets maximum value */
  62228. maximum: number;
  62229. /** Gets or sets current value */
  62230. value: number;
  62231. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62232. isVertical: boolean;
  62233. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62234. isThumbClamped: boolean;
  62235. /**
  62236. * Creates a new BaseSlider
  62237. * @param name defines the control name
  62238. */
  62239. constructor(name?: string | undefined);
  62240. protected _getTypeName(): string;
  62241. protected _getThumbPosition(): number;
  62242. protected _getThumbThickness(type: string): number;
  62243. protected _prepareRenderingData(type: string): void;
  62244. private _pointerIsDown;
  62245. /** @hidden */
  62246. protected _updateValueFromPointer(x: number, y: number): void;
  62247. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62248. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62249. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62250. }
  62251. }
  62252. declare module BABYLON.GUI {
  62253. /**
  62254. * Class used to create slider controls
  62255. */
  62256. export class Slider extends BaseSlider {
  62257. name?: string | undefined;
  62258. private _background;
  62259. private _borderColor;
  62260. private _isThumbCircle;
  62261. protected _displayValueBar: boolean;
  62262. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62263. displayValueBar: boolean;
  62264. /** Gets or sets border color */
  62265. borderColor: string;
  62266. /** Gets or sets background color */
  62267. background: string;
  62268. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62269. isThumbCircle: boolean;
  62270. /**
  62271. * Creates a new Slider
  62272. * @param name defines the control name
  62273. */
  62274. constructor(name?: string | undefined);
  62275. protected _getTypeName(): string;
  62276. _draw(context: CanvasRenderingContext2D): void;
  62277. }
  62278. }
  62279. declare module BABYLON.GUI {
  62280. /** Class used to create a RadioGroup
  62281. * which contains groups of radio buttons
  62282. */
  62283. export class SelectorGroup {
  62284. /** name of SelectorGroup */
  62285. name: string;
  62286. private _groupPanel;
  62287. private _selectors;
  62288. private _groupHeader;
  62289. /**
  62290. * Creates a new SelectorGroup
  62291. * @param name of group, used as a group heading
  62292. */
  62293. constructor(
  62294. /** name of SelectorGroup */
  62295. name: string);
  62296. /** Gets the groupPanel of the SelectorGroup */
  62297. readonly groupPanel: StackPanel;
  62298. /** Gets the selectors array */
  62299. readonly selectors: StackPanel[];
  62300. /** Gets and sets the group header */
  62301. header: string;
  62302. /** @hidden */
  62303. private _addGroupHeader;
  62304. /** @hidden*/
  62305. _getSelector(selectorNb: number): StackPanel | undefined;
  62306. /** Removes the selector at the given position
  62307. * @param selectorNb the position of the selector within the group
  62308. */
  62309. removeSelector(selectorNb: number): void;
  62310. }
  62311. /** Class used to create a CheckboxGroup
  62312. * which contains groups of checkbox buttons
  62313. */
  62314. export class CheckboxGroup extends SelectorGroup {
  62315. /** Adds a checkbox as a control
  62316. * @param text is the label for the selector
  62317. * @param func is the function called when the Selector is checked
  62318. * @param checked is true when Selector is checked
  62319. */
  62320. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62321. /** @hidden */
  62322. _setSelectorLabel(selectorNb: number, label: string): void;
  62323. /** @hidden */
  62324. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62325. /** @hidden */
  62326. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62327. /** @hidden */
  62328. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62329. }
  62330. /** Class used to create a RadioGroup
  62331. * which contains groups of radio buttons
  62332. */
  62333. export class RadioGroup extends SelectorGroup {
  62334. private _selectNb;
  62335. /** Adds a radio button as a control
  62336. * @param label is the label for the selector
  62337. * @param func is the function called when the Selector is checked
  62338. * @param checked is true when Selector is checked
  62339. */
  62340. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62341. /** @hidden */
  62342. _setSelectorLabel(selectorNb: number, label: string): void;
  62343. /** @hidden */
  62344. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62345. /** @hidden */
  62346. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62347. /** @hidden */
  62348. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62349. }
  62350. /** Class used to create a SliderGroup
  62351. * which contains groups of slider buttons
  62352. */
  62353. export class SliderGroup extends SelectorGroup {
  62354. /**
  62355. * Adds a slider to the SelectorGroup
  62356. * @param label is the label for the SliderBar
  62357. * @param func is the function called when the Slider moves
  62358. * @param unit is a string describing the units used, eg degrees or metres
  62359. * @param min is the minimum value for the Slider
  62360. * @param max is the maximum value for the Slider
  62361. * @param value is the start value for the Slider between min and max
  62362. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62363. */
  62364. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62365. /** @hidden */
  62366. _setSelectorLabel(selectorNb: number, label: string): void;
  62367. /** @hidden */
  62368. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62369. /** @hidden */
  62370. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62371. /** @hidden */
  62372. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62373. }
  62374. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62375. * @see http://doc.babylonjs.com/how_to/selector
  62376. */
  62377. export class SelectionPanel extends Rectangle {
  62378. /** name of SelectionPanel */
  62379. name: string;
  62380. /** an array of SelectionGroups */
  62381. groups: SelectorGroup[];
  62382. private _panel;
  62383. private _buttonColor;
  62384. private _buttonBackground;
  62385. private _headerColor;
  62386. private _barColor;
  62387. private _barHeight;
  62388. private _spacerHeight;
  62389. private _labelColor;
  62390. private _groups;
  62391. private _bars;
  62392. /**
  62393. * Creates a new SelectionPanel
  62394. * @param name of SelectionPanel
  62395. * @param groups is an array of SelectionGroups
  62396. */
  62397. constructor(
  62398. /** name of SelectionPanel */
  62399. name: string,
  62400. /** an array of SelectionGroups */
  62401. groups?: SelectorGroup[]);
  62402. protected _getTypeName(): string;
  62403. /** Gets or sets the headerColor */
  62404. headerColor: string;
  62405. private _setHeaderColor;
  62406. /** Gets or sets the button color */
  62407. buttonColor: string;
  62408. private _setbuttonColor;
  62409. /** Gets or sets the label color */
  62410. labelColor: string;
  62411. private _setLabelColor;
  62412. /** Gets or sets the button background */
  62413. buttonBackground: string;
  62414. private _setButtonBackground;
  62415. /** Gets or sets the color of separator bar */
  62416. barColor: string;
  62417. private _setBarColor;
  62418. /** Gets or sets the height of separator bar */
  62419. barHeight: string;
  62420. private _setBarHeight;
  62421. /** Gets or sets the height of spacers*/
  62422. spacerHeight: string;
  62423. private _setSpacerHeight;
  62424. /** Adds a bar between groups */
  62425. private _addSpacer;
  62426. /** Add a group to the selection panel
  62427. * @param group is the selector group to add
  62428. */
  62429. addGroup(group: SelectorGroup): void;
  62430. /** Remove the group from the given position
  62431. * @param groupNb is the position of the group in the list
  62432. */
  62433. removeGroup(groupNb: number): void;
  62434. /** Change a group header label
  62435. * @param label is the new group header label
  62436. * @param groupNb is the number of the group to relabel
  62437. * */
  62438. setHeaderName(label: string, groupNb: number): void;
  62439. /** Change selector label to the one given
  62440. * @param label is the new selector label
  62441. * @param groupNb is the number of the groupcontaining the selector
  62442. * @param selectorNb is the number of the selector within a group to relabel
  62443. * */
  62444. relabel(label: string, groupNb: number, selectorNb: number): void;
  62445. /** For a given group position remove the selector at the given position
  62446. * @param groupNb is the number of the group to remove the selector from
  62447. * @param selectorNb is the number of the selector within the group
  62448. */
  62449. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62450. /** For a given group position of correct type add a checkbox button
  62451. * @param groupNb is the number of the group to remove the selector from
  62452. * @param label is the label for the selector
  62453. * @param func is the function called when the Selector is checked
  62454. * @param checked is true when Selector is checked
  62455. */
  62456. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62457. /** For a given group position of correct type add a radio button
  62458. * @param groupNb is the number of the group to remove the selector from
  62459. * @param label is the label for the selector
  62460. * @param func is the function called when the Selector is checked
  62461. * @param checked is true when Selector is checked
  62462. */
  62463. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62464. /**
  62465. * For a given slider group add a slider
  62466. * @param groupNb is the number of the group to add the slider to
  62467. * @param label is the label for the Slider
  62468. * @param func is the function called when the Slider moves
  62469. * @param unit is a string describing the units used, eg degrees or metres
  62470. * @param min is the minimum value for the Slider
  62471. * @param max is the maximum value for the Slider
  62472. * @param value is the start value for the Slider between min and max
  62473. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62474. */
  62475. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62476. }
  62477. }
  62478. declare module BABYLON.GUI {
  62479. /**
  62480. * Class used to hold a the container for ScrollViewer
  62481. * @hidden
  62482. */
  62483. export class _ScrollViewerWindow extends Container {
  62484. parentClientWidth: number;
  62485. parentClientHeight: number;
  62486. /**
  62487. * Creates a new ScrollViewerWindow
  62488. * @param name of ScrollViewerWindow
  62489. */
  62490. constructor(name?: string);
  62491. protected _getTypeName(): string;
  62492. /** @hidden */
  62493. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62494. protected _postMeasure(): void;
  62495. }
  62496. }
  62497. declare module BABYLON.GUI {
  62498. /**
  62499. * Class used to create slider controls
  62500. */
  62501. export class ScrollBar extends BaseSlider {
  62502. name?: string | undefined;
  62503. private _background;
  62504. private _borderColor;
  62505. private _thumbMeasure;
  62506. /** Gets or sets border color */
  62507. borderColor: string;
  62508. /** Gets or sets background color */
  62509. background: string;
  62510. /**
  62511. * Creates a new Slider
  62512. * @param name defines the control name
  62513. */
  62514. constructor(name?: string | undefined);
  62515. protected _getTypeName(): string;
  62516. protected _getThumbThickness(): number;
  62517. _draw(context: CanvasRenderingContext2D): void;
  62518. private _first;
  62519. private _originX;
  62520. private _originY;
  62521. /** @hidden */
  62522. protected _updateValueFromPointer(x: number, y: number): void;
  62523. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62524. }
  62525. }
  62526. declare module BABYLON.GUI {
  62527. /**
  62528. * Class used to hold a viewer window and sliders in a grid
  62529. */
  62530. export class ScrollViewer extends Rectangle {
  62531. private _grid;
  62532. private _horizontalBarSpace;
  62533. private _verticalBarSpace;
  62534. private _dragSpace;
  62535. private _horizontalBar;
  62536. private _verticalBar;
  62537. private _barColor;
  62538. private _barBackground;
  62539. private _barSize;
  62540. private _endLeft;
  62541. private _endTop;
  62542. private _window;
  62543. private _pointerIsOver;
  62544. private _wheelPrecision;
  62545. private _onPointerObserver;
  62546. private _clientWidth;
  62547. private _clientHeight;
  62548. /**
  62549. * Gets the horizontal scrollbar
  62550. */
  62551. readonly horizontalBar: ScrollBar;
  62552. /**
  62553. * Gets the vertical scrollbar
  62554. */
  62555. readonly verticalBar: ScrollBar;
  62556. /**
  62557. * Adds a new control to the current container
  62558. * @param control defines the control to add
  62559. * @returns the current container
  62560. */
  62561. addControl(control: BABYLON.Nullable<Control>): Container;
  62562. /**
  62563. * Removes a control from the current container
  62564. * @param control defines the control to remove
  62565. * @returns the current container
  62566. */
  62567. removeControl(control: Control): Container;
  62568. /** Gets the list of children */
  62569. readonly children: Control[];
  62570. _flagDescendantsAsMatrixDirty(): void;
  62571. /**
  62572. * Creates a new ScrollViewer
  62573. * @param name of ScrollViewer
  62574. */
  62575. constructor(name?: string);
  62576. /** Reset the scroll viewer window to initial size */
  62577. resetWindow(): void;
  62578. protected _getTypeName(): string;
  62579. private _buildClientSizes;
  62580. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62581. protected _postMeasure(): void;
  62582. /**
  62583. * Gets or sets the mouse wheel precision
  62584. * from 0 to 1 with a default value of 0.05
  62585. * */
  62586. wheelPrecision: number;
  62587. /** Gets or sets the bar color */
  62588. barColor: string;
  62589. /** Gets or sets the size of the bar */
  62590. barSize: number;
  62591. /** Gets or sets the bar background */
  62592. barBackground: string;
  62593. /** @hidden */
  62594. private _updateScroller;
  62595. _link(host: AdvancedDynamicTexture): void;
  62596. /** @hidden */
  62597. private _attachWheel;
  62598. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62599. /** Releases associated resources */
  62600. dispose(): void;
  62601. }
  62602. }
  62603. declare module BABYLON.GUI {
  62604. /** Class used to render a grid */
  62605. export class DisplayGrid extends Control {
  62606. name?: string | undefined;
  62607. private _cellWidth;
  62608. private _cellHeight;
  62609. private _minorLineTickness;
  62610. private _minorLineColor;
  62611. private _majorLineTickness;
  62612. private _majorLineColor;
  62613. private _majorLineFrequency;
  62614. private _background;
  62615. private _displayMajorLines;
  62616. private _displayMinorLines;
  62617. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62618. displayMinorLines: boolean;
  62619. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62620. displayMajorLines: boolean;
  62621. /** Gets or sets background color (Black by default) */
  62622. background: string;
  62623. /** Gets or sets the width of each cell (20 by default) */
  62624. cellWidth: number;
  62625. /** Gets or sets the height of each cell (20 by default) */
  62626. cellHeight: number;
  62627. /** Gets or sets the tickness of minor lines (1 by default) */
  62628. minorLineTickness: number;
  62629. /** Gets or sets the color of minor lines (DarkGray by default) */
  62630. minorLineColor: string;
  62631. /** Gets or sets the tickness of major lines (2 by default) */
  62632. majorLineTickness: number;
  62633. /** Gets or sets the color of major lines (White by default) */
  62634. majorLineColor: string;
  62635. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62636. majorLineFrequency: number;
  62637. /**
  62638. * Creates a new GridDisplayRectangle
  62639. * @param name defines the control name
  62640. */
  62641. constructor(name?: string | undefined);
  62642. _draw(context: CanvasRenderingContext2D): void;
  62643. protected _getTypeName(): string;
  62644. }
  62645. }
  62646. declare module BABYLON.GUI {
  62647. /**
  62648. * Class used to create slider controls based on images
  62649. */
  62650. export class ImageBasedSlider extends BaseSlider {
  62651. name?: string | undefined;
  62652. private _backgroundImage;
  62653. private _thumbImage;
  62654. private _valueBarImage;
  62655. private _tempMeasure;
  62656. displayThumb: boolean;
  62657. /**
  62658. * Gets or sets the image used to render the background
  62659. */
  62660. backgroundImage: Image;
  62661. /**
  62662. * Gets or sets the image used to render the value bar
  62663. */
  62664. valueBarImage: Image;
  62665. /**
  62666. * Gets or sets the image used to render the thumb
  62667. */
  62668. thumbImage: Image;
  62669. /**
  62670. * Creates a new ImageBasedSlider
  62671. * @param name defines the control name
  62672. */
  62673. constructor(name?: string | undefined);
  62674. protected _getTypeName(): string;
  62675. _draw(context: CanvasRenderingContext2D): void;
  62676. }
  62677. }
  62678. declare module BABYLON.GUI {
  62679. /**
  62680. * Forcing an export so that this code will execute
  62681. * @hidden
  62682. */
  62683. const name = "Statics";
  62684. }
  62685. declare module BABYLON.GUI {
  62686. /**
  62687. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62688. */
  62689. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62690. /**
  62691. * Define the instrumented AdvancedDynamicTexture.
  62692. */
  62693. texture: AdvancedDynamicTexture;
  62694. private _captureRenderTime;
  62695. private _renderTime;
  62696. private _captureLayoutTime;
  62697. private _layoutTime;
  62698. private _onBeginRenderObserver;
  62699. private _onEndRenderObserver;
  62700. private _onBeginLayoutObserver;
  62701. private _onEndLayoutObserver;
  62702. /**
  62703. * Gets the perf counter used to capture render time
  62704. */
  62705. readonly renderTimeCounter: BABYLON.PerfCounter;
  62706. /**
  62707. * Gets the perf counter used to capture layout time
  62708. */
  62709. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62710. /**
  62711. * Enable or disable the render time capture
  62712. */
  62713. captureRenderTime: boolean;
  62714. /**
  62715. * Enable or disable the layout time capture
  62716. */
  62717. captureLayoutTime: boolean;
  62718. /**
  62719. * Instantiates a new advanced dynamic texture instrumentation.
  62720. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62721. * @param texture Defines the AdvancedDynamicTexture to instrument
  62722. */
  62723. constructor(
  62724. /**
  62725. * Define the instrumented AdvancedDynamicTexture.
  62726. */
  62727. texture: AdvancedDynamicTexture);
  62728. /**
  62729. * Dispose and release associated resources.
  62730. */
  62731. dispose(): void;
  62732. }
  62733. }
  62734. declare module BABYLON.GUI {
  62735. /**
  62736. * Class used to create containers for controls
  62737. */
  62738. export class Container3D extends Control3D {
  62739. private _blockLayout;
  62740. /**
  62741. * Gets the list of child controls
  62742. */
  62743. protected _children: Control3D[];
  62744. /**
  62745. * Gets the list of child controls
  62746. */
  62747. readonly children: Array<Control3D>;
  62748. /**
  62749. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62750. * This is helpful to optimize layout operation when adding multiple children in a row
  62751. */
  62752. blockLayout: boolean;
  62753. /**
  62754. * Creates a new container
  62755. * @param name defines the container name
  62756. */
  62757. constructor(name?: string);
  62758. /**
  62759. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62760. * @returns the current container
  62761. */
  62762. updateLayout(): Container3D;
  62763. /**
  62764. * Gets a boolean indicating if the given control is in the children of this control
  62765. * @param control defines the control to check
  62766. * @returns true if the control is in the child list
  62767. */
  62768. containsControl(control: Control3D): boolean;
  62769. /**
  62770. * Adds a control to the children of this control
  62771. * @param control defines the control to add
  62772. * @returns the current container
  62773. */
  62774. addControl(control: Control3D): Container3D;
  62775. /**
  62776. * This function will be called everytime a new control is added
  62777. */
  62778. protected _arrangeChildren(): void;
  62779. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62780. /**
  62781. * Removes a control from the children of this control
  62782. * @param control defines the control to remove
  62783. * @returns the current container
  62784. */
  62785. removeControl(control: Control3D): Container3D;
  62786. protected _getTypeName(): string;
  62787. /**
  62788. * Releases all associated resources
  62789. */
  62790. dispose(): void;
  62791. /** Control rotation will remain unchanged */
  62792. static readonly UNSET_ORIENTATION: number;
  62793. /** Control will rotate to make it look at sphere central axis */
  62794. static readonly FACEORIGIN_ORIENTATION: number;
  62795. /** Control will rotate to make it look back at sphere central axis */
  62796. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62797. /** Control will rotate to look at z axis (0, 0, 1) */
  62798. static readonly FACEFORWARD_ORIENTATION: number;
  62799. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62800. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62801. }
  62802. }
  62803. declare module BABYLON.GUI {
  62804. /**
  62805. * Class used to manage 3D user interface
  62806. * @see http://doc.babylonjs.com/how_to/gui3d
  62807. */
  62808. export class GUI3DManager implements BABYLON.IDisposable {
  62809. private _scene;
  62810. private _sceneDisposeObserver;
  62811. private _utilityLayer;
  62812. private _rootContainer;
  62813. private _pointerObserver;
  62814. private _pointerOutObserver;
  62815. /** @hidden */
  62816. _lastPickedControl: Control3D;
  62817. /** @hidden */
  62818. _lastControlOver: {
  62819. [pointerId: number]: Control3D;
  62820. };
  62821. /** @hidden */
  62822. _lastControlDown: {
  62823. [pointerId: number]: Control3D;
  62824. };
  62825. /**
  62826. * BABYLON.Observable raised when the point picked by the pointer events changed
  62827. */
  62828. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62829. /** @hidden */
  62830. _sharedMaterials: {
  62831. [key: string]: BABYLON.Material;
  62832. };
  62833. /** Gets the hosting scene */
  62834. readonly scene: BABYLON.Scene;
  62835. /** Gets associated utility layer */
  62836. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62837. /**
  62838. * Creates a new GUI3DManager
  62839. * @param scene
  62840. */
  62841. constructor(scene?: BABYLON.Scene);
  62842. private _handlePointerOut;
  62843. private _doPicking;
  62844. /**
  62845. * Gets the root container
  62846. */
  62847. readonly rootContainer: Container3D;
  62848. /**
  62849. * Gets a boolean indicating if the given control is in the root child list
  62850. * @param control defines the control to check
  62851. * @returns true if the control is in the root child list
  62852. */
  62853. containsControl(control: Control3D): boolean;
  62854. /**
  62855. * Adds a control to the root child list
  62856. * @param control defines the control to add
  62857. * @returns the current manager
  62858. */
  62859. addControl(control: Control3D): GUI3DManager;
  62860. /**
  62861. * Removes a control from the root child list
  62862. * @param control defines the control to remove
  62863. * @returns the current container
  62864. */
  62865. removeControl(control: Control3D): GUI3DManager;
  62866. /**
  62867. * Releases all associated resources
  62868. */
  62869. dispose(): void;
  62870. }
  62871. }
  62872. declare module BABYLON.GUI {
  62873. /**
  62874. * Class used to transport BABYLON.Vector3 information for pointer events
  62875. */
  62876. export class Vector3WithInfo extends BABYLON.Vector3 {
  62877. /** defines the current mouse button index */
  62878. buttonIndex: number;
  62879. /**
  62880. * Creates a new Vector3WithInfo
  62881. * @param source defines the vector3 data to transport
  62882. * @param buttonIndex defines the current mouse button index
  62883. */
  62884. constructor(source: BABYLON.Vector3,
  62885. /** defines the current mouse button index */
  62886. buttonIndex?: number);
  62887. }
  62888. }
  62889. declare module BABYLON.GUI {
  62890. /**
  62891. * Class used as base class for controls
  62892. */
  62893. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62894. /** Defines the control name */
  62895. name?: string | undefined;
  62896. /** @hidden */
  62897. _host: GUI3DManager;
  62898. private _node;
  62899. private _downCount;
  62900. private _enterCount;
  62901. private _downPointerIds;
  62902. private _isVisible;
  62903. /** Gets or sets the control position in world space */
  62904. position: BABYLON.Vector3;
  62905. /** Gets or sets the control scaling in world space */
  62906. scaling: BABYLON.Vector3;
  62907. /** Callback used to start pointer enter animation */
  62908. pointerEnterAnimation: () => void;
  62909. /** Callback used to start pointer out animation */
  62910. pointerOutAnimation: () => void;
  62911. /** Callback used to start pointer down animation */
  62912. pointerDownAnimation: () => void;
  62913. /** Callback used to start pointer up animation */
  62914. pointerUpAnimation: () => void;
  62915. /**
  62916. * An event triggered when the pointer move over the control
  62917. */
  62918. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62919. /**
  62920. * An event triggered when the pointer move out of the control
  62921. */
  62922. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62923. /**
  62924. * An event triggered when the pointer taps the control
  62925. */
  62926. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62927. /**
  62928. * An event triggered when pointer is up
  62929. */
  62930. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62931. /**
  62932. * An event triggered when a control is clicked on (with a mouse)
  62933. */
  62934. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62935. /**
  62936. * An event triggered when pointer enters the control
  62937. */
  62938. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62939. /**
  62940. * Gets or sets the parent container
  62941. */
  62942. parent: BABYLON.Nullable<Container3D>;
  62943. private _behaviors;
  62944. /**
  62945. * Gets the list of attached behaviors
  62946. * @see http://doc.babylonjs.com/features/behaviour
  62947. */
  62948. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62949. /**
  62950. * Attach a behavior to the control
  62951. * @see http://doc.babylonjs.com/features/behaviour
  62952. * @param behavior defines the behavior to attach
  62953. * @returns the current control
  62954. */
  62955. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62956. /**
  62957. * Remove an attached behavior
  62958. * @see http://doc.babylonjs.com/features/behaviour
  62959. * @param behavior defines the behavior to attach
  62960. * @returns the current control
  62961. */
  62962. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62963. /**
  62964. * Gets an attached behavior by name
  62965. * @param name defines the name of the behavior to look for
  62966. * @see http://doc.babylonjs.com/features/behaviour
  62967. * @returns null if behavior was not found else the requested behavior
  62968. */
  62969. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62970. /** Gets or sets a boolean indicating if the control is visible */
  62971. isVisible: boolean;
  62972. /**
  62973. * Creates a new control
  62974. * @param name defines the control name
  62975. */
  62976. constructor(
  62977. /** Defines the control name */
  62978. name?: string | undefined);
  62979. /**
  62980. * Gets a string representing the class name
  62981. */
  62982. readonly typeName: string;
  62983. /**
  62984. * Get the current class name of the control.
  62985. * @returns current class name
  62986. */
  62987. getClassName(): string;
  62988. protected _getTypeName(): string;
  62989. /**
  62990. * Gets the transform node used by this control
  62991. */
  62992. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62993. /**
  62994. * Gets the mesh used to render this control
  62995. */
  62996. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62997. /**
  62998. * Link the control as child of the given node
  62999. * @param node defines the node to link to. Use null to unlink the control
  63000. * @returns the current control
  63001. */
  63002. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63003. /** @hidden **/
  63004. _prepareNode(scene: BABYLON.Scene): void;
  63005. /**
  63006. * Node creation.
  63007. * Can be overriden by children
  63008. * @param scene defines the scene where the node must be attached
  63009. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63010. */
  63011. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63012. /**
  63013. * Affect a material to the given mesh
  63014. * @param mesh defines the mesh which will represent the control
  63015. */
  63016. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63017. /** @hidden */
  63018. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63019. /** @hidden */
  63020. _onPointerEnter(target: Control3D): boolean;
  63021. /** @hidden */
  63022. _onPointerOut(target: Control3D): void;
  63023. /** @hidden */
  63024. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63025. /** @hidden */
  63026. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63027. /** @hidden */
  63028. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63029. /** @hidden */
  63030. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63031. /** @hidden */
  63032. _disposeNode(): void;
  63033. /**
  63034. * Releases all associated resources
  63035. */
  63036. dispose(): void;
  63037. }
  63038. }
  63039. declare module BABYLON.GUI {
  63040. /**
  63041. * Class used as a root to all buttons
  63042. */
  63043. export class AbstractButton3D extends Control3D {
  63044. /**
  63045. * Creates a new button
  63046. * @param name defines the control name
  63047. */
  63048. constructor(name?: string);
  63049. protected _getTypeName(): string;
  63050. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63051. }
  63052. }
  63053. declare module BABYLON.GUI {
  63054. /**
  63055. * Class used to create a button in 3D
  63056. */
  63057. export class Button3D extends AbstractButton3D {
  63058. /** @hidden */
  63059. protected _currentMaterial: BABYLON.Material;
  63060. private _facadeTexture;
  63061. private _content;
  63062. private _contentResolution;
  63063. private _contentScaleRatio;
  63064. /**
  63065. * Gets or sets the texture resolution used to render content (512 by default)
  63066. */
  63067. contentResolution: BABYLON.int;
  63068. /**
  63069. * Gets or sets the texture scale ratio used to render content (2 by default)
  63070. */
  63071. contentScaleRatio: number;
  63072. protected _disposeFacadeTexture(): void;
  63073. protected _resetContent(): void;
  63074. /**
  63075. * Creates a new button
  63076. * @param name defines the control name
  63077. */
  63078. constructor(name?: string);
  63079. /**
  63080. * Gets or sets the GUI 2D content used to display the button's facade
  63081. */
  63082. content: Control;
  63083. /**
  63084. * Apply the facade texture (created from the content property).
  63085. * This function can be overloaded by child classes
  63086. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63087. */
  63088. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63089. protected _getTypeName(): string;
  63090. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63091. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63092. /**
  63093. * Releases all associated resources
  63094. */
  63095. dispose(): void;
  63096. }
  63097. }
  63098. declare module BABYLON.GUI {
  63099. /**
  63100. * Abstract class used to create a container panel deployed on the surface of a volume
  63101. */
  63102. export abstract class VolumeBasedPanel extends Container3D {
  63103. private _columns;
  63104. private _rows;
  63105. private _rowThenColum;
  63106. private _orientation;
  63107. protected _cellWidth: number;
  63108. protected _cellHeight: number;
  63109. /**
  63110. * Gets or sets the distance between elements
  63111. */
  63112. margin: number;
  63113. /**
  63114. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63115. * | Value | Type | Description |
  63116. * | ----- | ----------------------------------- | ----------- |
  63117. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63118. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63119. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63120. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63121. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63122. */
  63123. orientation: number;
  63124. /**
  63125. * Gets or sets the number of columns requested (10 by default).
  63126. * The panel will automatically compute the number of rows based on number of child controls.
  63127. */
  63128. columns: BABYLON.int;
  63129. /**
  63130. * Gets or sets a the number of rows requested.
  63131. * The panel will automatically compute the number of columns based on number of child controls.
  63132. */
  63133. rows: BABYLON.int;
  63134. /**
  63135. * Creates new VolumeBasedPanel
  63136. */
  63137. constructor();
  63138. protected _arrangeChildren(): void;
  63139. /** Child classes must implement this function to provide correct control positioning */
  63140. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63141. /** Child classes can implement this function to provide additional processing */
  63142. protected _finalProcessing(): void;
  63143. }
  63144. }
  63145. declare module BABYLON.GUI {
  63146. /**
  63147. * Class used to create a container panel deployed on the surface of a cylinder
  63148. */
  63149. export class CylinderPanel extends VolumeBasedPanel {
  63150. private _radius;
  63151. /**
  63152. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63153. */
  63154. radius: BABYLON.float;
  63155. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63156. private _cylindricalMapping;
  63157. }
  63158. }
  63159. declare module BABYLON.GUI {
  63160. /** @hidden */
  63161. export var fluentVertexShader: {
  63162. name: string;
  63163. shader: string;
  63164. };
  63165. }
  63166. declare module BABYLON.GUI {
  63167. /** @hidden */
  63168. export var fluentPixelShader: {
  63169. name: string;
  63170. shader: string;
  63171. };
  63172. }
  63173. declare module BABYLON.GUI {
  63174. /** @hidden */
  63175. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63176. INNERGLOW: boolean;
  63177. BORDER: boolean;
  63178. HOVERLIGHT: boolean;
  63179. TEXTURE: boolean;
  63180. constructor();
  63181. }
  63182. /**
  63183. * Class used to render controls with fluent desgin
  63184. */
  63185. export class FluentMaterial extends BABYLON.PushMaterial {
  63186. /**
  63187. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63188. */
  63189. innerGlowColorIntensity: number;
  63190. /**
  63191. * Gets or sets the inner glow color (white by default)
  63192. */
  63193. innerGlowColor: BABYLON.Color3;
  63194. /**
  63195. * Gets or sets alpha value (default is 1.0)
  63196. */
  63197. alpha: number;
  63198. /**
  63199. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63200. */
  63201. albedoColor: BABYLON.Color3;
  63202. /**
  63203. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63204. */
  63205. renderBorders: boolean;
  63206. /**
  63207. * Gets or sets border width (default is 0.5)
  63208. */
  63209. borderWidth: number;
  63210. /**
  63211. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63212. */
  63213. edgeSmoothingValue: number;
  63214. /**
  63215. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63216. */
  63217. borderMinValue: number;
  63218. /**
  63219. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63220. */
  63221. renderHoverLight: boolean;
  63222. /**
  63223. * Gets or sets the radius used to render the hover light (default is 1.0)
  63224. */
  63225. hoverRadius: number;
  63226. /**
  63227. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63228. */
  63229. hoverColor: BABYLON.Color4;
  63230. /**
  63231. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63232. */
  63233. hoverPosition: BABYLON.Vector3;
  63234. private _albedoTexture;
  63235. /** Gets or sets the texture to use for albedo color */
  63236. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63237. /**
  63238. * Creates a new Fluent material
  63239. * @param name defines the name of the material
  63240. * @param scene defines the hosting scene
  63241. */
  63242. constructor(name: string, scene: BABYLON.Scene);
  63243. needAlphaBlending(): boolean;
  63244. needAlphaTesting(): boolean;
  63245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63248. getActiveTextures(): BABYLON.BaseTexture[];
  63249. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63250. dispose(forceDisposeEffect?: boolean): void;
  63251. clone(name: string): FluentMaterial;
  63252. serialize(): any;
  63253. getClassName(): string;
  63254. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63255. }
  63256. }
  63257. declare module BABYLON.GUI {
  63258. /**
  63259. * Class used to create a holographic button in 3D
  63260. */
  63261. export class HolographicButton extends Button3D {
  63262. private _backPlate;
  63263. private _textPlate;
  63264. private _frontPlate;
  63265. private _text;
  63266. private _imageUrl;
  63267. private _shareMaterials;
  63268. private _frontMaterial;
  63269. private _backMaterial;
  63270. private _plateMaterial;
  63271. private _pickedPointObserver;
  63272. private _tooltipFade;
  63273. private _tooltipTextBlock;
  63274. private _tooltipTexture;
  63275. private _tooltipMesh;
  63276. private _tooltipHoverObserver;
  63277. private _tooltipOutObserver;
  63278. private _disposeTooltip;
  63279. /**
  63280. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63281. */
  63282. tooltipText: BABYLON.Nullable<string>;
  63283. /**
  63284. * Gets or sets text for the button
  63285. */
  63286. text: string;
  63287. /**
  63288. * Gets or sets the image url for the button
  63289. */
  63290. imageUrl: string;
  63291. /**
  63292. * Gets the back material used by this button
  63293. */
  63294. readonly backMaterial: FluentMaterial;
  63295. /**
  63296. * Gets the front material used by this button
  63297. */
  63298. readonly frontMaterial: FluentMaterial;
  63299. /**
  63300. * Gets the plate material used by this button
  63301. */
  63302. readonly plateMaterial: BABYLON.StandardMaterial;
  63303. /**
  63304. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63305. */
  63306. readonly shareMaterials: boolean;
  63307. /**
  63308. * Creates a new button
  63309. * @param name defines the control name
  63310. */
  63311. constructor(name?: string, shareMaterials?: boolean);
  63312. protected _getTypeName(): string;
  63313. private _rebuildContent;
  63314. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63315. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63316. private _createBackMaterial;
  63317. private _createFrontMaterial;
  63318. private _createPlateMaterial;
  63319. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63320. /**
  63321. * Releases all associated resources
  63322. */
  63323. dispose(): void;
  63324. }
  63325. }
  63326. declare module BABYLON.GUI {
  63327. /**
  63328. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63329. */
  63330. export class MeshButton3D extends Button3D {
  63331. /** @hidden */
  63332. protected _currentMesh: BABYLON.Mesh;
  63333. /**
  63334. * Creates a new 3D button based on a mesh
  63335. * @param mesh mesh to become a 3D button
  63336. * @param name defines the control name
  63337. */
  63338. constructor(mesh: BABYLON.Mesh, name?: string);
  63339. protected _getTypeName(): string;
  63340. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63341. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63342. }
  63343. }
  63344. declare module BABYLON.GUI {
  63345. /**
  63346. * Class used to create a container panel deployed on the surface of a plane
  63347. */
  63348. export class PlanePanel extends VolumeBasedPanel {
  63349. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63350. }
  63351. }
  63352. declare module BABYLON.GUI {
  63353. /**
  63354. * Class used to create a container panel where items get randomized planar mapping
  63355. */
  63356. export class ScatterPanel extends VolumeBasedPanel {
  63357. private _iteration;
  63358. /**
  63359. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63360. */
  63361. iteration: BABYLON.float;
  63362. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63363. private _scatterMapping;
  63364. protected _finalProcessing(): void;
  63365. }
  63366. }
  63367. declare module BABYLON.GUI {
  63368. /**
  63369. * Class used to create a container panel deployed on the surface of a sphere
  63370. */
  63371. export class SpherePanel extends VolumeBasedPanel {
  63372. private _radius;
  63373. /**
  63374. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63375. */
  63376. radius: BABYLON.float;
  63377. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63378. private _sphericalMapping;
  63379. }
  63380. }
  63381. declare module BABYLON.GUI {
  63382. /**
  63383. * Class used to create a stack panel in 3D on XY plane
  63384. */
  63385. export class StackPanel3D extends Container3D {
  63386. private _isVertical;
  63387. /**
  63388. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63389. */
  63390. isVertical: boolean;
  63391. /**
  63392. * Gets or sets the distance between elements
  63393. */
  63394. margin: number;
  63395. /**
  63396. * Creates new StackPanel
  63397. * @param isVertical
  63398. */
  63399. constructor(isVertical?: boolean);
  63400. protected _arrangeChildren(): void;
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. /**
  63405. * Mode that determines the coordinate system to use.
  63406. */
  63407. export enum GLTFLoaderCoordinateSystemMode {
  63408. /**
  63409. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63410. */
  63411. AUTO = 0,
  63412. /**
  63413. * Sets the useRightHandedSystem flag on the scene.
  63414. */
  63415. FORCE_RIGHT_HANDED = 1
  63416. }
  63417. /**
  63418. * Mode that determines what animations will start.
  63419. */
  63420. export enum GLTFLoaderAnimationStartMode {
  63421. /**
  63422. * No animation will start.
  63423. */
  63424. NONE = 0,
  63425. /**
  63426. * The first animation will start.
  63427. */
  63428. FIRST = 1,
  63429. /**
  63430. * All animations will start.
  63431. */
  63432. ALL = 2
  63433. }
  63434. /**
  63435. * Interface that contains the data for the glTF asset.
  63436. */
  63437. export interface IGLTFLoaderData {
  63438. /**
  63439. * Object that represents the glTF JSON.
  63440. */
  63441. json: Object;
  63442. /**
  63443. * The BIN chunk of a binary glTF.
  63444. */
  63445. bin: Nullable<ArrayBufferView>;
  63446. }
  63447. /**
  63448. * Interface for extending the loader.
  63449. */
  63450. export interface IGLTFLoaderExtension {
  63451. /**
  63452. * The name of this extension.
  63453. */
  63454. readonly name: string;
  63455. /**
  63456. * Defines whether this extension is enabled.
  63457. */
  63458. enabled: boolean;
  63459. }
  63460. /**
  63461. * Loader state.
  63462. */
  63463. export enum GLTFLoaderState {
  63464. /**
  63465. * The asset is loading.
  63466. */
  63467. LOADING = 0,
  63468. /**
  63469. * The asset is ready for rendering.
  63470. */
  63471. READY = 1,
  63472. /**
  63473. * The asset is completely loaded.
  63474. */
  63475. COMPLETE = 2
  63476. }
  63477. /** @hidden */
  63478. export interface IGLTFLoader extends IDisposable {
  63479. readonly state: Nullable<GLTFLoaderState>;
  63480. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63481. meshes: AbstractMesh[];
  63482. particleSystems: IParticleSystem[];
  63483. skeletons: Skeleton[];
  63484. animationGroups: AnimationGroup[];
  63485. }>;
  63486. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63487. }
  63488. /**
  63489. * File loader for loading glTF files into a scene.
  63490. */
  63491. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63492. /** @hidden */
  63493. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63494. /** @hidden */
  63495. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63496. /**
  63497. * Raised when the asset has been parsed
  63498. */
  63499. onParsedObservable: Observable<IGLTFLoaderData>;
  63500. private _onParsedObserver;
  63501. /**
  63502. * Raised when the asset has been parsed
  63503. */
  63504. onParsed: (loaderData: IGLTFLoaderData) => void;
  63505. /**
  63506. * 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.
  63507. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63508. * Defaults to true.
  63509. * @hidden
  63510. */
  63511. static IncrementalLoading: boolean;
  63512. /**
  63513. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63514. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63515. * @hidden
  63516. */
  63517. static HomogeneousCoordinates: boolean;
  63518. /**
  63519. * The coordinate system mode. Defaults to AUTO.
  63520. */
  63521. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63522. /**
  63523. * The animation start mode. Defaults to FIRST.
  63524. */
  63525. animationStartMode: GLTFLoaderAnimationStartMode;
  63526. /**
  63527. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63528. */
  63529. compileMaterials: boolean;
  63530. /**
  63531. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63532. */
  63533. useClipPlane: boolean;
  63534. /**
  63535. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63536. */
  63537. compileShadowGenerators: boolean;
  63538. /**
  63539. * Defines if the Alpha blended materials are only applied as coverage.
  63540. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63541. * If true, no extra effects are applied to transparent pixels.
  63542. */
  63543. transparencyAsCoverage: boolean;
  63544. /**
  63545. * Function called before loading a url referenced by the asset.
  63546. */
  63547. preprocessUrlAsync: (url: string) => Promise<string>;
  63548. /**
  63549. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63550. */
  63551. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63552. private _onMeshLoadedObserver;
  63553. /**
  63554. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63555. */
  63556. onMeshLoaded: (mesh: AbstractMesh) => void;
  63557. /**
  63558. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63559. */
  63560. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63561. private _onTextureLoadedObserver;
  63562. /**
  63563. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63564. */
  63565. onTextureLoaded: (texture: BaseTexture) => void;
  63566. /**
  63567. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63568. */
  63569. readonly onMaterialLoadedObservable: Observable<Material>;
  63570. private _onMaterialLoadedObserver;
  63571. /**
  63572. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63573. */
  63574. onMaterialLoaded: (material: Material) => void;
  63575. /**
  63576. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63577. */
  63578. readonly onCameraLoadedObservable: Observable<Camera>;
  63579. private _onCameraLoadedObserver;
  63580. /**
  63581. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63582. */
  63583. onCameraLoaded: (camera: Camera) => void;
  63584. /**
  63585. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63586. * For assets with LODs, raised when all of the LODs are complete.
  63587. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63588. */
  63589. readonly onCompleteObservable: Observable<void>;
  63590. private _onCompleteObserver;
  63591. /**
  63592. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63593. * For assets with LODs, raised when all of the LODs are complete.
  63594. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63595. */
  63596. onComplete: () => void;
  63597. /**
  63598. * Observable raised when an error occurs.
  63599. */
  63600. readonly onErrorObservable: Observable<any>;
  63601. private _onErrorObserver;
  63602. /**
  63603. * Callback raised when an error occurs.
  63604. */
  63605. onError: (reason: any) => void;
  63606. /**
  63607. * Observable raised after the loader is disposed.
  63608. */
  63609. readonly onDisposeObservable: Observable<void>;
  63610. private _onDisposeObserver;
  63611. /**
  63612. * Callback raised after the loader is disposed.
  63613. */
  63614. onDispose: () => void;
  63615. /**
  63616. * Observable raised after a loader extension is created.
  63617. * Set additional options for a loader extension in this event.
  63618. */
  63619. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63620. private _onExtensionLoadedObserver;
  63621. /**
  63622. * Callback raised after a loader extension is created.
  63623. */
  63624. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63625. /**
  63626. * Defines if the loader logging is enabled.
  63627. */
  63628. loggingEnabled: boolean;
  63629. /**
  63630. * Defines if the loader should capture performance counters.
  63631. */
  63632. capturePerformanceCounters: boolean;
  63633. /**
  63634. * Defines if the loader should validate the asset.
  63635. */
  63636. validate: boolean;
  63637. /**
  63638. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63639. */
  63640. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63641. private _onValidatedObserver;
  63642. /**
  63643. * Callback raised after a loader extension is created.
  63644. */
  63645. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63646. private _loader;
  63647. /**
  63648. * Name of the loader ("gltf")
  63649. */
  63650. name: string;
  63651. /**
  63652. * Supported file extensions of the loader (.gltf, .glb)
  63653. */
  63654. extensions: ISceneLoaderPluginExtensions;
  63655. /**
  63656. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63657. */
  63658. dispose(): void;
  63659. /** @hidden */
  63660. _clear(): void;
  63661. /**
  63662. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63663. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63664. * @param scene the scene the meshes should be added to
  63665. * @param data the glTF data to load
  63666. * @param rootUrl root url to load from
  63667. * @param onProgress event that fires when loading progress has occured
  63668. * @param fileName Defines the name of the file to load
  63669. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63670. */
  63671. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63672. meshes: AbstractMesh[];
  63673. particleSystems: IParticleSystem[];
  63674. skeletons: Skeleton[];
  63675. animationGroups: AnimationGroup[];
  63676. }>;
  63677. /**
  63678. * Imports all objects from the loaded glTF data and adds them to the scene
  63679. * @param scene the scene the objects should be added to
  63680. * @param data the glTF data to load
  63681. * @param rootUrl root url to load from
  63682. * @param onProgress event that fires when loading progress has occured
  63683. * @param fileName Defines the name of the file to load
  63684. * @returns a promise which completes when objects have been loaded to the scene
  63685. */
  63686. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63687. /**
  63688. * Load into an asset container.
  63689. * @param scene The scene to load into
  63690. * @param data The data to import
  63691. * @param rootUrl The root url for scene and resources
  63692. * @param onProgress The callback when the load progresses
  63693. * @param fileName Defines the name of the file to load
  63694. * @returns The loaded asset container
  63695. */
  63696. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63697. /**
  63698. * If the data string can be loaded directly.
  63699. * @param data string contianing the file data
  63700. * @returns if the data can be loaded directly
  63701. */
  63702. canDirectLoad(data: string): boolean;
  63703. /**
  63704. * Rewrites a url by combining a root url and response url.
  63705. */
  63706. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63707. /**
  63708. * Instantiates a glTF file loader plugin.
  63709. * @returns the created plugin
  63710. */
  63711. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63712. /**
  63713. * The loader state or null if the loader is not active.
  63714. */
  63715. readonly loaderState: Nullable<GLTFLoaderState>;
  63716. /**
  63717. * Returns a promise that resolves when the asset is completely loaded.
  63718. * @returns a promise that resolves when the asset is completely loaded.
  63719. */
  63720. whenCompleteAsync(): Promise<void>;
  63721. private _parseAsync;
  63722. private _validateAsync;
  63723. private _getLoader;
  63724. private _unpackBinary;
  63725. private _unpackBinaryV1;
  63726. private _unpackBinaryV2;
  63727. private static _parseVersion;
  63728. private static _compareVersion;
  63729. private static _decodeBufferToText;
  63730. private static readonly _logSpaces;
  63731. private _logIndentLevel;
  63732. private _loggingEnabled;
  63733. /** @hidden */
  63734. _log: (message: string) => void;
  63735. /** @hidden */
  63736. _logOpen(message: string): void;
  63737. /** @hidden */
  63738. _logClose(): void;
  63739. private _logEnabled;
  63740. private _logDisabled;
  63741. private _capturePerformanceCounters;
  63742. /** @hidden */
  63743. _startPerformanceCounter: (counterName: string) => void;
  63744. /** @hidden */
  63745. _endPerformanceCounter: (counterName: string) => void;
  63746. private _startPerformanceCounterEnabled;
  63747. private _startPerformanceCounterDisabled;
  63748. private _endPerformanceCounterEnabled;
  63749. private _endPerformanceCounterDisabled;
  63750. }
  63751. }
  63752. declare module BABYLON.GLTF1 {
  63753. /**
  63754. * Enums
  63755. * @hidden
  63756. */
  63757. export enum EComponentType {
  63758. BYTE = 5120,
  63759. UNSIGNED_BYTE = 5121,
  63760. SHORT = 5122,
  63761. UNSIGNED_SHORT = 5123,
  63762. FLOAT = 5126
  63763. }
  63764. /** @hidden */
  63765. export enum EShaderType {
  63766. FRAGMENT = 35632,
  63767. VERTEX = 35633
  63768. }
  63769. /** @hidden */
  63770. export enum EParameterType {
  63771. BYTE = 5120,
  63772. UNSIGNED_BYTE = 5121,
  63773. SHORT = 5122,
  63774. UNSIGNED_SHORT = 5123,
  63775. INT = 5124,
  63776. UNSIGNED_INT = 5125,
  63777. FLOAT = 5126,
  63778. FLOAT_VEC2 = 35664,
  63779. FLOAT_VEC3 = 35665,
  63780. FLOAT_VEC4 = 35666,
  63781. INT_VEC2 = 35667,
  63782. INT_VEC3 = 35668,
  63783. INT_VEC4 = 35669,
  63784. BOOL = 35670,
  63785. BOOL_VEC2 = 35671,
  63786. BOOL_VEC3 = 35672,
  63787. BOOL_VEC4 = 35673,
  63788. FLOAT_MAT2 = 35674,
  63789. FLOAT_MAT3 = 35675,
  63790. FLOAT_MAT4 = 35676,
  63791. SAMPLER_2D = 35678
  63792. }
  63793. /** @hidden */
  63794. export enum ETextureWrapMode {
  63795. CLAMP_TO_EDGE = 33071,
  63796. MIRRORED_REPEAT = 33648,
  63797. REPEAT = 10497
  63798. }
  63799. /** @hidden */
  63800. export enum ETextureFilterType {
  63801. NEAREST = 9728,
  63802. LINEAR = 9728,
  63803. NEAREST_MIPMAP_NEAREST = 9984,
  63804. LINEAR_MIPMAP_NEAREST = 9985,
  63805. NEAREST_MIPMAP_LINEAR = 9986,
  63806. LINEAR_MIPMAP_LINEAR = 9987
  63807. }
  63808. /** @hidden */
  63809. export enum ETextureFormat {
  63810. ALPHA = 6406,
  63811. RGB = 6407,
  63812. RGBA = 6408,
  63813. LUMINANCE = 6409,
  63814. LUMINANCE_ALPHA = 6410
  63815. }
  63816. /** @hidden */
  63817. export enum ECullingType {
  63818. FRONT = 1028,
  63819. BACK = 1029,
  63820. FRONT_AND_BACK = 1032
  63821. }
  63822. /** @hidden */
  63823. export enum EBlendingFunction {
  63824. ZERO = 0,
  63825. ONE = 1,
  63826. SRC_COLOR = 768,
  63827. ONE_MINUS_SRC_COLOR = 769,
  63828. DST_COLOR = 774,
  63829. ONE_MINUS_DST_COLOR = 775,
  63830. SRC_ALPHA = 770,
  63831. ONE_MINUS_SRC_ALPHA = 771,
  63832. DST_ALPHA = 772,
  63833. ONE_MINUS_DST_ALPHA = 773,
  63834. CONSTANT_COLOR = 32769,
  63835. ONE_MINUS_CONSTANT_COLOR = 32770,
  63836. CONSTANT_ALPHA = 32771,
  63837. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63838. SRC_ALPHA_SATURATE = 776
  63839. }
  63840. /** @hidden */
  63841. export interface IGLTFProperty {
  63842. extensions?: {
  63843. [key: string]: any;
  63844. };
  63845. extras?: Object;
  63846. }
  63847. /** @hidden */
  63848. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63849. name?: string;
  63850. }
  63851. /** @hidden */
  63852. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63853. bufferView: string;
  63854. byteOffset: number;
  63855. byteStride: number;
  63856. count: number;
  63857. type: string;
  63858. componentType: EComponentType;
  63859. max?: number[];
  63860. min?: number[];
  63861. name?: string;
  63862. }
  63863. /** @hidden */
  63864. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63865. buffer: string;
  63866. byteOffset: number;
  63867. byteLength: number;
  63868. byteStride: number;
  63869. target?: number;
  63870. }
  63871. /** @hidden */
  63872. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63873. uri: string;
  63874. byteLength?: number;
  63875. type?: string;
  63876. }
  63877. /** @hidden */
  63878. export interface IGLTFShader extends IGLTFChildRootProperty {
  63879. uri: string;
  63880. type: EShaderType;
  63881. }
  63882. /** @hidden */
  63883. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63884. attributes: string[];
  63885. fragmentShader: string;
  63886. vertexShader: string;
  63887. }
  63888. /** @hidden */
  63889. export interface IGLTFTechniqueParameter {
  63890. type: number;
  63891. count?: number;
  63892. semantic?: string;
  63893. node?: string;
  63894. value?: number | boolean | string | Array<any>;
  63895. source?: string;
  63896. babylonValue?: any;
  63897. }
  63898. /** @hidden */
  63899. export interface IGLTFTechniqueCommonProfile {
  63900. lightingModel: string;
  63901. texcoordBindings: Object;
  63902. parameters?: Array<any>;
  63903. }
  63904. /** @hidden */
  63905. export interface IGLTFTechniqueStatesFunctions {
  63906. blendColor?: number[];
  63907. blendEquationSeparate?: number[];
  63908. blendFuncSeparate?: number[];
  63909. colorMask: boolean[];
  63910. cullFace: number[];
  63911. }
  63912. /** @hidden */
  63913. export interface IGLTFTechniqueStates {
  63914. enable: number[];
  63915. functions: IGLTFTechniqueStatesFunctions;
  63916. }
  63917. /** @hidden */
  63918. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63919. parameters: {
  63920. [key: string]: IGLTFTechniqueParameter;
  63921. };
  63922. program: string;
  63923. attributes: {
  63924. [key: string]: string;
  63925. };
  63926. uniforms: {
  63927. [key: string]: string;
  63928. };
  63929. states: IGLTFTechniqueStates;
  63930. }
  63931. /** @hidden */
  63932. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63933. technique?: string;
  63934. values: string[];
  63935. }
  63936. /** @hidden */
  63937. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63938. attributes: {
  63939. [key: string]: string;
  63940. };
  63941. indices: string;
  63942. material: string;
  63943. mode?: number;
  63944. }
  63945. /** @hidden */
  63946. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63947. primitives: IGLTFMeshPrimitive[];
  63948. }
  63949. /** @hidden */
  63950. export interface IGLTFImage extends IGLTFChildRootProperty {
  63951. uri: string;
  63952. }
  63953. /** @hidden */
  63954. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63955. magFilter?: number;
  63956. minFilter?: number;
  63957. wrapS?: number;
  63958. wrapT?: number;
  63959. }
  63960. /** @hidden */
  63961. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63962. sampler: string;
  63963. source: string;
  63964. format?: ETextureFormat;
  63965. internalFormat?: ETextureFormat;
  63966. target?: number;
  63967. type?: number;
  63968. babylonTexture?: Texture;
  63969. }
  63970. /** @hidden */
  63971. export interface IGLTFAmbienLight {
  63972. color?: number[];
  63973. }
  63974. /** @hidden */
  63975. export interface IGLTFDirectionalLight {
  63976. color?: number[];
  63977. }
  63978. /** @hidden */
  63979. export interface IGLTFPointLight {
  63980. color?: number[];
  63981. constantAttenuation?: number;
  63982. linearAttenuation?: number;
  63983. quadraticAttenuation?: number;
  63984. }
  63985. /** @hidden */
  63986. export interface IGLTFSpotLight {
  63987. color?: number[];
  63988. constantAttenuation?: number;
  63989. fallOfAngle?: number;
  63990. fallOffExponent?: number;
  63991. linearAttenuation?: number;
  63992. quadraticAttenuation?: number;
  63993. }
  63994. /** @hidden */
  63995. export interface IGLTFLight extends IGLTFChildRootProperty {
  63996. type: string;
  63997. }
  63998. /** @hidden */
  63999. export interface IGLTFCameraOrthographic {
  64000. xmag: number;
  64001. ymag: number;
  64002. zfar: number;
  64003. znear: number;
  64004. }
  64005. /** @hidden */
  64006. export interface IGLTFCameraPerspective {
  64007. aspectRatio: number;
  64008. yfov: number;
  64009. zfar: number;
  64010. znear: number;
  64011. }
  64012. /** @hidden */
  64013. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64014. type: string;
  64015. }
  64016. /** @hidden */
  64017. export interface IGLTFAnimationChannelTarget {
  64018. id: string;
  64019. path: string;
  64020. }
  64021. /** @hidden */
  64022. export interface IGLTFAnimationChannel {
  64023. sampler: string;
  64024. target: IGLTFAnimationChannelTarget;
  64025. }
  64026. /** @hidden */
  64027. export interface IGLTFAnimationSampler {
  64028. input: string;
  64029. output: string;
  64030. interpolation?: string;
  64031. }
  64032. /** @hidden */
  64033. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64034. channels?: IGLTFAnimationChannel[];
  64035. parameters?: {
  64036. [key: string]: string;
  64037. };
  64038. samplers?: {
  64039. [key: string]: IGLTFAnimationSampler;
  64040. };
  64041. }
  64042. /** @hidden */
  64043. export interface IGLTFNodeInstanceSkin {
  64044. skeletons: string[];
  64045. skin: string;
  64046. meshes: string[];
  64047. }
  64048. /** @hidden */
  64049. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64050. bindShapeMatrix: number[];
  64051. inverseBindMatrices: string;
  64052. jointNames: string[];
  64053. babylonSkeleton?: Skeleton;
  64054. }
  64055. /** @hidden */
  64056. export interface IGLTFNode extends IGLTFChildRootProperty {
  64057. camera?: string;
  64058. children: string[];
  64059. skin?: string;
  64060. jointName?: string;
  64061. light?: string;
  64062. matrix: number[];
  64063. mesh?: string;
  64064. meshes?: string[];
  64065. rotation?: number[];
  64066. scale?: number[];
  64067. translation?: number[];
  64068. babylonNode?: Node;
  64069. }
  64070. /** @hidden */
  64071. export interface IGLTFScene extends IGLTFChildRootProperty {
  64072. nodes: string[];
  64073. }
  64074. /** @hidden */
  64075. export interface IGLTFRuntime {
  64076. extensions: {
  64077. [key: string]: any;
  64078. };
  64079. accessors: {
  64080. [key: string]: IGLTFAccessor;
  64081. };
  64082. buffers: {
  64083. [key: string]: IGLTFBuffer;
  64084. };
  64085. bufferViews: {
  64086. [key: string]: IGLTFBufferView;
  64087. };
  64088. meshes: {
  64089. [key: string]: IGLTFMesh;
  64090. };
  64091. lights: {
  64092. [key: string]: IGLTFLight;
  64093. };
  64094. cameras: {
  64095. [key: string]: IGLTFCamera;
  64096. };
  64097. nodes: {
  64098. [key: string]: IGLTFNode;
  64099. };
  64100. images: {
  64101. [key: string]: IGLTFImage;
  64102. };
  64103. textures: {
  64104. [key: string]: IGLTFTexture;
  64105. };
  64106. shaders: {
  64107. [key: string]: IGLTFShader;
  64108. };
  64109. programs: {
  64110. [key: string]: IGLTFProgram;
  64111. };
  64112. samplers: {
  64113. [key: string]: IGLTFSampler;
  64114. };
  64115. techniques: {
  64116. [key: string]: IGLTFTechnique;
  64117. };
  64118. materials: {
  64119. [key: string]: IGLTFMaterial;
  64120. };
  64121. animations: {
  64122. [key: string]: IGLTFAnimation;
  64123. };
  64124. skins: {
  64125. [key: string]: IGLTFSkins;
  64126. };
  64127. currentScene?: Object;
  64128. scenes: {
  64129. [key: string]: IGLTFScene;
  64130. };
  64131. extensionsUsed: string[];
  64132. extensionsRequired?: string[];
  64133. buffersCount: number;
  64134. shaderscount: number;
  64135. scene: Scene;
  64136. rootUrl: string;
  64137. loadedBufferCount: number;
  64138. loadedBufferViews: {
  64139. [name: string]: ArrayBufferView;
  64140. };
  64141. loadedShaderCount: number;
  64142. importOnlyMeshes: boolean;
  64143. importMeshesNames?: string[];
  64144. dummyNodes: Node[];
  64145. }
  64146. /** @hidden */
  64147. export interface INodeToRoot {
  64148. bone: Bone;
  64149. node: IGLTFNode;
  64150. id: string;
  64151. }
  64152. /** @hidden */
  64153. export interface IJointNode {
  64154. node: IGLTFNode;
  64155. id: string;
  64156. }
  64157. }
  64158. declare module BABYLON.GLTF1 {
  64159. /**
  64160. * Utils functions for GLTF
  64161. * @hidden
  64162. */
  64163. export class GLTFUtils {
  64164. /**
  64165. * Sets the given "parameter" matrix
  64166. * @param scene: the Scene object
  64167. * @param source: the source node where to pick the matrix
  64168. * @param parameter: the GLTF technique parameter
  64169. * @param uniformName: the name of the shader's uniform
  64170. * @param shaderMaterial: the shader material
  64171. */
  64172. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64173. /**
  64174. * Sets the given "parameter" matrix
  64175. * @param shaderMaterial: the shader material
  64176. * @param uniform: the name of the shader's uniform
  64177. * @param value: the value of the uniform
  64178. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64179. */
  64180. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64181. /**
  64182. * Returns the wrap mode of the texture
  64183. * @param mode: the mode value
  64184. */
  64185. static GetWrapMode(mode: number): number;
  64186. /**
  64187. * Returns the byte stride giving an accessor
  64188. * @param accessor: the GLTF accessor objet
  64189. */
  64190. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64191. /**
  64192. * Returns the texture filter mode giving a mode value
  64193. * @param mode: the filter mode value
  64194. */
  64195. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64196. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64197. /**
  64198. * Returns a buffer from its accessor
  64199. * @param gltfRuntime: the GLTF runtime
  64200. * @param accessor: the GLTF accessor
  64201. */
  64202. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64203. /**
  64204. * Decodes a buffer view into a string
  64205. * @param view: the buffer view
  64206. */
  64207. static DecodeBufferToText(view: ArrayBufferView): string;
  64208. /**
  64209. * Returns the default material of gltf. Related to
  64210. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64211. * @param scene: the Babylon.js scene
  64212. */
  64213. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64214. private static _DefaultMaterial;
  64215. }
  64216. }
  64217. declare module BABYLON.GLTF1 {
  64218. /**
  64219. * Implementation of the base glTF spec
  64220. * @hidden
  64221. */
  64222. export class GLTFLoaderBase {
  64223. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64224. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64225. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64226. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64227. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64228. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64229. }
  64230. /**
  64231. * glTF V1 Loader
  64232. * @hidden
  64233. */
  64234. export class GLTFLoader implements IGLTFLoader {
  64235. static Extensions: {
  64236. [name: string]: GLTFLoaderExtension;
  64237. };
  64238. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64239. state: Nullable<GLTFLoaderState>;
  64240. dispose(): void;
  64241. private _importMeshAsync;
  64242. /**
  64243. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64244. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64245. * @param scene the scene the meshes should be added to
  64246. * @param data gltf data containing information of the meshes in a loaded file
  64247. * @param rootUrl root url to load from
  64248. * @param onProgress event that fires when loading progress has occured
  64249. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64250. */
  64251. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64252. meshes: AbstractMesh[];
  64253. particleSystems: IParticleSystem[];
  64254. skeletons: Skeleton[];
  64255. animationGroups: AnimationGroup[];
  64256. }>;
  64257. private _loadAsync;
  64258. /**
  64259. * Imports all objects from a loaded gltf file and adds them to the scene
  64260. * @param scene the scene the objects should be added to
  64261. * @param data gltf data containing information of the meshes in a loaded file
  64262. * @param rootUrl root url to load from
  64263. * @param onProgress event that fires when loading progress has occured
  64264. * @returns a promise which completes when objects have been loaded to the scene
  64265. */
  64266. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64267. private _loadShadersAsync;
  64268. private _loadBuffersAsync;
  64269. private _createNodes;
  64270. }
  64271. /** @hidden */
  64272. export abstract class GLTFLoaderExtension {
  64273. private _name;
  64274. constructor(name: string);
  64275. readonly name: string;
  64276. /**
  64277. * Defines an override for loading the runtime
  64278. * Return true to stop further extensions from loading the runtime
  64279. */
  64280. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64281. /**
  64282. * Defines an onverride for creating gltf runtime
  64283. * Return true to stop further extensions from creating the runtime
  64284. */
  64285. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64286. /**
  64287. * Defines an override for loading buffers
  64288. * Return true to stop further extensions from loading this buffer
  64289. */
  64290. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64291. /**
  64292. * Defines an override for loading texture buffers
  64293. * Return true to stop further extensions from loading this texture data
  64294. */
  64295. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64296. /**
  64297. * Defines an override for creating textures
  64298. * Return true to stop further extensions from loading this texture
  64299. */
  64300. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64301. /**
  64302. * Defines an override for loading shader strings
  64303. * Return true to stop further extensions from loading this shader data
  64304. */
  64305. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64306. /**
  64307. * Defines an override for loading materials
  64308. * Return true to stop further extensions from loading this material
  64309. */
  64310. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64311. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64312. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64313. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64314. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64315. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64316. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64317. private static LoadTextureBufferAsync;
  64318. private static CreateTextureAsync;
  64319. private static ApplyExtensions;
  64320. }
  64321. }
  64322. declare module BABYLON.GLTF1 {
  64323. /** @hidden */
  64324. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64325. private _bin;
  64326. constructor();
  64327. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64328. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64329. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64330. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64331. }
  64332. }
  64333. declare module BABYLON.GLTF1 {
  64334. /** @hidden */
  64335. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64336. constructor();
  64337. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64338. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64339. private _loadTexture;
  64340. }
  64341. }
  64342. declare module BABYLON.GLTF2.Loader {
  64343. /**
  64344. * Loader interface with an index field.
  64345. */
  64346. export interface IArrayItem {
  64347. /**
  64348. * The index of this item in the array.
  64349. */
  64350. index: number;
  64351. }
  64352. /**
  64353. * Loader interface with additional members.
  64354. */
  64355. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64356. /** @hidden */
  64357. _data?: Promise<ArrayBufferView>;
  64358. /** @hidden */
  64359. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64360. }
  64361. /**
  64362. * Loader interface with additional members.
  64363. */
  64364. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64365. }
  64366. /** @hidden */
  64367. export interface _IAnimationSamplerData {
  64368. input: Float32Array;
  64369. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64370. output: Float32Array;
  64371. }
  64372. /**
  64373. * Loader interface with additional members.
  64374. */
  64375. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64376. /** @hidden */
  64377. _data?: Promise<_IAnimationSamplerData>;
  64378. }
  64379. /**
  64380. * Loader interface with additional members.
  64381. */
  64382. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64383. channels: IAnimationChannel[];
  64384. samplers: IAnimationSampler[];
  64385. /** @hidden */
  64386. _babylonAnimationGroup?: AnimationGroup;
  64387. }
  64388. /**
  64389. * Loader interface with additional members.
  64390. */
  64391. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64392. /** @hidden */
  64393. _data?: Promise<ArrayBufferView>;
  64394. }
  64395. /**
  64396. * Loader interface with additional members.
  64397. */
  64398. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64399. /** @hidden */
  64400. _data?: Promise<ArrayBufferView>;
  64401. /** @hidden */
  64402. _babylonBuffer?: Promise<Buffer>;
  64403. }
  64404. /**
  64405. * Loader interface with additional members.
  64406. */
  64407. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64408. }
  64409. /**
  64410. * Loader interface with additional members.
  64411. */
  64412. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64413. /** @hidden */
  64414. _data?: Promise<ArrayBufferView>;
  64415. }
  64416. /**
  64417. * Loader interface with additional members.
  64418. */
  64419. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64420. }
  64421. /**
  64422. * Loader interface with additional members.
  64423. */
  64424. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64425. }
  64426. /**
  64427. * Loader interface with additional members.
  64428. */
  64429. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64430. baseColorTexture?: ITextureInfo;
  64431. metallicRoughnessTexture?: ITextureInfo;
  64432. }
  64433. /**
  64434. * Loader interface with additional members.
  64435. */
  64436. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64437. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64438. normalTexture?: IMaterialNormalTextureInfo;
  64439. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64440. emissiveTexture?: ITextureInfo;
  64441. /** @hidden */
  64442. _data?: {
  64443. [babylonDrawMode: number]: {
  64444. babylonMaterial: Material;
  64445. babylonMeshes: AbstractMesh[];
  64446. promise: Promise<void>;
  64447. };
  64448. };
  64449. }
  64450. /**
  64451. * Loader interface with additional members.
  64452. */
  64453. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64454. primitives: IMeshPrimitive[];
  64455. }
  64456. /**
  64457. * Loader interface with additional members.
  64458. */
  64459. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64460. /** @hidden */
  64461. _instanceData?: {
  64462. babylonSourceMesh: Mesh;
  64463. promise: Promise<any>;
  64464. };
  64465. }
  64466. /**
  64467. * Loader interface with additional members.
  64468. */
  64469. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64470. /**
  64471. * The parent glTF node.
  64472. */
  64473. parent?: INode;
  64474. /** @hidden */
  64475. _babylonTransformNode?: TransformNode;
  64476. /** @hidden */
  64477. _primitiveBabylonMeshes?: AbstractMesh[];
  64478. /** @hidden */
  64479. _babylonBones?: Bone[];
  64480. /** @hidden */
  64481. _numMorphTargets?: number;
  64482. }
  64483. /** @hidden */
  64484. export interface _ISamplerData {
  64485. noMipMaps: boolean;
  64486. samplingMode: number;
  64487. wrapU: number;
  64488. wrapV: number;
  64489. }
  64490. /**
  64491. * Loader interface with additional members.
  64492. */
  64493. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64494. /** @hidden */
  64495. _data?: _ISamplerData;
  64496. }
  64497. /**
  64498. * Loader interface with additional members.
  64499. */
  64500. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64501. }
  64502. /**
  64503. * Loader interface with additional members.
  64504. */
  64505. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64506. /** @hidden */
  64507. _data?: {
  64508. babylonSkeleton: Skeleton;
  64509. promise: Promise<void>;
  64510. };
  64511. }
  64512. /**
  64513. * Loader interface with additional members.
  64514. */
  64515. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64516. }
  64517. /**
  64518. * Loader interface with additional members.
  64519. */
  64520. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64521. }
  64522. /**
  64523. * Loader interface with additional members.
  64524. */
  64525. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64526. accessors?: IAccessor[];
  64527. animations?: IAnimation[];
  64528. buffers?: IBuffer[];
  64529. bufferViews?: IBufferView[];
  64530. cameras?: ICamera[];
  64531. images?: IImage[];
  64532. materials?: IMaterial[];
  64533. meshes?: IMesh[];
  64534. nodes?: INode[];
  64535. samplers?: ISampler[];
  64536. scenes?: IScene[];
  64537. skins?: ISkin[];
  64538. textures?: ITexture[];
  64539. }
  64540. }
  64541. declare module BABYLON.GLTF2 {
  64542. /**
  64543. * Interface for a glTF loader extension.
  64544. */
  64545. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64546. /**
  64547. * Called after the loader state changes to LOADING.
  64548. */
  64549. onLoading?(): void;
  64550. /**
  64551. * Called after the loader state changes to READY.
  64552. */
  64553. onReady?(): void;
  64554. /**
  64555. * Define this method to modify the default behavior when loading scenes.
  64556. * @param context The context when loading the asset
  64557. * @param scene The glTF scene property
  64558. * @returns A promise that resolves when the load is complete or null if not handled
  64559. */
  64560. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64561. /**
  64562. * Define this method to modify the default behavior when loading nodes.
  64563. * @param context The context when loading the asset
  64564. * @param node The glTF node property
  64565. * @param assign A function called synchronously after parsing the glTF properties
  64566. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64567. */
  64568. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64569. /**
  64570. * Define this method to modify the default behavior when loading cameras.
  64571. * @param context The context when loading the asset
  64572. * @param camera The glTF camera property
  64573. * @param assign A function called synchronously after parsing the glTF properties
  64574. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64575. */
  64576. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64577. /**
  64578. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64579. * @param context The context when loading the asset
  64580. * @param primitive The glTF mesh primitive property
  64581. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64582. */
  64583. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64584. /**
  64585. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64586. * @param context The context when loading the asset
  64587. * @param name The mesh name when loading the asset
  64588. * @param node The glTF node when loading the asset
  64589. * @param mesh The glTF mesh when loading the asset
  64590. * @param primitive The glTF mesh primitive property
  64591. * @param assign A function called synchronously after parsing the glTF properties
  64592. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64593. */
  64594. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64595. /**
  64596. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64597. * @param context The context when loading the asset
  64598. * @param material The glTF material property
  64599. * @param assign A function called synchronously after parsing the glTF properties
  64600. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64601. */
  64602. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64603. /**
  64604. * Define this method to modify the default behavior when creating materials.
  64605. * @param context The context when loading the asset
  64606. * @param material The glTF material property
  64607. * @param babylonDrawMode The draw mode for the Babylon material
  64608. * @returns The Babylon material or null if not handled
  64609. */
  64610. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64611. /**
  64612. * Define this method to modify the default behavior when loading material properties.
  64613. * @param context The context when loading the asset
  64614. * @param material The glTF material property
  64615. * @param babylonMaterial The Babylon material
  64616. * @returns A promise that resolves when the load is complete or null if not handled
  64617. */
  64618. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64619. /**
  64620. * Define this method to modify the default behavior when loading texture infos.
  64621. * @param context The context when loading the asset
  64622. * @param textureInfo The glTF texture info property
  64623. * @param assign A function called synchronously after parsing the glTF properties
  64624. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64625. */
  64626. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64627. /**
  64628. * Define this method to modify the default behavior when loading animations.
  64629. * @param context The context when loading the asset
  64630. * @param animation The glTF animation property
  64631. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64632. */
  64633. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64634. /**
  64635. * @hidden Define this method to modify the default behavior when loading skins.
  64636. * @param context The context when loading the asset
  64637. * @param node The glTF node property
  64638. * @param skin The glTF skin property
  64639. * @returns A promise that resolves when the load is complete or null if not handled
  64640. */
  64641. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64642. /**
  64643. * @hidden Define this method to modify the default behavior when loading uris.
  64644. * @param context The context when loading the asset
  64645. * @param property The glTF property associated with the uri
  64646. * @param uri The uri to load
  64647. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64648. */
  64649. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64650. }
  64651. }
  64652. declare module BABYLON.GLTF2 {
  64653. /**
  64654. * Helper class for working with arrays when loading the glTF asset
  64655. */
  64656. export class ArrayItem {
  64657. /**
  64658. * Gets an item from the given array.
  64659. * @param context The context when loading the asset
  64660. * @param array The array to get the item from
  64661. * @param index The index to the array
  64662. * @returns The array item
  64663. */
  64664. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64665. /**
  64666. * Assign an `index` field to each item of the given array.
  64667. * @param array The array of items
  64668. */
  64669. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64670. }
  64671. /**
  64672. * The glTF 2.0 loader
  64673. */
  64674. export class GLTFLoader implements IGLTFLoader {
  64675. /** @hidden */
  64676. _completePromises: Promise<any>[];
  64677. private _disposed;
  64678. private _parent;
  64679. private _state;
  64680. private _extensions;
  64681. private _rootUrl;
  64682. private _fileName;
  64683. private _uniqueRootUrl;
  64684. private _gltf;
  64685. private _babylonScene;
  64686. private _rootBabylonMesh;
  64687. private _defaultBabylonMaterialData;
  64688. private _progressCallback?;
  64689. private _requests;
  64690. private static readonly _DefaultSampler;
  64691. private static _ExtensionNames;
  64692. private static _ExtensionFactories;
  64693. /**
  64694. * Registers a loader extension.
  64695. * @param name The name of the loader extension.
  64696. * @param factory The factory function that creates the loader extension.
  64697. */
  64698. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64699. /**
  64700. * Unregisters a loader extension.
  64701. * @param name The name of the loader extenion.
  64702. * @returns A boolean indicating whether the extension has been unregistered
  64703. */
  64704. static UnregisterExtension(name: string): boolean;
  64705. /**
  64706. * Gets the loader state.
  64707. */
  64708. readonly state: Nullable<GLTFLoaderState>;
  64709. /**
  64710. * The glTF object parsed from the JSON.
  64711. */
  64712. readonly gltf: IGLTF;
  64713. /**
  64714. * The Babylon scene when loading the asset.
  64715. */
  64716. readonly babylonScene: Scene;
  64717. /**
  64718. * The root Babylon mesh when loading the asset.
  64719. */
  64720. readonly rootBabylonMesh: Mesh;
  64721. /** @hidden */
  64722. constructor(parent: GLTFFileLoader);
  64723. /** @hidden */
  64724. dispose(): void;
  64725. /** @hidden */
  64726. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64727. meshes: AbstractMesh[];
  64728. particleSystems: IParticleSystem[];
  64729. skeletons: Skeleton[];
  64730. animationGroups: AnimationGroup[];
  64731. }>;
  64732. /** @hidden */
  64733. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64734. private _loadAsync;
  64735. private _loadData;
  64736. private _setupData;
  64737. private _loadExtensions;
  64738. private _checkExtensions;
  64739. private _setState;
  64740. private _createRootNode;
  64741. /**
  64742. * Loads a glTF scene.
  64743. * @param context The context when loading the asset
  64744. * @param scene The glTF scene property
  64745. * @returns A promise that resolves when the load is complete
  64746. */
  64747. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64748. private _forEachPrimitive;
  64749. private _getMeshes;
  64750. private _getSkeletons;
  64751. private _getAnimationGroups;
  64752. private _startAnimations;
  64753. /**
  64754. * Loads a glTF node.
  64755. * @param context The context when loading the asset
  64756. * @param node The glTF node property
  64757. * @param assign A function called synchronously after parsing the glTF properties
  64758. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64759. */
  64760. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64761. private _loadMeshAsync;
  64762. /**
  64763. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64764. * @param context The context when loading the asset
  64765. * @param name The mesh name when loading the asset
  64766. * @param node The glTF node when loading the asset
  64767. * @param mesh The glTF mesh when loading the asset
  64768. * @param primitive The glTF mesh primitive property
  64769. * @param assign A function called synchronously after parsing the glTF properties
  64770. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64771. */
  64772. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64773. private _loadVertexDataAsync;
  64774. private _createMorphTargets;
  64775. private _loadMorphTargetsAsync;
  64776. private _loadMorphTargetVertexDataAsync;
  64777. private static _LoadTransform;
  64778. private _loadSkinAsync;
  64779. private _loadBones;
  64780. private _loadBone;
  64781. private _loadSkinInverseBindMatricesDataAsync;
  64782. private _updateBoneMatrices;
  64783. private _getNodeMatrix;
  64784. /**
  64785. * Loads a glTF camera.
  64786. * @param context The context when loading the asset
  64787. * @param camera The glTF camera property
  64788. * @param assign A function called synchronously after parsing the glTF properties
  64789. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64790. */
  64791. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64792. private _loadAnimationsAsync;
  64793. /**
  64794. * Loads a glTF animation.
  64795. * @param context The context when loading the asset
  64796. * @param animation The glTF animation property
  64797. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64798. */
  64799. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64800. /**
  64801. * @hidden Loads a glTF animation channel.
  64802. * @param context The context when loading the asset
  64803. * @param animationContext The context of the animation when loading the asset
  64804. * @param animation The glTF animation property
  64805. * @param channel The glTF animation channel property
  64806. * @param babylonAnimationGroup The babylon animation group property
  64807. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64808. * @returns A void promise when the channel load is complete
  64809. */
  64810. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64811. private _loadAnimationSamplerAsync;
  64812. private _loadBufferAsync;
  64813. /**
  64814. * Loads a glTF buffer view.
  64815. * @param context The context when loading the asset
  64816. * @param bufferView The glTF buffer view property
  64817. * @returns A promise that resolves with the loaded data when the load is complete
  64818. */
  64819. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64820. private _loadIndicesAccessorAsync;
  64821. private _loadFloatAccessorAsync;
  64822. private _loadVertexBufferViewAsync;
  64823. private _loadVertexAccessorAsync;
  64824. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64825. /** @hidden */
  64826. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64827. private _createDefaultMaterial;
  64828. /**
  64829. * Creates a Babylon material from a glTF material.
  64830. * @param context The context when loading the asset
  64831. * @param material The glTF material property
  64832. * @param babylonDrawMode The draw mode for the Babylon material
  64833. * @returns The Babylon material
  64834. */
  64835. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64836. /**
  64837. * Loads properties from a glTF material into a Babylon material.
  64838. * @param context The context when loading the asset
  64839. * @param material The glTF material property
  64840. * @param babylonMaterial The Babylon material
  64841. * @returns A promise that resolves when the load is complete
  64842. */
  64843. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64844. /**
  64845. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64846. * @param context The context when loading the asset
  64847. * @param material The glTF material property
  64848. * @param babylonMaterial The Babylon material
  64849. * @returns A promise that resolves when the load is complete
  64850. */
  64851. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64852. /**
  64853. * Loads the alpha properties from a glTF material into a Babylon material.
  64854. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64855. * @param context The context when loading the asset
  64856. * @param material The glTF material property
  64857. * @param babylonMaterial The Babylon material
  64858. */
  64859. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64860. /**
  64861. * Loads a glTF texture info.
  64862. * @param context The context when loading the asset
  64863. * @param textureInfo The glTF texture info property
  64864. * @param assign A function called synchronously after parsing the glTF properties
  64865. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64866. */
  64867. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64868. private _loadTextureAsync;
  64869. private _loadSampler;
  64870. /**
  64871. * Loads a glTF image.
  64872. * @param context The context when loading the asset
  64873. * @param image The glTF image property
  64874. * @returns A promise that resolves with the loaded data when the load is complete
  64875. */
  64876. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64877. /**
  64878. * Loads a glTF uri.
  64879. * @param context The context when loading the asset
  64880. * @param property The glTF property associated with the uri
  64881. * @param uri The base64 or relative uri
  64882. * @returns A promise that resolves with the loaded data when the load is complete
  64883. */
  64884. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64885. private _onProgress;
  64886. /**
  64887. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64888. * @param babylonObject the Babylon object with metadata
  64889. * @param pointer the JSON pointer
  64890. */
  64891. static AddPointerMetadata(babylonObject: {
  64892. metadata: any;
  64893. }, pointer: string): void;
  64894. private static _GetTextureWrapMode;
  64895. private static _GetTextureSamplingMode;
  64896. private static _GetTypedArray;
  64897. private static _GetNumComponents;
  64898. private static _ValidateUri;
  64899. private static _GetDrawMode;
  64900. private _compileMaterialsAsync;
  64901. private _compileShadowGeneratorsAsync;
  64902. private _forEachExtensions;
  64903. private _applyExtensions;
  64904. private _extensionsOnLoading;
  64905. private _extensionsOnReady;
  64906. private _extensionsLoadSceneAsync;
  64907. private _extensionsLoadNodeAsync;
  64908. private _extensionsLoadCameraAsync;
  64909. private _extensionsLoadVertexDataAsync;
  64910. private _extensionsLoadMeshPrimitiveAsync;
  64911. private _extensionsLoadMaterialAsync;
  64912. private _extensionsCreateMaterial;
  64913. private _extensionsLoadMaterialPropertiesAsync;
  64914. private _extensionsLoadTextureInfoAsync;
  64915. private _extensionsLoadAnimationAsync;
  64916. private _extensionsLoadSkinAsync;
  64917. private _extensionsLoadUriAsync;
  64918. /**
  64919. * Helper method called by a loader extension to load an glTF extension.
  64920. * @param context The context when loading the asset
  64921. * @param property The glTF property to load the extension from
  64922. * @param extensionName The name of the extension to load
  64923. * @param actionAsync The action to run
  64924. * @returns The promise returned by actionAsync or null if the extension does not exist
  64925. */
  64926. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64927. /**
  64928. * Helper method called by a loader extension to load a glTF extra.
  64929. * @param context The context when loading the asset
  64930. * @param property The glTF property to load the extra from
  64931. * @param extensionName The name of the extension to load
  64932. * @param actionAsync The action to run
  64933. * @returns The promise returned by actionAsync or null if the extra does not exist
  64934. */
  64935. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64936. /**
  64937. * Increments the indentation level and logs a message.
  64938. * @param message The message to log
  64939. */
  64940. logOpen(message: string): void;
  64941. /**
  64942. * Decrements the indentation level.
  64943. */
  64944. logClose(): void;
  64945. /**
  64946. * Logs a message
  64947. * @param message The message to log
  64948. */
  64949. log(message: string): void;
  64950. /**
  64951. * Starts a performance counter.
  64952. * @param counterName The name of the performance counter
  64953. */
  64954. startPerformanceCounter(counterName: string): void;
  64955. /**
  64956. * Ends a performance counter.
  64957. * @param counterName The name of the performance counter
  64958. */
  64959. endPerformanceCounter(counterName: string): void;
  64960. }
  64961. }
  64962. declare module BABYLON.GLTF2.Loader.Extensions {
  64963. /**
  64964. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64965. */
  64966. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64967. /** The name of this extension. */
  64968. readonly name: string;
  64969. /** Defines whether this extension is enabled. */
  64970. enabled: boolean;
  64971. private _loader;
  64972. private _lights?;
  64973. /** @hidden */
  64974. constructor(loader: GLTFLoader);
  64975. /** @hidden */
  64976. dispose(): void;
  64977. /** @hidden */
  64978. onLoading(): void;
  64979. /** @hidden */
  64980. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64981. private _loadLightAsync;
  64982. }
  64983. }
  64984. declare module BABYLON.GLTF2.Loader.Extensions {
  64985. /**
  64986. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64987. */
  64988. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64989. /** The name of this extension. */
  64990. readonly name: string;
  64991. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64992. dracoCompression?: DracoCompression;
  64993. /** Defines whether this extension is enabled. */
  64994. enabled: boolean;
  64995. private _loader;
  64996. /** @hidden */
  64997. constructor(loader: GLTFLoader);
  64998. /** @hidden */
  64999. dispose(): void;
  65000. /** @hidden */
  65001. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65002. }
  65003. }
  65004. declare module BABYLON.GLTF2.Loader.Extensions {
  65005. /**
  65006. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65007. */
  65008. export class KHR_lights implements IGLTFLoaderExtension {
  65009. /** The name of this extension. */
  65010. readonly name: string;
  65011. /** Defines whether this extension is enabled. */
  65012. enabled: boolean;
  65013. private _loader;
  65014. private _lights?;
  65015. /** @hidden */
  65016. constructor(loader: GLTFLoader);
  65017. /** @hidden */
  65018. dispose(): void;
  65019. /** @hidden */
  65020. onLoading(): void;
  65021. /** @hidden */
  65022. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65023. }
  65024. }
  65025. declare module BABYLON.GLTF2.Loader.Extensions {
  65026. /**
  65027. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65028. */
  65029. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65030. /** The name of this extension. */
  65031. readonly name: string;
  65032. /** Defines whether this extension is enabled. */
  65033. enabled: boolean;
  65034. private _loader;
  65035. /** @hidden */
  65036. constructor(loader: GLTFLoader);
  65037. /** @hidden */
  65038. dispose(): void;
  65039. /** @hidden */
  65040. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65041. private _loadSpecularGlossinessPropertiesAsync;
  65042. }
  65043. }
  65044. declare module BABYLON.GLTF2.Loader.Extensions {
  65045. /**
  65046. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65047. */
  65048. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65049. /** The name of this extension. */
  65050. readonly name: string;
  65051. /** Defines whether this extension is enabled. */
  65052. enabled: boolean;
  65053. private _loader;
  65054. /** @hidden */
  65055. constructor(loader: GLTFLoader);
  65056. /** @hidden */
  65057. dispose(): void;
  65058. /** @hidden */
  65059. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65060. private _loadUnlitPropertiesAsync;
  65061. }
  65062. }
  65063. declare module BABYLON.GLTF2.Loader.Extensions {
  65064. /**
  65065. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65066. */
  65067. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65068. /** The name of this extension. */
  65069. readonly name: string;
  65070. /** Defines whether this extension is enabled. */
  65071. enabled: boolean;
  65072. private _loader;
  65073. /** @hidden */
  65074. constructor(loader: GLTFLoader);
  65075. /** @hidden */
  65076. dispose(): void;
  65077. /** @hidden */
  65078. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65079. }
  65080. }
  65081. declare module BABYLON.GLTF2.Loader.Extensions {
  65082. /**
  65083. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65084. */
  65085. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65086. /** The name of this extension. */
  65087. readonly name: string;
  65088. /** Defines whether this extension is enabled. */
  65089. enabled: boolean;
  65090. private _loader;
  65091. private _clips;
  65092. private _emitters;
  65093. /** @hidden */
  65094. constructor(loader: GLTFLoader);
  65095. /** @hidden */
  65096. dispose(): void;
  65097. /** @hidden */
  65098. onLoading(): void;
  65099. /** @hidden */
  65100. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65101. /** @hidden */
  65102. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65103. /** @hidden */
  65104. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65105. private _loadClipAsync;
  65106. private _loadEmitterAsync;
  65107. private _getEventAction;
  65108. private _loadAnimationEventAsync;
  65109. }
  65110. }
  65111. declare module BABYLON.GLTF2.Loader.Extensions {
  65112. /**
  65113. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65114. */
  65115. export class MSFT_lod implements IGLTFLoaderExtension {
  65116. /** The name of this extension. */
  65117. readonly name: string;
  65118. /** Defines whether this extension is enabled. */
  65119. enabled: boolean;
  65120. /**
  65121. * Maximum number of LODs to load, starting from the lowest LOD.
  65122. */
  65123. maxLODsToLoad: number;
  65124. /**
  65125. * Observable raised when all node LODs of one level are loaded.
  65126. * The event data is the index of the loaded LOD starting from zero.
  65127. * Dispose the loader to cancel the loading of the next level of LODs.
  65128. */
  65129. onNodeLODsLoadedObservable: Observable<number>;
  65130. /**
  65131. * Observable raised when all material LODs of one level are loaded.
  65132. * The event data is the index of the loaded LOD starting from zero.
  65133. * Dispose the loader to cancel the loading of the next level of LODs.
  65134. */
  65135. onMaterialLODsLoadedObservable: Observable<number>;
  65136. private _loader;
  65137. private _nodeIndexLOD;
  65138. private _nodeSignalLODs;
  65139. private _nodePromiseLODs;
  65140. private _materialIndexLOD;
  65141. private _materialSignalLODs;
  65142. private _materialPromiseLODs;
  65143. /** @hidden */
  65144. constructor(loader: GLTFLoader);
  65145. /** @hidden */
  65146. dispose(): void;
  65147. /** @hidden */
  65148. onReady(): void;
  65149. /** @hidden */
  65150. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65151. /** @hidden */
  65152. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65153. /** @hidden */
  65154. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65155. /**
  65156. * Gets an array of LOD properties from lowest to highest.
  65157. */
  65158. private _getLODs;
  65159. private _disposeUnusedMaterials;
  65160. }
  65161. }
  65162. declare module BABYLON.GLTF2.Loader.Extensions {
  65163. /** @hidden */
  65164. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65165. readonly name: string;
  65166. enabled: boolean;
  65167. private _loader;
  65168. constructor(loader: GLTFLoader);
  65169. dispose(): void;
  65170. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65171. }
  65172. }
  65173. declare module BABYLON.GLTF2.Loader.Extensions {
  65174. /** @hidden */
  65175. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65176. readonly name: string;
  65177. enabled: boolean;
  65178. private _loader;
  65179. constructor(loader: GLTFLoader);
  65180. dispose(): void;
  65181. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65182. }
  65183. }
  65184. declare module BABYLON {
  65185. /**
  65186. * Class reading and parsing the MTL file bundled with the obj file.
  65187. */
  65188. export class MTLFileLoader {
  65189. /**
  65190. * All material loaded from the mtl will be set here
  65191. */
  65192. materials: StandardMaterial[];
  65193. /**
  65194. * This function will read the mtl file and create each material described inside
  65195. * This function could be improve by adding :
  65196. * -some component missing (Ni, Tf...)
  65197. * -including the specific options available
  65198. *
  65199. * @param scene defines the scene the material will be created in
  65200. * @param data defines the mtl data to parse
  65201. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65202. */
  65203. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65204. /**
  65205. * Gets the texture for the material.
  65206. *
  65207. * If the material is imported from input file,
  65208. * We sanitize the url to ensure it takes the textre from aside the material.
  65209. *
  65210. * @param rootUrl The root url to load from
  65211. * @param value The value stored in the mtl
  65212. * @return The Texture
  65213. */
  65214. private static _getTexture;
  65215. }
  65216. /**
  65217. * Options for loading OBJ/MTL files
  65218. */
  65219. type MeshLoadOptions = {
  65220. /**
  65221. * Defines if UVs are optimized by default during load.
  65222. */
  65223. OptimizeWithUV: boolean;
  65224. /**
  65225. * Defines custom scaling of UV coordinates of loaded meshes.
  65226. */
  65227. UVScaling: Vector2;
  65228. /**
  65229. * Invert model on y-axis (does a model scaling inversion)
  65230. */
  65231. InvertY: boolean;
  65232. /**
  65233. * Invert Y-Axis of referenced textures on load
  65234. */
  65235. InvertTextureY: boolean;
  65236. /**
  65237. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65238. */
  65239. ImportVertexColors: boolean;
  65240. /**
  65241. * Compute the normals for the model, even if normals are present in the file.
  65242. */
  65243. ComputeNormals: boolean;
  65244. /**
  65245. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65246. */
  65247. SkipMaterials: boolean;
  65248. /**
  65249. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65250. */
  65251. MaterialLoadingFailsSilently: boolean;
  65252. };
  65253. /**
  65254. * OBJ file type loader.
  65255. * This is a babylon scene loader plugin.
  65256. */
  65257. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65258. /**
  65259. * Defines if UVs are optimized by default during load.
  65260. */
  65261. static OPTIMIZE_WITH_UV: boolean;
  65262. /**
  65263. * Invert model on y-axis (does a model scaling inversion)
  65264. */
  65265. static INVERT_Y: boolean;
  65266. /**
  65267. * Invert Y-Axis of referenced textures on load
  65268. */
  65269. static INVERT_TEXTURE_Y: boolean;
  65270. /**
  65271. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65272. */
  65273. static IMPORT_VERTEX_COLORS: boolean;
  65274. /**
  65275. * Compute the normals for the model, even if normals are present in the file.
  65276. */
  65277. static COMPUTE_NORMALS: boolean;
  65278. /**
  65279. * Defines custom scaling of UV coordinates of loaded meshes.
  65280. */
  65281. static UV_SCALING: Vector2;
  65282. /**
  65283. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65284. */
  65285. static SKIP_MATERIALS: boolean;
  65286. /**
  65287. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65288. *
  65289. * Defaults to true for backwards compatibility.
  65290. */
  65291. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65292. /**
  65293. * Defines the name of the plugin.
  65294. */
  65295. name: string;
  65296. /**
  65297. * Defines the extension the plugin is able to load.
  65298. */
  65299. extensions: string;
  65300. /** @hidden */
  65301. obj: RegExp;
  65302. /** @hidden */
  65303. group: RegExp;
  65304. /** @hidden */
  65305. mtllib: RegExp;
  65306. /** @hidden */
  65307. usemtl: RegExp;
  65308. /** @hidden */
  65309. smooth: RegExp;
  65310. /** @hidden */
  65311. vertexPattern: RegExp;
  65312. /** @hidden */
  65313. normalPattern: RegExp;
  65314. /** @hidden */
  65315. uvPattern: RegExp;
  65316. /** @hidden */
  65317. facePattern1: RegExp;
  65318. /** @hidden */
  65319. facePattern2: RegExp;
  65320. /** @hidden */
  65321. facePattern3: RegExp;
  65322. /** @hidden */
  65323. facePattern4: RegExp;
  65324. /** @hidden */
  65325. facePattern5: RegExp;
  65326. private _meshLoadOptions;
  65327. /**
  65328. * Creates loader for .OBJ files
  65329. *
  65330. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65331. */
  65332. constructor(meshLoadOptions?: MeshLoadOptions);
  65333. private static readonly currentMeshLoadOptions;
  65334. /**
  65335. * Calls synchronously the MTL file attached to this obj.
  65336. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65337. * Without this function materials are not displayed in the first frame (but displayed after).
  65338. * In consequence it is impossible to get material information in your HTML file
  65339. *
  65340. * @param url The URL of the MTL file
  65341. * @param rootUrl
  65342. * @param onSuccess Callback function to be called when the MTL file is loaded
  65343. * @private
  65344. */
  65345. private _loadMTL;
  65346. /**
  65347. * Instantiates a OBJ file loader plugin.
  65348. * @returns the created plugin
  65349. */
  65350. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65351. /**
  65352. * If the data string can be loaded directly.
  65353. *
  65354. * @param data string containing the file data
  65355. * @returns if the data can be loaded directly
  65356. */
  65357. canDirectLoad(data: string): boolean;
  65358. /**
  65359. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65360. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65361. * @param scene the scene the meshes should be added to
  65362. * @param data the OBJ data to load
  65363. * @param rootUrl root url to load from
  65364. * @param onProgress event that fires when loading progress has occured
  65365. * @param fileName Defines the name of the file to load
  65366. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65367. */
  65368. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65369. meshes: AbstractMesh[];
  65370. particleSystems: IParticleSystem[];
  65371. skeletons: Skeleton[];
  65372. animationGroups: AnimationGroup[];
  65373. }>;
  65374. /**
  65375. * Imports all objects from the loaded OBJ data and adds them to the scene
  65376. * @param scene the scene the objects should be added to
  65377. * @param data the OBJ data to load
  65378. * @param rootUrl root url to load from
  65379. * @param onProgress event that fires when loading progress has occured
  65380. * @param fileName Defines the name of the file to load
  65381. * @returns a promise which completes when objects have been loaded to the scene
  65382. */
  65383. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65384. /**
  65385. * Load into an asset container.
  65386. * @param scene The scene to load into
  65387. * @param data The data to import
  65388. * @param rootUrl The root url for scene and resources
  65389. * @param onProgress The callback when the load progresses
  65390. * @param fileName Defines the name of the file to load
  65391. * @returns The loaded asset container
  65392. */
  65393. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65394. /**
  65395. * Read the OBJ file and create an Array of meshes.
  65396. * Each mesh contains all information given by the OBJ and the MTL file.
  65397. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65398. *
  65399. * @param meshesNames
  65400. * @param scene Scene The scene where are displayed the data
  65401. * @param data String The content of the obj file
  65402. * @param rootUrl String The path to the folder
  65403. * @returns Array<AbstractMesh>
  65404. * @private
  65405. */
  65406. private _parseSolid;
  65407. }
  65408. }
  65409. declare module BABYLON {
  65410. /**
  65411. * STL file type loader.
  65412. * This is a babylon scene loader plugin.
  65413. */
  65414. export class STLFileLoader implements ISceneLoaderPlugin {
  65415. /** @hidden */
  65416. solidPattern: RegExp;
  65417. /** @hidden */
  65418. facetsPattern: RegExp;
  65419. /** @hidden */
  65420. normalPattern: RegExp;
  65421. /** @hidden */
  65422. vertexPattern: RegExp;
  65423. /**
  65424. * Defines the name of the plugin.
  65425. */
  65426. name: string;
  65427. /**
  65428. * Defines the extensions the stl loader is able to load.
  65429. * force data to come in as an ArrayBuffer
  65430. * we'll convert to string if it looks like it's an ASCII .stl
  65431. */
  65432. extensions: ISceneLoaderPluginExtensions;
  65433. /**
  65434. * Import meshes into a scene.
  65435. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65436. * @param scene The scene to import into
  65437. * @param data The data to import
  65438. * @param rootUrl The root url for scene and resources
  65439. * @param meshes The meshes array to import into
  65440. * @param particleSystems The particle systems array to import into
  65441. * @param skeletons The skeletons array to import into
  65442. * @param onError The callback when import fails
  65443. * @returns True if successful or false otherwise
  65444. */
  65445. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65446. /**
  65447. * Load into a scene.
  65448. * @param scene The scene to load into
  65449. * @param data The data to import
  65450. * @param rootUrl The root url for scene and resources
  65451. * @param onError The callback when import fails
  65452. * @returns true if successful or false otherwise
  65453. */
  65454. load(scene: Scene, data: any, rootUrl: string): boolean;
  65455. /**
  65456. * Load into an asset container.
  65457. * @param scene The scene to load into
  65458. * @param data The data to import
  65459. * @param rootUrl The root url for scene and resources
  65460. * @param onError The callback when import fails
  65461. * @returns The loaded asset container
  65462. */
  65463. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65464. private _isBinary;
  65465. private _parseBinary;
  65466. private _parseASCII;
  65467. }
  65468. }
  65469. declare module BABYLON {
  65470. /**
  65471. * Class for generating OBJ data from a Babylon scene.
  65472. */
  65473. export class OBJExport {
  65474. /**
  65475. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65476. * @param mesh defines the list of meshes to serialize
  65477. * @param materials defines if materials should be exported
  65478. * @param matlibname defines the name of the associated mtl file
  65479. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65480. * @returns the OBJ content
  65481. */
  65482. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65483. /**
  65484. * Exports the material(s) of a mesh in .MTL file format (text)
  65485. * @param mesh defines the mesh to extract the material from
  65486. * @returns the mtl content
  65487. */
  65488. static MTL(mesh: Mesh): string;
  65489. }
  65490. }
  65491. declare module BABYLON {
  65492. /** @hidden */
  65493. export var __IGLTFExporterExtension: number;
  65494. /**
  65495. * Interface for extending the exporter
  65496. * @hidden
  65497. */
  65498. export interface IGLTFExporterExtension {
  65499. /**
  65500. * The name of this extension
  65501. */
  65502. readonly name: string;
  65503. /**
  65504. * Defines whether this extension is enabled
  65505. */
  65506. enabled: boolean;
  65507. /**
  65508. * Defines whether this extension is required
  65509. */
  65510. required: boolean;
  65511. }
  65512. }
  65513. declare module BABYLON.GLTF2.Exporter {
  65514. /** @hidden */
  65515. export var __IGLTFExporterExtensionV2: number;
  65516. /**
  65517. * Interface for a glTF exporter extension
  65518. * @hidden
  65519. */
  65520. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65521. /**
  65522. * Define this method to modify the default behavior before exporting a texture
  65523. * @param context The context when loading the asset
  65524. * @param babylonTexture The glTF texture info property
  65525. * @param mimeType The mime-type of the generated image
  65526. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65527. */
  65528. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65529. /**
  65530. * Define this method to modify the default behavior when exporting texture info
  65531. * @param context The context when loading the asset
  65532. * @param meshPrimitive glTF mesh primitive
  65533. * @param babylonSubMesh Babylon submesh
  65534. * @param binaryWriter glTF serializer binary writer instance
  65535. * @returns nullable IMeshPrimitive promise
  65536. */
  65537. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65538. /**
  65539. * Define this method to modify the default behavior when exporting a node
  65540. * @param context The context when exporting the node
  65541. * @param node glTF node
  65542. * @param babylonNode BabylonJS node
  65543. * @returns nullable INode promise
  65544. */
  65545. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65546. /**
  65547. * Called after the exporter state changes to EXPORTING
  65548. */
  65549. onExporting?(): void;
  65550. }
  65551. }
  65552. declare module BABYLON.GLTF2.Exporter {
  65553. /**
  65554. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65555. * @hidden
  65556. */
  65557. export class _GLTFMaterialExporter {
  65558. /**
  65559. * Represents the dielectric specular values for R, G and B
  65560. */
  65561. private static readonly _DielectricSpecular;
  65562. /**
  65563. * Allows the maximum specular power to be defined for material calculations
  65564. */
  65565. private static readonly _MaxSpecularPower;
  65566. /**
  65567. * Mapping to store textures
  65568. */
  65569. private _textureMap;
  65570. /**
  65571. * Numeric tolerance value
  65572. */
  65573. private static readonly _Epsilon;
  65574. /**
  65575. * Reference to the glTF Exporter
  65576. */
  65577. private _exporter;
  65578. constructor(exporter: _Exporter);
  65579. /**
  65580. * Specifies if two colors are approximately equal in value
  65581. * @param color1 first color to compare to
  65582. * @param color2 second color to compare to
  65583. * @param epsilon threshold value
  65584. */
  65585. private static FuzzyEquals;
  65586. /**
  65587. * Gets the materials from a Babylon scene and converts them to glTF materials
  65588. * @param scene babylonjs scene
  65589. * @param mimeType texture mime type
  65590. * @param images array of images
  65591. * @param textures array of textures
  65592. * @param materials array of materials
  65593. * @param imageData mapping of texture names to base64 textures
  65594. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65595. */
  65596. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65597. /**
  65598. * Makes a copy of the glTF material without the texture parameters
  65599. * @param originalMaterial original glTF material
  65600. * @returns glTF material without texture parameters
  65601. */
  65602. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65603. /**
  65604. * Specifies if the material has any texture parameters present
  65605. * @param material glTF Material
  65606. * @returns boolean specifying if texture parameters are present
  65607. */
  65608. _hasTexturesPresent(material: IMaterial): boolean;
  65609. /**
  65610. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65611. * @param babylonStandardMaterial
  65612. * @returns glTF Metallic Roughness Material representation
  65613. */
  65614. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65615. /**
  65616. * Computes the metallic factor
  65617. * @param diffuse diffused value
  65618. * @param specular specular value
  65619. * @param oneMinusSpecularStrength one minus the specular strength
  65620. * @returns metallic value
  65621. */
  65622. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65623. /**
  65624. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65625. * @param glTFMaterial glTF material
  65626. * @param babylonMaterial Babylon material
  65627. */
  65628. private static _SetAlphaMode;
  65629. /**
  65630. * Converts a Babylon Standard Material to a glTF Material
  65631. * @param babylonStandardMaterial BJS Standard Material
  65632. * @param mimeType mime type to use for the textures
  65633. * @param images array of glTF image interfaces
  65634. * @param textures array of glTF texture interfaces
  65635. * @param materials array of glTF material interfaces
  65636. * @param imageData map of image file name to data
  65637. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65638. */
  65639. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65640. /**
  65641. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65642. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65643. * @param mimeType mime type to use for the textures
  65644. * @param images array of glTF image interfaces
  65645. * @param textures array of glTF texture interfaces
  65646. * @param materials array of glTF material interfaces
  65647. * @param imageData map of image file name to data
  65648. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65649. */
  65650. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65651. /**
  65652. * Converts an image typed array buffer to a base64 image
  65653. * @param buffer typed array buffer
  65654. * @param width width of the image
  65655. * @param height height of the image
  65656. * @param mimeType mimetype of the image
  65657. * @returns base64 image string
  65658. */
  65659. private _createBase64FromCanvasAsync;
  65660. /**
  65661. * Generates a white texture based on the specified width and height
  65662. * @param width width of the texture in pixels
  65663. * @param height height of the texture in pixels
  65664. * @param scene babylonjs scene
  65665. * @returns white texture
  65666. */
  65667. private _createWhiteTexture;
  65668. /**
  65669. * 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
  65670. * @param texture1 first texture to resize
  65671. * @param texture2 second texture to resize
  65672. * @param scene babylonjs scene
  65673. * @returns resized textures or null
  65674. */
  65675. private _resizeTexturesToSameDimensions;
  65676. /**
  65677. * Converts an array of pixels to a Float32Array
  65678. * Throws an error if the pixel format is not supported
  65679. * @param pixels - array buffer containing pixel values
  65680. * @returns Float32 of pixels
  65681. */
  65682. private _convertPixelArrayToFloat32;
  65683. /**
  65684. * Convert Specular Glossiness Textures to Metallic Roughness
  65685. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65686. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65687. * @param diffuseTexture texture used to store diffuse information
  65688. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65689. * @param factors specular glossiness material factors
  65690. * @param mimeType the mime type to use for the texture
  65691. * @returns pbr metallic roughness interface or null
  65692. */
  65693. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65694. /**
  65695. * Converts specular glossiness material properties to metallic roughness
  65696. * @param specularGlossiness interface with specular glossiness material properties
  65697. * @returns interface with metallic roughness material properties
  65698. */
  65699. private _convertSpecularGlossinessToMetallicRoughness;
  65700. /**
  65701. * Calculates the surface reflectance, independent of lighting conditions
  65702. * @param color Color source to calculate brightness from
  65703. * @returns number representing the perceived brightness, or zero if color is undefined
  65704. */
  65705. private _getPerceivedBrightness;
  65706. /**
  65707. * Returns the maximum color component value
  65708. * @param color
  65709. * @returns maximum color component value, or zero if color is null or undefined
  65710. */
  65711. private _getMaxComponent;
  65712. /**
  65713. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65714. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65715. * @param mimeType mime type to use for the textures
  65716. * @param images array of glTF image interfaces
  65717. * @param textures array of glTF texture interfaces
  65718. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65719. * @param imageData map of image file name to data
  65720. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65721. * @returns glTF PBR Metallic Roughness factors
  65722. */
  65723. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65724. private _getGLTFTextureSampler;
  65725. private _getGLTFTextureWrapMode;
  65726. private _getGLTFTextureWrapModesSampler;
  65727. /**
  65728. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65729. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65730. * @param mimeType mime type to use for the textures
  65731. * @param images array of glTF image interfaces
  65732. * @param textures array of glTF texture interfaces
  65733. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65734. * @param imageData map of image file name to data
  65735. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65736. * @returns glTF PBR Metallic Roughness factors
  65737. */
  65738. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65739. /**
  65740. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65741. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65742. * @param mimeType mime type to use for the textures
  65743. * @param images array of glTF image interfaces
  65744. * @param textures array of glTF texture interfaces
  65745. * @param materials array of glTF material interfaces
  65746. * @param imageData map of image file name to data
  65747. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65748. */
  65749. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65750. private setMetallicRoughnessPbrMaterial;
  65751. private getPixelsFromTexture;
  65752. /**
  65753. * Extracts a texture from a Babylon texture into file data and glTF data
  65754. * @param babylonTexture Babylon texture to extract
  65755. * @param mimeType Mime Type of the babylonTexture
  65756. * @return glTF texture info, or null if the texture format is not supported
  65757. */
  65758. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65759. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65760. /**
  65761. * Builds a texture from base64 string
  65762. * @param base64Texture base64 texture string
  65763. * @param baseTextureName Name to use for the texture
  65764. * @param mimeType image mime type for the texture
  65765. * @param images array of images
  65766. * @param textures array of textures
  65767. * @param imageData map of image data
  65768. * @returns glTF texture info, or null if the texture format is not supported
  65769. */
  65770. private _getTextureInfoFromBase64;
  65771. }
  65772. }
  65773. declare module BABYLON {
  65774. /**
  65775. * Class for holding and downloading glTF file data
  65776. */
  65777. export class GLTFData {
  65778. /**
  65779. * Object which contains the file name as the key and its data as the value
  65780. */
  65781. glTFFiles: {
  65782. [fileName: string]: string | Blob;
  65783. };
  65784. /**
  65785. * Initializes the glTF file object
  65786. */
  65787. constructor();
  65788. /**
  65789. * Downloads the glTF data as files based on their names and data
  65790. */
  65791. downloadFiles(): void;
  65792. }
  65793. }
  65794. declare module BABYLON {
  65795. /**
  65796. * Holds a collection of exporter options and parameters
  65797. */
  65798. export interface IExportOptions {
  65799. /**
  65800. * Function which indicates whether a babylon node should be exported or not
  65801. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65802. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65803. */
  65804. shouldExportNode?(node: Node): boolean;
  65805. /**
  65806. * The sample rate to bake animation curves
  65807. */
  65808. animationSampleRate?: number;
  65809. /**
  65810. * Begin serialization without waiting for the scene to be ready
  65811. */
  65812. exportWithoutWaitingForScene?: boolean;
  65813. }
  65814. /**
  65815. * Class for generating glTF data from a Babylon scene.
  65816. */
  65817. export class GLTF2Export {
  65818. /**
  65819. * Exports the geometry of the scene to .gltf file format asynchronously
  65820. * @param scene Babylon scene with scene hierarchy information
  65821. * @param filePrefix File prefix to use when generating the glTF file
  65822. * @param options Exporter options
  65823. * @returns Returns an object with a .gltf file and associates texture names
  65824. * as keys and their data and paths as values
  65825. */
  65826. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65827. private static _PreExportAsync;
  65828. private static _PostExportAsync;
  65829. /**
  65830. * Exports the geometry of the scene to .glb file format asychronously
  65831. * @param scene Babylon scene with scene hierarchy information
  65832. * @param filePrefix File prefix to use when generating glb file
  65833. * @param options Exporter options
  65834. * @returns Returns an object with a .glb filename as key and data as value
  65835. */
  65836. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65837. }
  65838. }
  65839. declare module BABYLON.GLTF2.Exporter {
  65840. /**
  65841. * @hidden
  65842. */
  65843. export class _GLTFUtilities {
  65844. /**
  65845. * Creates a buffer view based on the supplied arguments
  65846. * @param bufferIndex index value of the specified buffer
  65847. * @param byteOffset byte offset value
  65848. * @param byteLength byte length of the bufferView
  65849. * @param byteStride byte distance between conequential elements
  65850. * @param name name of the buffer view
  65851. * @returns bufferView for glTF
  65852. */
  65853. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65854. /**
  65855. * Creates an accessor based on the supplied arguments
  65856. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65857. * @param name The name of the accessor
  65858. * @param type The type of the accessor
  65859. * @param componentType The datatype of components in the attribute
  65860. * @param count The number of attributes referenced by this accessor
  65861. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65862. * @param min Minimum value of each component in this attribute
  65863. * @param max Maximum value of each component in this attribute
  65864. * @returns accessor for glTF
  65865. */
  65866. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65867. /**
  65868. * Calculates the minimum and maximum values of an array of position floats
  65869. * @param positions Positions array of a mesh
  65870. * @param vertexStart Starting vertex offset to calculate min and max values
  65871. * @param vertexCount Number of vertices to check for min and max values
  65872. * @returns min number array and max number array
  65873. */
  65874. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65875. min: number[];
  65876. max: number[];
  65877. };
  65878. /**
  65879. * Converts a new right-handed Vector3
  65880. * @param vector vector3 array
  65881. * @returns right-handed Vector3
  65882. */
  65883. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65884. /**
  65885. * Converts a Vector3 to right-handed
  65886. * @param vector Vector3 to convert to right-handed
  65887. */
  65888. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65889. /**
  65890. * Converts a three element number array to right-handed
  65891. * @param vector number array to convert to right-handed
  65892. */
  65893. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65894. /**
  65895. * Converts a new right-handed Vector3
  65896. * @param vector vector3 array
  65897. * @returns right-handed Vector3
  65898. */
  65899. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65900. /**
  65901. * Converts a Vector3 to right-handed
  65902. * @param vector Vector3 to convert to right-handed
  65903. */
  65904. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65905. /**
  65906. * Converts a three element number array to right-handed
  65907. * @param vector number array to convert to right-handed
  65908. */
  65909. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65910. /**
  65911. * Converts a Vector4 to right-handed
  65912. * @param vector Vector4 to convert to right-handed
  65913. */
  65914. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65915. /**
  65916. * Converts a Vector4 to right-handed
  65917. * @param vector Vector4 to convert to right-handed
  65918. */
  65919. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65920. /**
  65921. * Converts a Quaternion to right-handed
  65922. * @param quaternion Source quaternion to convert to right-handed
  65923. */
  65924. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65925. /**
  65926. * Converts a Quaternion to right-handed
  65927. * @param quaternion Source quaternion to convert to right-handed
  65928. */
  65929. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65930. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65931. }
  65932. }
  65933. declare module BABYLON.GLTF2.Exporter {
  65934. /**
  65935. * Converts Babylon Scene into glTF 2.0.
  65936. * @hidden
  65937. */
  65938. export class _Exporter {
  65939. /**
  65940. * Stores the glTF to export
  65941. */
  65942. _glTF: IGLTF;
  65943. /**
  65944. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65945. */
  65946. _bufferViews: IBufferView[];
  65947. /**
  65948. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65949. */
  65950. _accessors: IAccessor[];
  65951. /**
  65952. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65953. */
  65954. private _nodes;
  65955. /**
  65956. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65957. */
  65958. private _scenes;
  65959. /**
  65960. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65961. */
  65962. private _meshes;
  65963. /**
  65964. * Stores all the generated material information, which represents the appearance of each primitive
  65965. */
  65966. _materials: IMaterial[];
  65967. _materialMap: {
  65968. [materialID: number]: number;
  65969. };
  65970. /**
  65971. * Stores all the generated texture information, which is referenced by glTF materials
  65972. */
  65973. _textures: ITexture[];
  65974. /**
  65975. * Stores all the generated image information, which is referenced by glTF textures
  65976. */
  65977. _images: IImage[];
  65978. /**
  65979. * Stores all the texture samplers
  65980. */
  65981. _samplers: ISampler[];
  65982. /**
  65983. * Stores all the generated animation samplers, which is referenced by glTF animations
  65984. */
  65985. /**
  65986. * Stores the animations for glTF models
  65987. */
  65988. private _animations;
  65989. /**
  65990. * Stores the total amount of bytes stored in the glTF buffer
  65991. */
  65992. private _totalByteLength;
  65993. /**
  65994. * Stores a reference to the Babylon scene containing the source geometry and material information
  65995. */
  65996. _babylonScene: Scene;
  65997. /**
  65998. * Stores a map of the image data, where the key is the file name and the value
  65999. * is the image data
  66000. */
  66001. _imageData: {
  66002. [fileName: string]: {
  66003. data: Uint8Array;
  66004. mimeType: ImageMimeType;
  66005. };
  66006. };
  66007. /**
  66008. * Stores a map of the unique id of a node to its index in the node array
  66009. */
  66010. private _nodeMap;
  66011. /**
  66012. * Specifies if the Babylon scene should be converted to right-handed on export
  66013. */
  66014. _convertToRightHandedSystem: boolean;
  66015. /**
  66016. * Baked animation sample rate
  66017. */
  66018. private _animationSampleRate;
  66019. /**
  66020. * Callback which specifies if a node should be exported or not
  66021. */
  66022. private _shouldExportNode;
  66023. private _localEngine;
  66024. _glTFMaterialExporter: _GLTFMaterialExporter;
  66025. private _extensions;
  66026. private static _ExtensionNames;
  66027. private static _ExtensionFactories;
  66028. private _applyExtensions;
  66029. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66030. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66031. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66032. private _forEachExtensions;
  66033. private _extensionsOnExporting;
  66034. /**
  66035. * Load glTF serializer extensions
  66036. */
  66037. private _loadExtensions;
  66038. /**
  66039. * Creates a glTF Exporter instance, which can accept optional exporter options
  66040. * @param babylonScene Babylon scene object
  66041. * @param options Options to modify the behavior of the exporter
  66042. */
  66043. constructor(babylonScene: Scene, options?: IExportOptions);
  66044. /**
  66045. * Registers a glTF exporter extension
  66046. * @param name Name of the extension to export
  66047. * @param factory The factory function that creates the exporter extension
  66048. */
  66049. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66050. /**
  66051. * Un-registers an exporter extension
  66052. * @param name The name fo the exporter extension
  66053. * @returns A boolean indicating whether the extension has been un-registered
  66054. */
  66055. static UnregisterExtension(name: string): boolean;
  66056. /**
  66057. * Lazy load a local engine with premultiplied alpha set to false
  66058. */
  66059. _getLocalEngine(): Engine;
  66060. private reorderIndicesBasedOnPrimitiveMode;
  66061. /**
  66062. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66063. * clock-wise during export to glTF
  66064. * @param submesh BabylonJS submesh
  66065. * @param primitiveMode Primitive mode of the mesh
  66066. * @param sideOrientation the winding order of the submesh
  66067. * @param vertexBufferKind The type of vertex attribute
  66068. * @param meshAttributeArray The vertex attribute data
  66069. * @param byteOffset The offset to the binary data
  66070. * @param binaryWriter The binary data for the glTF file
  66071. */
  66072. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66073. /**
  66074. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66075. * clock-wise during export to glTF
  66076. * @param submesh BabylonJS submesh
  66077. * @param primitiveMode Primitive mode of the mesh
  66078. * @param sideOrientation the winding order of the submesh
  66079. * @param vertexBufferKind The type of vertex attribute
  66080. * @param meshAttributeArray The vertex attribute data
  66081. * @param byteOffset The offset to the binary data
  66082. * @param binaryWriter The binary data for the glTF file
  66083. */
  66084. private reorderTriangleFillMode;
  66085. /**
  66086. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66087. * clock-wise during export to glTF
  66088. * @param submesh BabylonJS submesh
  66089. * @param primitiveMode Primitive mode of the mesh
  66090. * @param sideOrientation the winding order of the submesh
  66091. * @param vertexBufferKind The type of vertex attribute
  66092. * @param meshAttributeArray The vertex attribute data
  66093. * @param byteOffset The offset to the binary data
  66094. * @param binaryWriter The binary data for the glTF file
  66095. */
  66096. private reorderTriangleStripDrawMode;
  66097. /**
  66098. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66099. * clock-wise during export to glTF
  66100. * @param submesh BabylonJS submesh
  66101. * @param primitiveMode Primitive mode of the mesh
  66102. * @param sideOrientation the winding order of the submesh
  66103. * @param vertexBufferKind The type of vertex attribute
  66104. * @param meshAttributeArray The vertex attribute data
  66105. * @param byteOffset The offset to the binary data
  66106. * @param binaryWriter The binary data for the glTF file
  66107. */
  66108. private reorderTriangleFanMode;
  66109. /**
  66110. * Writes the vertex attribute data to binary
  66111. * @param vertices The vertices to write to the binary writer
  66112. * @param byteOffset The offset into the binary writer to overwrite binary data
  66113. * @param vertexAttributeKind The vertex attribute type
  66114. * @param meshAttributeArray The vertex attribute data
  66115. * @param binaryWriter The writer containing the binary data
  66116. */
  66117. private writeVertexAttributeData;
  66118. /**
  66119. * Writes mesh attribute data to a data buffer
  66120. * Returns the bytelength of the data
  66121. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66122. * @param meshAttributeArray Array containing the attribute data
  66123. * @param binaryWriter The buffer to write the binary data to
  66124. * @param indices Used to specify the order of the vertex data
  66125. */
  66126. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66127. /**
  66128. * Generates glTF json data
  66129. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66130. * @param glTFPrefix Text to use when prefixing a glTF file
  66131. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66132. * @returns json data as string
  66133. */
  66134. private generateJSON;
  66135. /**
  66136. * Generates data for .gltf and .bin files based on the glTF prefix string
  66137. * @param glTFPrefix Text to use when prefixing a glTF file
  66138. * @returns GLTFData with glTF file data
  66139. */
  66140. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66141. /**
  66142. * Creates a binary buffer for glTF
  66143. * @returns array buffer for binary data
  66144. */
  66145. private _generateBinaryAsync;
  66146. /**
  66147. * Pads the number to a multiple of 4
  66148. * @param num number to pad
  66149. * @returns padded number
  66150. */
  66151. private _getPadding;
  66152. /**
  66153. * Generates a glb file from the json and binary data
  66154. * Returns an object with the glb file name as the key and data as the value
  66155. * @param glTFPrefix
  66156. * @returns object with glb filename as key and data as value
  66157. */
  66158. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66159. /**
  66160. * Sets the TRS for each node
  66161. * @param node glTF Node for storing the transformation data
  66162. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66163. */
  66164. private setNodeTransformation;
  66165. private getVertexBufferFromMesh;
  66166. /**
  66167. * Creates a bufferview based on the vertices type for the Babylon mesh
  66168. * @param kind Indicates the type of vertices data
  66169. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66170. * @param binaryWriter The buffer to write the bufferview data to
  66171. */
  66172. private createBufferViewKind;
  66173. /**
  66174. * The primitive mode of the Babylon mesh
  66175. * @param babylonMesh The BabylonJS mesh
  66176. */
  66177. private getMeshPrimitiveMode;
  66178. /**
  66179. * Sets the primitive mode of the glTF mesh primitive
  66180. * @param meshPrimitive glTF mesh primitive
  66181. * @param primitiveMode The primitive mode
  66182. */
  66183. private setPrimitiveMode;
  66184. /**
  66185. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66186. * @param meshPrimitive glTF mesh primitive
  66187. * @param attributeKind vertex attribute
  66188. * @returns boolean specifying if uv coordinates are present
  66189. */
  66190. private setAttributeKind;
  66191. /**
  66192. * Sets data for the primitive attributes of each submesh
  66193. * @param mesh glTF Mesh object to store the primitive attribute information
  66194. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66195. * @param binaryWriter Buffer to write the attribute data to
  66196. */
  66197. private setPrimitiveAttributesAsync;
  66198. /**
  66199. * Creates a glTF scene based on the array of meshes
  66200. * Returns the the total byte offset
  66201. * @param babylonScene Babylon scene to get the mesh data from
  66202. * @param binaryWriter Buffer to write binary data to
  66203. */
  66204. private createSceneAsync;
  66205. /**
  66206. * Creates a mapping of Node unique id to node index and handles animations
  66207. * @param babylonScene Babylon Scene
  66208. * @param nodes Babylon transform nodes
  66209. * @param shouldExportNode Callback specifying if a transform node should be exported
  66210. * @param binaryWriter Buffer to write binary data to
  66211. * @returns Node mapping of unique id to index
  66212. */
  66213. private createNodeMapAndAnimationsAsync;
  66214. /**
  66215. * Creates a glTF node from a Babylon mesh
  66216. * @param babylonMesh Source Babylon mesh
  66217. * @param binaryWriter Buffer for storing geometry data
  66218. * @returns glTF node
  66219. */
  66220. private createNodeAsync;
  66221. }
  66222. /**
  66223. * @hidden
  66224. *
  66225. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66226. */
  66227. export class _BinaryWriter {
  66228. /**
  66229. * Array buffer which stores all binary data
  66230. */
  66231. private _arrayBuffer;
  66232. /**
  66233. * View of the array buffer
  66234. */
  66235. private _dataView;
  66236. /**
  66237. * byte offset of data in array buffer
  66238. */
  66239. private _byteOffset;
  66240. /**
  66241. * Initialize binary writer with an initial byte length
  66242. * @param byteLength Initial byte length of the array buffer
  66243. */
  66244. constructor(byteLength: number);
  66245. /**
  66246. * Resize the array buffer to the specified byte length
  66247. * @param byteLength
  66248. */
  66249. private resizeBuffer;
  66250. /**
  66251. * Get an array buffer with the length of the byte offset
  66252. * @returns ArrayBuffer resized to the byte offset
  66253. */
  66254. getArrayBuffer(): ArrayBuffer;
  66255. /**
  66256. * Get the byte offset of the array buffer
  66257. * @returns byte offset
  66258. */
  66259. getByteOffset(): number;
  66260. /**
  66261. * Stores an UInt8 in the array buffer
  66262. * @param entry
  66263. * @param byteOffset If defined, specifies where to set the value as an offset.
  66264. */
  66265. setUInt8(entry: number, byteOffset?: number): void;
  66266. /**
  66267. * Gets an UInt32 in the array buffer
  66268. * @param entry
  66269. * @param byteOffset If defined, specifies where to set the value as an offset.
  66270. */
  66271. getUInt32(byteOffset: number): number;
  66272. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66273. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66274. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66275. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66276. /**
  66277. * Stores a Float32 in the array buffer
  66278. * @param entry
  66279. */
  66280. setFloat32(entry: number, byteOffset?: number): void;
  66281. /**
  66282. * Stores an UInt32 in the array buffer
  66283. * @param entry
  66284. * @param byteOffset If defined, specifies where to set the value as an offset.
  66285. */
  66286. setUInt32(entry: number, byteOffset?: number): void;
  66287. }
  66288. }
  66289. declare module BABYLON.GLTF2.Exporter {
  66290. /**
  66291. * @hidden
  66292. * Interface to store animation data.
  66293. */
  66294. export interface _IAnimationData {
  66295. /**
  66296. * Keyframe data.
  66297. */
  66298. inputs: number[];
  66299. /**
  66300. * Value data.
  66301. */
  66302. outputs: number[][];
  66303. /**
  66304. * Animation interpolation data.
  66305. */
  66306. samplerInterpolation: AnimationSamplerInterpolation;
  66307. /**
  66308. * Minimum keyframe value.
  66309. */
  66310. inputsMin: number;
  66311. /**
  66312. * Maximum keyframe value.
  66313. */
  66314. inputsMax: number;
  66315. }
  66316. /**
  66317. * @hidden
  66318. */
  66319. export interface _IAnimationInfo {
  66320. /**
  66321. * The target channel for the animation
  66322. */
  66323. animationChannelTargetPath: AnimationChannelTargetPath;
  66324. /**
  66325. * The glTF accessor type for the data.
  66326. */
  66327. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66328. /**
  66329. * Specifies if quaternions should be used.
  66330. */
  66331. useQuaternion: boolean;
  66332. }
  66333. /**
  66334. * @hidden
  66335. * Utility class for generating glTF animation data from BabylonJS.
  66336. */
  66337. export class _GLTFAnimation {
  66338. /**
  66339. * @ignore
  66340. *
  66341. * Creates glTF channel animation from BabylonJS animation.
  66342. * @param babylonTransformNode - BabylonJS mesh.
  66343. * @param animation - animation.
  66344. * @param animationChannelTargetPath - The target animation channel.
  66345. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66346. * @param useQuaternion - Specifies if quaternions are used.
  66347. * @returns nullable IAnimationData
  66348. */
  66349. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66350. private static _DeduceAnimationInfo;
  66351. /**
  66352. * @ignore
  66353. * Create node animations from the transform node animations
  66354. * @param babylonNode
  66355. * @param runtimeGLTFAnimation
  66356. * @param idleGLTFAnimations
  66357. * @param nodeMap
  66358. * @param nodes
  66359. * @param binaryWriter
  66360. * @param bufferViews
  66361. * @param accessors
  66362. * @param convertToRightHandedSystem
  66363. */
  66364. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66365. [key: number]: number;
  66366. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66367. /**
  66368. * @ignore
  66369. * Create node animations from the animation groups
  66370. * @param babylonScene
  66371. * @param glTFAnimations
  66372. * @param nodeMap
  66373. * @param nodes
  66374. * @param binaryWriter
  66375. * @param bufferViews
  66376. * @param accessors
  66377. * @param convertToRightHandedSystem
  66378. */
  66379. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66380. [key: number]: number;
  66381. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66382. private static AddAnimation;
  66383. /**
  66384. * Create a baked animation
  66385. * @param babylonTransformNode BabylonJS mesh
  66386. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66387. * @param animationChannelTargetPath animation target channel
  66388. * @param minFrame minimum animation frame
  66389. * @param maxFrame maximum animation frame
  66390. * @param fps frames per second of the animation
  66391. * @param inputs input key frames of the animation
  66392. * @param outputs output key frame data of the animation
  66393. * @param convertToRightHandedSystem converts the values to right-handed
  66394. * @param useQuaternion specifies if quaternions should be used
  66395. */
  66396. private static _CreateBakedAnimation;
  66397. private static _ConvertFactorToVector3OrQuaternion;
  66398. private static _SetInterpolatedValue;
  66399. /**
  66400. * Creates linear animation from the animation key frames
  66401. * @param babylonTransformNode BabylonJS mesh
  66402. * @param animation BabylonJS animation
  66403. * @param animationChannelTargetPath The target animation channel
  66404. * @param frameDelta The difference between the last and first frame of the animation
  66405. * @param inputs Array to store the key frame times
  66406. * @param outputs Array to store the key frame data
  66407. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66408. * @param useQuaternion Specifies if quaternions are used in the animation
  66409. */
  66410. private static _CreateLinearOrStepAnimation;
  66411. /**
  66412. * Creates cubic spline animation from the animation key frames
  66413. * @param babylonTransformNode BabylonJS mesh
  66414. * @param animation BabylonJS animation
  66415. * @param animationChannelTargetPath The target animation channel
  66416. * @param frameDelta The difference between the last and first frame of the animation
  66417. * @param inputs Array to store the key frame times
  66418. * @param outputs Array to store the key frame data
  66419. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66420. * @param useQuaternion Specifies if quaternions are used in the animation
  66421. */
  66422. private static _CreateCubicSplineAnimation;
  66423. private static _GetBasePositionRotationOrScale;
  66424. /**
  66425. * Adds a key frame value
  66426. * @param keyFrame
  66427. * @param animation
  66428. * @param outputs
  66429. * @param animationChannelTargetPath
  66430. * @param basePositionRotationOrScale
  66431. * @param convertToRightHandedSystem
  66432. * @param useQuaternion
  66433. */
  66434. private static _AddKeyframeValue;
  66435. /**
  66436. * Determine the interpolation based on the key frames
  66437. * @param keyFrames
  66438. * @param animationChannelTargetPath
  66439. * @param useQuaternion
  66440. */
  66441. private static _DeduceInterpolation;
  66442. /**
  66443. * Adds an input tangent or output tangent to the output data
  66444. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66445. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66446. * @param outputs The animation data by keyframe
  66447. * @param animationChannelTargetPath The target animation channel
  66448. * @param interpolation The interpolation type
  66449. * @param keyFrame The key frame with the animation data
  66450. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66451. * @param useQuaternion Specifies if quaternions are used
  66452. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66453. */
  66454. private static AddSplineTangent;
  66455. /**
  66456. * Get the minimum and maximum key frames' frame values
  66457. * @param keyFrames animation key frames
  66458. * @returns the minimum and maximum key frame value
  66459. */
  66460. private static calculateMinMaxKeyFrames;
  66461. }
  66462. }
  66463. declare module BABYLON.GLTF2.Exporter {
  66464. /** @hidden */
  66465. export var textureTransformPixelShader: {
  66466. name: string;
  66467. shader: string;
  66468. };
  66469. }
  66470. declare module BABYLON.GLTF2.Exporter.Extensions {
  66471. /**
  66472. * @hidden
  66473. */
  66474. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66475. /** Name of this extension */
  66476. readonly name: string;
  66477. /** Defines whether this extension is enabled */
  66478. enabled: boolean;
  66479. /** Defines whether this extension is required */
  66480. required: boolean;
  66481. /** Reference to the glTF exporter */
  66482. private _exporter;
  66483. constructor(exporter: _Exporter);
  66484. dispose(): void;
  66485. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66486. /**
  66487. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66488. * @param babylonTexture
  66489. * @param offset
  66490. * @param rotation
  66491. * @param scale
  66492. * @param scene
  66493. */
  66494. private _textureTransformTextureAsync;
  66495. }
  66496. }
  66497. declare module BABYLON.GLTF2.Exporter.Extensions {
  66498. /**
  66499. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66500. */
  66501. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66502. /** The name of this extension. */
  66503. readonly name: string;
  66504. /** Defines whether this extension is enabled. */
  66505. enabled: boolean;
  66506. /** Defines whether this extension is required */
  66507. required: boolean;
  66508. /** Reference to the glTF exporter */
  66509. private _exporter;
  66510. private _lights;
  66511. /** @hidden */
  66512. constructor(exporter: _Exporter);
  66513. /** @hidden */
  66514. dispose(): void;
  66515. /** @hidden */
  66516. onExporting(): void;
  66517. /**
  66518. * Define this method to modify the default behavior when exporting a node
  66519. * @param context The context when exporting the node
  66520. * @param node glTF node
  66521. * @param babylonNode BabylonJS node
  66522. * @returns nullable INode promise
  66523. */
  66524. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66525. }
  66526. }
  66527. declare module BABYLON {
  66528. /**
  66529. * Class for generating STL data from a Babylon scene.
  66530. */
  66531. export class STLExport {
  66532. /**
  66533. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66534. * @param meshes list defines the mesh to serialize
  66535. * @param download triggers the automatic download of the file.
  66536. * @param fileName changes the downloads fileName.
  66537. * @param binary changes the STL to a binary type.
  66538. * @param isLittleEndian toggle for binary type exporter.
  66539. * @returns the STL as UTF8 string
  66540. */
  66541. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66542. }
  66543. }
  66544. /**
  66545. * @ignoreChildren
  66546. * @ignore
  66547. */
  66548. declare module "babylonjs-gltf2interface" {
  66549. export = BABYLON.GLTF2;
  66550. }
  66551. /**
  66552. * Module for glTF 2.0 Interface
  66553. * @ignoreChildren
  66554. * @ignore
  66555. */
  66556. declare module BABYLON.GLTF2 {
  66557. /**
  66558. * The datatype of the components in the attribute
  66559. */
  66560. const enum AccessorComponentType {
  66561. /**
  66562. * Byte
  66563. */
  66564. BYTE = 5120,
  66565. /**
  66566. * Unsigned Byte
  66567. */
  66568. UNSIGNED_BYTE = 5121,
  66569. /**
  66570. * Short
  66571. */
  66572. SHORT = 5122,
  66573. /**
  66574. * Unsigned Short
  66575. */
  66576. UNSIGNED_SHORT = 5123,
  66577. /**
  66578. * Unsigned Int
  66579. */
  66580. UNSIGNED_INT = 5125,
  66581. /**
  66582. * Float
  66583. */
  66584. FLOAT = 5126,
  66585. }
  66586. /**
  66587. * Specifies if the attirbute is a scalar, vector, or matrix
  66588. */
  66589. const enum AccessorType {
  66590. /**
  66591. * Scalar
  66592. */
  66593. SCALAR = "SCALAR",
  66594. /**
  66595. * Vector2
  66596. */
  66597. VEC2 = "VEC2",
  66598. /**
  66599. * Vector3
  66600. */
  66601. VEC3 = "VEC3",
  66602. /**
  66603. * Vector4
  66604. */
  66605. VEC4 = "VEC4",
  66606. /**
  66607. * Matrix2x2
  66608. */
  66609. MAT2 = "MAT2",
  66610. /**
  66611. * Matrix3x3
  66612. */
  66613. MAT3 = "MAT3",
  66614. /**
  66615. * Matrix4x4
  66616. */
  66617. MAT4 = "MAT4",
  66618. }
  66619. /**
  66620. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66621. */
  66622. const enum AnimationChannelTargetPath {
  66623. /**
  66624. * Translation
  66625. */
  66626. TRANSLATION = "translation",
  66627. /**
  66628. * Rotation
  66629. */
  66630. ROTATION = "rotation",
  66631. /**
  66632. * Scale
  66633. */
  66634. SCALE = "scale",
  66635. /**
  66636. * Weights
  66637. */
  66638. WEIGHTS = "weights",
  66639. }
  66640. /**
  66641. * Interpolation algorithm
  66642. */
  66643. const enum AnimationSamplerInterpolation {
  66644. /**
  66645. * The animated values are linearly interpolated between keyframes
  66646. */
  66647. LINEAR = "LINEAR",
  66648. /**
  66649. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66650. */
  66651. STEP = "STEP",
  66652. /**
  66653. * The animation's interpolation is computed using a cubic spline with specified tangents
  66654. */
  66655. CUBICSPLINE = "CUBICSPLINE",
  66656. }
  66657. /**
  66658. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66659. */
  66660. const enum CameraType {
  66661. /**
  66662. * A perspective camera containing properties to create a perspective projection matrix
  66663. */
  66664. PERSPECTIVE = "perspective",
  66665. /**
  66666. * An orthographic camera containing properties to create an orthographic projection matrix
  66667. */
  66668. ORTHOGRAPHIC = "orthographic",
  66669. }
  66670. /**
  66671. * The mime-type of the image
  66672. */
  66673. const enum ImageMimeType {
  66674. /**
  66675. * JPEG Mime-type
  66676. */
  66677. JPEG = "image/jpeg",
  66678. /**
  66679. * PNG Mime-type
  66680. */
  66681. PNG = "image/png",
  66682. }
  66683. /**
  66684. * The alpha rendering mode of the material
  66685. */
  66686. const enum MaterialAlphaMode {
  66687. /**
  66688. * The alpha value is ignored and the rendered output is fully opaque
  66689. */
  66690. OPAQUE = "OPAQUE",
  66691. /**
  66692. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66693. */
  66694. MASK = "MASK",
  66695. /**
  66696. * 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)
  66697. */
  66698. BLEND = "BLEND",
  66699. }
  66700. /**
  66701. * The type of the primitives to render
  66702. */
  66703. const enum MeshPrimitiveMode {
  66704. /**
  66705. * Points
  66706. */
  66707. POINTS = 0,
  66708. /**
  66709. * Lines
  66710. */
  66711. LINES = 1,
  66712. /**
  66713. * Line Loop
  66714. */
  66715. LINE_LOOP = 2,
  66716. /**
  66717. * Line Strip
  66718. */
  66719. LINE_STRIP = 3,
  66720. /**
  66721. * Triangles
  66722. */
  66723. TRIANGLES = 4,
  66724. /**
  66725. * Triangle Strip
  66726. */
  66727. TRIANGLE_STRIP = 5,
  66728. /**
  66729. * Triangle Fan
  66730. */
  66731. TRIANGLE_FAN = 6,
  66732. }
  66733. /**
  66734. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66735. */
  66736. const enum TextureMagFilter {
  66737. /**
  66738. * Nearest
  66739. */
  66740. NEAREST = 9728,
  66741. /**
  66742. * Linear
  66743. */
  66744. LINEAR = 9729,
  66745. }
  66746. /**
  66747. * Minification filter. All valid values correspond to WebGL enums
  66748. */
  66749. const enum TextureMinFilter {
  66750. /**
  66751. * Nearest
  66752. */
  66753. NEAREST = 9728,
  66754. /**
  66755. * Linear
  66756. */
  66757. LINEAR = 9729,
  66758. /**
  66759. * Nearest Mip-Map Nearest
  66760. */
  66761. NEAREST_MIPMAP_NEAREST = 9984,
  66762. /**
  66763. * Linear Mipmap Nearest
  66764. */
  66765. LINEAR_MIPMAP_NEAREST = 9985,
  66766. /**
  66767. * Nearest Mipmap Linear
  66768. */
  66769. NEAREST_MIPMAP_LINEAR = 9986,
  66770. /**
  66771. * Linear Mipmap Linear
  66772. */
  66773. LINEAR_MIPMAP_LINEAR = 9987,
  66774. }
  66775. /**
  66776. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66777. */
  66778. const enum TextureWrapMode {
  66779. /**
  66780. * Clamp to Edge
  66781. */
  66782. CLAMP_TO_EDGE = 33071,
  66783. /**
  66784. * Mirrored Repeat
  66785. */
  66786. MIRRORED_REPEAT = 33648,
  66787. /**
  66788. * Repeat
  66789. */
  66790. REPEAT = 10497,
  66791. }
  66792. /**
  66793. * glTF Property
  66794. */
  66795. interface IProperty {
  66796. /**
  66797. * Dictionary object with extension-specific objects
  66798. */
  66799. extensions?: {
  66800. [key: string]: any;
  66801. };
  66802. /**
  66803. * Application-Specific data
  66804. */
  66805. extras?: any;
  66806. }
  66807. /**
  66808. * glTF Child of Root Property
  66809. */
  66810. interface IChildRootProperty extends IProperty {
  66811. /**
  66812. * The user-defined name of this object
  66813. */
  66814. name?: string;
  66815. }
  66816. /**
  66817. * Indices of those attributes that deviate from their initialization value
  66818. */
  66819. interface IAccessorSparseIndices extends IProperty {
  66820. /**
  66821. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66822. */
  66823. bufferView: number;
  66824. /**
  66825. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66826. */
  66827. byteOffset?: number;
  66828. /**
  66829. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66830. */
  66831. componentType: AccessorComponentType;
  66832. }
  66833. /**
  66834. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66835. */
  66836. interface IAccessorSparseValues extends IProperty {
  66837. /**
  66838. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66839. */
  66840. bufferView: number;
  66841. /**
  66842. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66843. */
  66844. byteOffset?: number;
  66845. }
  66846. /**
  66847. * Sparse storage of attributes that deviate from their initialization value
  66848. */
  66849. interface IAccessorSparse extends IProperty {
  66850. /**
  66851. * The number of attributes encoded in this sparse accessor
  66852. */
  66853. count: number;
  66854. /**
  66855. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66856. */
  66857. indices: IAccessorSparseIndices;
  66858. /**
  66859. * 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
  66860. */
  66861. values: IAccessorSparseValues;
  66862. }
  66863. /**
  66864. * 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
  66865. */
  66866. interface IAccessor extends IChildRootProperty {
  66867. /**
  66868. * The index of the bufferview
  66869. */
  66870. bufferView?: number;
  66871. /**
  66872. * The offset relative to the start of the bufferView in bytes
  66873. */
  66874. byteOffset?: number;
  66875. /**
  66876. * The datatype of components in the attribute
  66877. */
  66878. componentType: AccessorComponentType;
  66879. /**
  66880. * Specifies whether integer data values should be normalized
  66881. */
  66882. normalized?: boolean;
  66883. /**
  66884. * The number of attributes referenced by this accessor
  66885. */
  66886. count: number;
  66887. /**
  66888. * Specifies if the attribute is a scalar, vector, or matrix
  66889. */
  66890. type: AccessorType;
  66891. /**
  66892. * Maximum value of each component in this attribute
  66893. */
  66894. max?: number[];
  66895. /**
  66896. * Minimum value of each component in this attribute
  66897. */
  66898. min?: number[];
  66899. /**
  66900. * Sparse storage of attributes that deviate from their initialization value
  66901. */
  66902. sparse?: IAccessorSparse;
  66903. }
  66904. /**
  66905. * Targets an animation's sampler at a node's property
  66906. */
  66907. interface IAnimationChannel extends IProperty {
  66908. /**
  66909. * The index of a sampler in this animation used to compute the value for the target
  66910. */
  66911. sampler: number;
  66912. /**
  66913. * The index of the node and TRS property to target
  66914. */
  66915. target: IAnimationChannelTarget;
  66916. }
  66917. /**
  66918. * The index of the node and TRS property that an animation channel targets
  66919. */
  66920. interface IAnimationChannelTarget extends IProperty {
  66921. /**
  66922. * The index of the node to target
  66923. */
  66924. node: number;
  66925. /**
  66926. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66927. */
  66928. path: AnimationChannelTargetPath;
  66929. }
  66930. /**
  66931. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66932. */
  66933. interface IAnimationSampler extends IProperty {
  66934. /**
  66935. * The index of an accessor containing keyframe input values, e.g., time
  66936. */
  66937. input: number;
  66938. /**
  66939. * Interpolation algorithm
  66940. */
  66941. interpolation?: AnimationSamplerInterpolation;
  66942. /**
  66943. * The index of an accessor, containing keyframe output values
  66944. */
  66945. output: number;
  66946. }
  66947. /**
  66948. * A keyframe animation
  66949. */
  66950. interface IAnimation extends IChildRootProperty {
  66951. /**
  66952. * An array of channels, each of which targets an animation's sampler at a node's property
  66953. */
  66954. channels: IAnimationChannel[];
  66955. /**
  66956. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66957. */
  66958. samplers: IAnimationSampler[];
  66959. }
  66960. /**
  66961. * Metadata about the glTF asset
  66962. */
  66963. interface IAsset extends IChildRootProperty {
  66964. /**
  66965. * A copyright message suitable for display to credit the content creator
  66966. */
  66967. copyright?: string;
  66968. /**
  66969. * Tool that generated this glTF model. Useful for debugging
  66970. */
  66971. generator?: string;
  66972. /**
  66973. * The glTF version that this asset targets
  66974. */
  66975. version: string;
  66976. /**
  66977. * The minimum glTF version that this asset targets
  66978. */
  66979. minVersion?: string;
  66980. }
  66981. /**
  66982. * A buffer points to binary geometry, animation, or skins
  66983. */
  66984. interface IBuffer extends IChildRootProperty {
  66985. /**
  66986. * 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
  66987. */
  66988. uri?: string;
  66989. /**
  66990. * The length of the buffer in bytes
  66991. */
  66992. byteLength: number;
  66993. }
  66994. /**
  66995. * A view into a buffer generally representing a subset of the buffer
  66996. */
  66997. interface IBufferView extends IChildRootProperty {
  66998. /**
  66999. * The index of the buffer
  67000. */
  67001. buffer: number;
  67002. /**
  67003. * The offset into the buffer in bytes
  67004. */
  67005. byteOffset?: number;
  67006. /**
  67007. * The lenth of the bufferView in bytes
  67008. */
  67009. byteLength: number;
  67010. /**
  67011. * The stride, in bytes
  67012. */
  67013. byteStride?: number;
  67014. }
  67015. /**
  67016. * An orthographic camera containing properties to create an orthographic projection matrix
  67017. */
  67018. interface ICameraOrthographic extends IProperty {
  67019. /**
  67020. * The floating-point horizontal magnification of the view. Must not be zero
  67021. */
  67022. xmag: number;
  67023. /**
  67024. * The floating-point vertical magnification of the view. Must not be zero
  67025. */
  67026. ymag: number;
  67027. /**
  67028. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67029. */
  67030. zfar: number;
  67031. /**
  67032. * The floating-point distance to the near clipping plane
  67033. */
  67034. znear: number;
  67035. }
  67036. /**
  67037. * A perspective camera containing properties to create a perspective projection matrix
  67038. */
  67039. interface ICameraPerspective extends IProperty {
  67040. /**
  67041. * The floating-point aspect ratio of the field of view
  67042. */
  67043. aspectRatio?: number;
  67044. /**
  67045. * The floating-point vertical field of view in radians
  67046. */
  67047. yfov: number;
  67048. /**
  67049. * The floating-point distance to the far clipping plane
  67050. */
  67051. zfar?: number;
  67052. /**
  67053. * The floating-point distance to the near clipping plane
  67054. */
  67055. znear: number;
  67056. }
  67057. /**
  67058. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67059. */
  67060. interface ICamera extends IChildRootProperty {
  67061. /**
  67062. * An orthographic camera containing properties to create an orthographic projection matrix
  67063. */
  67064. orthographic?: ICameraOrthographic;
  67065. /**
  67066. * A perspective camera containing properties to create a perspective projection matrix
  67067. */
  67068. perspective?: ICameraPerspective;
  67069. /**
  67070. * Specifies if the camera uses a perspective or orthographic projection
  67071. */
  67072. type: CameraType;
  67073. }
  67074. /**
  67075. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67076. */
  67077. interface IImage extends IChildRootProperty {
  67078. /**
  67079. * 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
  67080. */
  67081. uri?: string;
  67082. /**
  67083. * The image's MIME type
  67084. */
  67085. mimeType?: ImageMimeType;
  67086. /**
  67087. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67088. */
  67089. bufferView?: number;
  67090. }
  67091. /**
  67092. * Material Normal Texture Info
  67093. */
  67094. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67095. /**
  67096. * The scalar multiplier applied to each normal vector of the normal texture
  67097. */
  67098. scale?: number;
  67099. }
  67100. /**
  67101. * Material Occlusion Texture Info
  67102. */
  67103. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67104. /**
  67105. * A scalar multiplier controlling the amount of occlusion applied
  67106. */
  67107. strength?: number;
  67108. }
  67109. /**
  67110. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67111. */
  67112. interface IMaterialPbrMetallicRoughness {
  67113. /**
  67114. * The material's base color factor
  67115. */
  67116. baseColorFactor?: number[];
  67117. /**
  67118. * The base color texture
  67119. */
  67120. baseColorTexture?: ITextureInfo;
  67121. /**
  67122. * The metalness of the material
  67123. */
  67124. metallicFactor?: number;
  67125. /**
  67126. * The roughness of the material
  67127. */
  67128. roughnessFactor?: number;
  67129. /**
  67130. * The metallic-roughness texture
  67131. */
  67132. metallicRoughnessTexture?: ITextureInfo;
  67133. }
  67134. /**
  67135. * The material appearance of a primitive
  67136. */
  67137. interface IMaterial extends IChildRootProperty {
  67138. /**
  67139. * 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
  67140. */
  67141. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67142. /**
  67143. * The normal map texture
  67144. */
  67145. normalTexture?: IMaterialNormalTextureInfo;
  67146. /**
  67147. * The occlusion map texture
  67148. */
  67149. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67150. /**
  67151. * The emissive map texture
  67152. */
  67153. emissiveTexture?: ITextureInfo;
  67154. /**
  67155. * 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
  67156. */
  67157. emissiveFactor?: number[];
  67158. /**
  67159. * The alpha rendering mode of the material
  67160. */
  67161. alphaMode?: MaterialAlphaMode;
  67162. /**
  67163. * The alpha cutoff value of the material
  67164. */
  67165. alphaCutoff?: number;
  67166. /**
  67167. * Specifies whether the material is double sided
  67168. */
  67169. doubleSided?: boolean;
  67170. }
  67171. /**
  67172. * Geometry to be rendered with the given material
  67173. */
  67174. interface IMeshPrimitive extends IProperty {
  67175. /**
  67176. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67177. */
  67178. attributes: {
  67179. [name: string]: number;
  67180. };
  67181. /**
  67182. * The index of the accessor that contains the indices
  67183. */
  67184. indices?: number;
  67185. /**
  67186. * The index of the material to apply to this primitive when rendering
  67187. */
  67188. material?: number;
  67189. /**
  67190. * The type of primitives to render. All valid values correspond to WebGL enums
  67191. */
  67192. mode?: MeshPrimitiveMode;
  67193. /**
  67194. * 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
  67195. */
  67196. targets?: {
  67197. [name: string]: number;
  67198. }[];
  67199. }
  67200. /**
  67201. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67202. */
  67203. interface IMesh extends IChildRootProperty {
  67204. /**
  67205. * An array of primitives, each defining geometry to be rendered with a material
  67206. */
  67207. primitives: IMeshPrimitive[];
  67208. /**
  67209. * Array of weights to be applied to the Morph Targets
  67210. */
  67211. weights?: number[];
  67212. }
  67213. /**
  67214. * A node in the node hierarchy
  67215. */
  67216. interface INode extends IChildRootProperty {
  67217. /**
  67218. * The index of the camera referenced by this node
  67219. */
  67220. camera?: number;
  67221. /**
  67222. * The indices of this node's children
  67223. */
  67224. children?: number[];
  67225. /**
  67226. * The index of the skin referenced by this node
  67227. */
  67228. skin?: number;
  67229. /**
  67230. * A floating-point 4x4 transformation matrix stored in column-major order
  67231. */
  67232. matrix?: number[];
  67233. /**
  67234. * The index of the mesh in this node
  67235. */
  67236. mesh?: number;
  67237. /**
  67238. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67239. */
  67240. rotation?: number[];
  67241. /**
  67242. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67243. */
  67244. scale?: number[];
  67245. /**
  67246. * The node's translation along the x, y, and z axes
  67247. */
  67248. translation?: number[];
  67249. /**
  67250. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67251. */
  67252. weights?: number[];
  67253. }
  67254. /**
  67255. * Texture sampler properties for filtering and wrapping modes
  67256. */
  67257. interface ISampler extends IChildRootProperty {
  67258. /**
  67259. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67260. */
  67261. magFilter?: TextureMagFilter;
  67262. /**
  67263. * Minification filter. All valid values correspond to WebGL enums
  67264. */
  67265. minFilter?: TextureMinFilter;
  67266. /**
  67267. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67268. */
  67269. wrapS?: TextureWrapMode;
  67270. /**
  67271. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67272. */
  67273. wrapT?: TextureWrapMode;
  67274. }
  67275. /**
  67276. * The root nodes of a scene
  67277. */
  67278. interface IScene extends IChildRootProperty {
  67279. /**
  67280. * The indices of each root node
  67281. */
  67282. nodes: number[];
  67283. }
  67284. /**
  67285. * Joints and matrices defining a skin
  67286. */
  67287. interface ISkin extends IChildRootProperty {
  67288. /**
  67289. * 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
  67290. */
  67291. inverseBindMatrices?: number;
  67292. /**
  67293. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67294. */
  67295. skeleton?: number;
  67296. /**
  67297. * 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)
  67298. */
  67299. joints: number[];
  67300. }
  67301. /**
  67302. * A texture and its sampler
  67303. */
  67304. interface ITexture extends IChildRootProperty {
  67305. /**
  67306. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67307. */
  67308. sampler?: number;
  67309. /**
  67310. * The index of the image used by this texture
  67311. */
  67312. source: number;
  67313. }
  67314. /**
  67315. * Reference to a texture
  67316. */
  67317. interface ITextureInfo extends IProperty {
  67318. /**
  67319. * The index of the texture
  67320. */
  67321. index: number;
  67322. /**
  67323. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67324. */
  67325. texCoord?: number;
  67326. }
  67327. /**
  67328. * The root object for a glTF asset
  67329. */
  67330. interface IGLTF extends IProperty {
  67331. /**
  67332. * An array of accessors. An accessor is a typed view into a bufferView
  67333. */
  67334. accessors?: IAccessor[];
  67335. /**
  67336. * An array of keyframe animations
  67337. */
  67338. animations?: IAnimation[];
  67339. /**
  67340. * Metadata about the glTF asset
  67341. */
  67342. asset: IAsset;
  67343. /**
  67344. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67345. */
  67346. buffers?: IBuffer[];
  67347. /**
  67348. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67349. */
  67350. bufferViews?: IBufferView[];
  67351. /**
  67352. * An array of cameras
  67353. */
  67354. cameras?: ICamera[];
  67355. /**
  67356. * Names of glTF extensions used somewhere in this asset
  67357. */
  67358. extensionsUsed?: string[];
  67359. /**
  67360. * Names of glTF extensions required to properly load this asset
  67361. */
  67362. extensionsRequired?: string[];
  67363. /**
  67364. * An array of images. An image defines data used to create a texture
  67365. */
  67366. images?: IImage[];
  67367. /**
  67368. * An array of materials. A material defines the appearance of a primitive
  67369. */
  67370. materials?: IMaterial[];
  67371. /**
  67372. * An array of meshes. A mesh is a set of primitives to be rendered
  67373. */
  67374. meshes?: IMesh[];
  67375. /**
  67376. * An array of nodes
  67377. */
  67378. nodes?: INode[];
  67379. /**
  67380. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67381. */
  67382. samplers?: ISampler[];
  67383. /**
  67384. * The index of the default scene
  67385. */
  67386. scene?: number;
  67387. /**
  67388. * An array of scenes
  67389. */
  67390. scenes?: IScene[];
  67391. /**
  67392. * An array of skins. A skin is defined by joints and matrices
  67393. */
  67394. skins?: ISkin[];
  67395. /**
  67396. * An array of textures
  67397. */
  67398. textures?: ITexture[];
  67399. }
  67400. /**
  67401. * The glTF validation results
  67402. */
  67403. interface IGLTFValidationResults {
  67404. info: {
  67405. generator: string;
  67406. hasAnimations: boolean;
  67407. hasDefaultScene: boolean;
  67408. hasMaterials: boolean;
  67409. hasMorphTargets: boolean;
  67410. hasSkins: boolean;
  67411. hasTextures: boolean;
  67412. maxAttributesUsed: number;
  67413. primitivesCount: number
  67414. };
  67415. issues: {
  67416. messages: Array<string>;
  67417. numErrors: number;
  67418. numHints: number;
  67419. numInfos: number;
  67420. numWarnings: number;
  67421. truncated: boolean
  67422. };
  67423. mimeType: string;
  67424. uri: string;
  67425. validatedAt: string;
  67426. validatorVersion: string;
  67427. }
  67428. /**
  67429. * The glTF validation options
  67430. */
  67431. interface IGLTFValidationOptions {
  67432. uri?: string;
  67433. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67434. validateAccessorData?: boolean;
  67435. maxIssues?: number;
  67436. ignoredIssues?: Array<string>;
  67437. severityOverrides?: Object;
  67438. }
  67439. /**
  67440. * The glTF validator object
  67441. */
  67442. interface IGLTFValidator {
  67443. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67444. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67445. }
  67446. }
  67447. declare module BABYLON {
  67448. /** @hidden */
  67449. export var cellPixelShader: {
  67450. name: string;
  67451. shader: string;
  67452. };
  67453. }
  67454. declare module BABYLON {
  67455. /** @hidden */
  67456. export var cellVertexShader: {
  67457. name: string;
  67458. shader: string;
  67459. };
  67460. }
  67461. declare module BABYLON {
  67462. export class CellMaterial extends BABYLON.PushMaterial {
  67463. private _diffuseTexture;
  67464. diffuseTexture: BABYLON.BaseTexture;
  67465. diffuseColor: BABYLON.Color3;
  67466. _computeHighLevel: boolean;
  67467. computeHighLevel: boolean;
  67468. private _disableLighting;
  67469. disableLighting: boolean;
  67470. private _maxSimultaneousLights;
  67471. maxSimultaneousLights: number;
  67472. private _renderId;
  67473. constructor(name: string, scene: BABYLON.Scene);
  67474. needAlphaBlending(): boolean;
  67475. needAlphaTesting(): boolean;
  67476. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67477. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67478. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67479. getAnimatables(): BABYLON.IAnimatable[];
  67480. getActiveTextures(): BABYLON.BaseTexture[];
  67481. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67482. dispose(forceDisposeEffect?: boolean): void;
  67483. getClassName(): string;
  67484. clone(name: string): CellMaterial;
  67485. serialize(): any;
  67486. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67487. }
  67488. }
  67489. declare module BABYLON {
  67490. export class CustomShaderStructure {
  67491. FragmentStore: string;
  67492. VertexStore: string;
  67493. constructor();
  67494. }
  67495. export class ShaderSpecialParts {
  67496. constructor();
  67497. Fragment_Begin: string;
  67498. Fragment_Definitions: string;
  67499. Fragment_MainBegin: string;
  67500. Fragment_Custom_Diffuse: string;
  67501. Fragment_Before_Lights: string;
  67502. Fragment_Before_Fog: string;
  67503. Fragment_Custom_Alpha: string;
  67504. Fragment_Before_FragColor: string;
  67505. Vertex_Begin: string;
  67506. Vertex_Definitions: string;
  67507. Vertex_MainBegin: string;
  67508. Vertex_Before_PositionUpdated: string;
  67509. Vertex_Before_NormalUpdated: string;
  67510. Vertex_MainEnd: string;
  67511. }
  67512. export class CustomMaterial extends BABYLON.StandardMaterial {
  67513. static ShaderIndexer: number;
  67514. CustomParts: ShaderSpecialParts;
  67515. _isCreatedShader: boolean;
  67516. _createdShaderName: string;
  67517. _customUniform: string[];
  67518. _newUniforms: string[];
  67519. _newUniformInstances: any[];
  67520. _newSamplerInstances: BABYLON.Texture[];
  67521. FragmentShader: string;
  67522. VertexShader: string;
  67523. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67524. ReviewUniform(name: string, arr: string[]): string[];
  67525. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67526. constructor(name: string, scene: BABYLON.Scene);
  67527. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67528. Fragment_Begin(shaderPart: string): CustomMaterial;
  67529. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67530. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67531. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67532. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67533. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67534. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67535. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67536. Vertex_Begin(shaderPart: string): CustomMaterial;
  67537. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67538. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67539. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67540. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67541. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67542. }
  67543. }
  67544. declare module BABYLON {
  67545. export class ShaderAlebdoParts {
  67546. constructor();
  67547. Fragment_Begin: string;
  67548. Fragment_Definitions: string;
  67549. Fragment_MainBegin: string;
  67550. Fragment_Custom_Albedo: string;
  67551. Fragment_Before_Lights: string;
  67552. Fragment_Custom_MetallicRoughness: string;
  67553. Fragment_Custom_MicroSurface: string;
  67554. Fragment_Before_Fog: string;
  67555. Fragment_Custom_Alpha: string;
  67556. Fragment_Before_FragColor: string;
  67557. Vertex_Begin: string;
  67558. Vertex_Definitions: string;
  67559. Vertex_MainBegin: string;
  67560. Vertex_Before_PositionUpdated: string;
  67561. Vertex_Before_NormalUpdated: string;
  67562. Vertex_MainEnd: string;
  67563. }
  67564. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67565. static ShaderIndexer: number;
  67566. CustomParts: ShaderAlebdoParts;
  67567. _isCreatedShader: boolean;
  67568. _createdShaderName: string;
  67569. _customUniform: string[];
  67570. _newUniforms: string[];
  67571. _newUniformInstances: any[];
  67572. _newSamplerInstances: BABYLON.Texture[];
  67573. FragmentShader: string;
  67574. VertexShader: string;
  67575. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67576. ReviewUniform(name: string, arr: string[]): string[];
  67577. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67578. constructor(name: string, scene: BABYLON.Scene);
  67579. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67580. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67581. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67582. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67583. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67584. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67585. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67586. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67587. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67588. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67589. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67590. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67591. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67592. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67593. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67594. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67595. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67596. }
  67597. }
  67598. declare module BABYLON {
  67599. /** @hidden */
  67600. export var firePixelShader: {
  67601. name: string;
  67602. shader: string;
  67603. };
  67604. }
  67605. declare module BABYLON {
  67606. /** @hidden */
  67607. export var fireVertexShader: {
  67608. name: string;
  67609. shader: string;
  67610. };
  67611. }
  67612. declare module BABYLON {
  67613. export class FireMaterial extends BABYLON.PushMaterial {
  67614. private _diffuseTexture;
  67615. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67616. private _distortionTexture;
  67617. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67618. private _opacityTexture;
  67619. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67620. diffuseColor: BABYLON.Color3;
  67621. speed: number;
  67622. private _scaledDiffuse;
  67623. private _renderId;
  67624. private _lastTime;
  67625. constructor(name: string, scene: BABYLON.Scene);
  67626. needAlphaBlending(): boolean;
  67627. needAlphaTesting(): boolean;
  67628. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67629. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67630. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67631. getAnimatables(): BABYLON.IAnimatable[];
  67632. getActiveTextures(): BABYLON.BaseTexture[];
  67633. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67634. getClassName(): string;
  67635. dispose(forceDisposeEffect?: boolean): void;
  67636. clone(name: string): FireMaterial;
  67637. serialize(): any;
  67638. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67639. }
  67640. }
  67641. declare module BABYLON {
  67642. /** @hidden */
  67643. export var furPixelShader: {
  67644. name: string;
  67645. shader: string;
  67646. };
  67647. }
  67648. declare module BABYLON {
  67649. /** @hidden */
  67650. export var furVertexShader: {
  67651. name: string;
  67652. shader: string;
  67653. };
  67654. }
  67655. declare module BABYLON {
  67656. export class FurMaterial extends BABYLON.PushMaterial {
  67657. private _diffuseTexture;
  67658. diffuseTexture: BABYLON.BaseTexture;
  67659. private _heightTexture;
  67660. heightTexture: BABYLON.BaseTexture;
  67661. diffuseColor: BABYLON.Color3;
  67662. furLength: number;
  67663. furAngle: number;
  67664. furColor: BABYLON.Color3;
  67665. furOffset: number;
  67666. furSpacing: number;
  67667. furGravity: BABYLON.Vector3;
  67668. furSpeed: number;
  67669. furDensity: number;
  67670. furOcclusion: number;
  67671. furTexture: BABYLON.DynamicTexture;
  67672. private _disableLighting;
  67673. disableLighting: boolean;
  67674. private _maxSimultaneousLights;
  67675. maxSimultaneousLights: number;
  67676. highLevelFur: boolean;
  67677. _meshes: BABYLON.AbstractMesh[];
  67678. private _renderId;
  67679. private _furTime;
  67680. constructor(name: string, scene: BABYLON.Scene);
  67681. furTime: number;
  67682. needAlphaBlending(): boolean;
  67683. needAlphaTesting(): boolean;
  67684. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67685. updateFur(): void;
  67686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67688. getAnimatables(): BABYLON.IAnimatable[];
  67689. getActiveTextures(): BABYLON.BaseTexture[];
  67690. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67691. dispose(forceDisposeEffect?: boolean): void;
  67692. clone(name: string): FurMaterial;
  67693. serialize(): any;
  67694. getClassName(): string;
  67695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67696. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67697. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /** @hidden */
  67702. export var gradientPixelShader: {
  67703. name: string;
  67704. shader: string;
  67705. };
  67706. }
  67707. declare module BABYLON {
  67708. /** @hidden */
  67709. export var gradientVertexShader: {
  67710. name: string;
  67711. shader: string;
  67712. };
  67713. }
  67714. declare module BABYLON {
  67715. export class GradientMaterial extends BABYLON.PushMaterial {
  67716. private _maxSimultaneousLights;
  67717. maxSimultaneousLights: number;
  67718. topColor: BABYLON.Color3;
  67719. topColorAlpha: number;
  67720. bottomColor: BABYLON.Color3;
  67721. bottomColorAlpha: number;
  67722. offset: number;
  67723. scale: number;
  67724. smoothness: number;
  67725. private _disableLighting;
  67726. disableLighting: boolean;
  67727. private _renderId;
  67728. constructor(name: string, scene: BABYLON.Scene);
  67729. needAlphaBlending(): boolean;
  67730. needAlphaTesting(): boolean;
  67731. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67732. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67733. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67734. getAnimatables(): BABYLON.IAnimatable[];
  67735. dispose(forceDisposeEffect?: boolean): void;
  67736. clone(name: string): GradientMaterial;
  67737. serialize(): any;
  67738. getClassName(): string;
  67739. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67740. }
  67741. }
  67742. declare module BABYLON {
  67743. /** @hidden */
  67744. export var gridPixelShader: {
  67745. name: string;
  67746. shader: string;
  67747. };
  67748. }
  67749. declare module BABYLON {
  67750. /** @hidden */
  67751. export var gridVertexShader: {
  67752. name: string;
  67753. shader: string;
  67754. };
  67755. }
  67756. declare module BABYLON {
  67757. /**
  67758. * The grid materials allows you to wrap any shape with a grid.
  67759. * Colors are customizable.
  67760. */
  67761. export class GridMaterial extends BABYLON.PushMaterial {
  67762. /**
  67763. * Main color of the grid (e.g. between lines)
  67764. */
  67765. mainColor: BABYLON.Color3;
  67766. /**
  67767. * Color of the grid lines.
  67768. */
  67769. lineColor: BABYLON.Color3;
  67770. /**
  67771. * The scale of the grid compared to unit.
  67772. */
  67773. gridRatio: number;
  67774. /**
  67775. * Allows setting an offset for the grid lines.
  67776. */
  67777. gridOffset: BABYLON.Vector3;
  67778. /**
  67779. * The frequency of thicker lines.
  67780. */
  67781. majorUnitFrequency: number;
  67782. /**
  67783. * The visibility of minor units in the grid.
  67784. */
  67785. minorUnitVisibility: number;
  67786. /**
  67787. * The grid opacity outside of the lines.
  67788. */
  67789. opacity: number;
  67790. /**
  67791. * Determine RBG output is premultiplied by alpha value.
  67792. */
  67793. preMultiplyAlpha: boolean;
  67794. private _opacityTexture;
  67795. opacityTexture: BABYLON.BaseTexture;
  67796. private _gridControl;
  67797. private _renderId;
  67798. /**
  67799. * constructor
  67800. * @param name The name given to the material in order to identify it afterwards.
  67801. * @param scene The scene the material is used in.
  67802. */
  67803. constructor(name: string, scene: BABYLON.Scene);
  67804. /**
  67805. * Returns wehter or not the grid requires alpha blending.
  67806. */
  67807. needAlphaBlending(): boolean;
  67808. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67809. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67811. /**
  67812. * Dispose the material and its associated resources.
  67813. * @param forceDisposeEffect will also dispose the used effect when true
  67814. */
  67815. dispose(forceDisposeEffect?: boolean): void;
  67816. clone(name: string): GridMaterial;
  67817. serialize(): any;
  67818. getClassName(): string;
  67819. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67820. }
  67821. }
  67822. declare module BABYLON {
  67823. /** @hidden */
  67824. export var lavaPixelShader: {
  67825. name: string;
  67826. shader: string;
  67827. };
  67828. }
  67829. declare module BABYLON {
  67830. /** @hidden */
  67831. export var lavaVertexShader: {
  67832. name: string;
  67833. shader: string;
  67834. };
  67835. }
  67836. declare module BABYLON {
  67837. export class LavaMaterial extends BABYLON.PushMaterial {
  67838. private _diffuseTexture;
  67839. diffuseTexture: BABYLON.BaseTexture;
  67840. noiseTexture: BABYLON.BaseTexture;
  67841. fogColor: BABYLON.Color3;
  67842. speed: number;
  67843. movingSpeed: number;
  67844. lowFrequencySpeed: number;
  67845. fogDensity: number;
  67846. private _lastTime;
  67847. diffuseColor: BABYLON.Color3;
  67848. private _disableLighting;
  67849. disableLighting: boolean;
  67850. private _unlit;
  67851. unlit: boolean;
  67852. private _maxSimultaneousLights;
  67853. maxSimultaneousLights: number;
  67854. private _scaledDiffuse;
  67855. private _renderId;
  67856. constructor(name: string, scene: BABYLON.Scene);
  67857. needAlphaBlending(): boolean;
  67858. needAlphaTesting(): boolean;
  67859. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67860. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67861. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67862. getAnimatables(): BABYLON.IAnimatable[];
  67863. getActiveTextures(): BABYLON.BaseTexture[];
  67864. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67865. dispose(forceDisposeEffect?: boolean): void;
  67866. clone(name: string): LavaMaterial;
  67867. serialize(): any;
  67868. getClassName(): string;
  67869. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67870. }
  67871. }
  67872. declare module BABYLON {
  67873. /** @hidden */
  67874. export var mixPixelShader: {
  67875. name: string;
  67876. shader: string;
  67877. };
  67878. }
  67879. declare module BABYLON {
  67880. /** @hidden */
  67881. export var mixVertexShader: {
  67882. name: string;
  67883. shader: string;
  67884. };
  67885. }
  67886. declare module BABYLON {
  67887. export class MixMaterial extends BABYLON.PushMaterial {
  67888. /**
  67889. * Mix textures
  67890. */
  67891. private _mixTexture1;
  67892. mixTexture1: BABYLON.BaseTexture;
  67893. private _mixTexture2;
  67894. mixTexture2: BABYLON.BaseTexture;
  67895. /**
  67896. * Diffuse textures
  67897. */
  67898. private _diffuseTexture1;
  67899. diffuseTexture1: BABYLON.Texture;
  67900. private _diffuseTexture2;
  67901. diffuseTexture2: BABYLON.Texture;
  67902. private _diffuseTexture3;
  67903. diffuseTexture3: BABYLON.Texture;
  67904. private _diffuseTexture4;
  67905. diffuseTexture4: BABYLON.Texture;
  67906. private _diffuseTexture5;
  67907. diffuseTexture5: BABYLON.Texture;
  67908. private _diffuseTexture6;
  67909. diffuseTexture6: BABYLON.Texture;
  67910. private _diffuseTexture7;
  67911. diffuseTexture7: BABYLON.Texture;
  67912. private _diffuseTexture8;
  67913. diffuseTexture8: BABYLON.Texture;
  67914. /**
  67915. * Uniforms
  67916. */
  67917. diffuseColor: BABYLON.Color3;
  67918. specularColor: BABYLON.Color3;
  67919. specularPower: number;
  67920. private _disableLighting;
  67921. disableLighting: boolean;
  67922. private _maxSimultaneousLights;
  67923. maxSimultaneousLights: number;
  67924. private _renderId;
  67925. constructor(name: string, scene: BABYLON.Scene);
  67926. needAlphaBlending(): boolean;
  67927. needAlphaTesting(): boolean;
  67928. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67929. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67930. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67931. getAnimatables(): BABYLON.IAnimatable[];
  67932. getActiveTextures(): BABYLON.BaseTexture[];
  67933. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67934. dispose(forceDisposeEffect?: boolean): void;
  67935. clone(name: string): MixMaterial;
  67936. serialize(): any;
  67937. getClassName(): string;
  67938. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /** @hidden */
  67943. export var normalPixelShader: {
  67944. name: string;
  67945. shader: string;
  67946. };
  67947. }
  67948. declare module BABYLON {
  67949. /** @hidden */
  67950. export var normalVertexShader: {
  67951. name: string;
  67952. shader: string;
  67953. };
  67954. }
  67955. declare module BABYLON {
  67956. export class NormalMaterial extends BABYLON.PushMaterial {
  67957. private _diffuseTexture;
  67958. diffuseTexture: BABYLON.BaseTexture;
  67959. diffuseColor: BABYLON.Color3;
  67960. private _disableLighting;
  67961. disableLighting: boolean;
  67962. private _maxSimultaneousLights;
  67963. maxSimultaneousLights: number;
  67964. private _renderId;
  67965. constructor(name: string, scene: BABYLON.Scene);
  67966. needAlphaBlending(): boolean;
  67967. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67968. needAlphaTesting(): boolean;
  67969. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67970. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67971. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67972. getAnimatables(): BABYLON.IAnimatable[];
  67973. getActiveTextures(): BABYLON.BaseTexture[];
  67974. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67975. dispose(forceDisposeEffect?: boolean): void;
  67976. clone(name: string): NormalMaterial;
  67977. serialize(): any;
  67978. getClassName(): string;
  67979. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67980. }
  67981. }
  67982. declare module BABYLON {
  67983. /** @hidden */
  67984. export var shadowOnlyPixelShader: {
  67985. name: string;
  67986. shader: string;
  67987. };
  67988. }
  67989. declare module BABYLON {
  67990. /** @hidden */
  67991. export var shadowOnlyVertexShader: {
  67992. name: string;
  67993. shader: string;
  67994. };
  67995. }
  67996. declare module BABYLON {
  67997. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67998. private _renderId;
  67999. private _activeLight;
  68000. constructor(name: string, scene: BABYLON.Scene);
  68001. shadowColor: BABYLON.Color3;
  68002. needAlphaBlending(): boolean;
  68003. needAlphaTesting(): boolean;
  68004. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68005. activeLight: BABYLON.IShadowLight;
  68006. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68007. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68008. clone(name: string): ShadowOnlyMaterial;
  68009. serialize(): any;
  68010. getClassName(): string;
  68011. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68012. }
  68013. }
  68014. declare module BABYLON {
  68015. /** @hidden */
  68016. export var simplePixelShader: {
  68017. name: string;
  68018. shader: string;
  68019. };
  68020. }
  68021. declare module BABYLON {
  68022. /** @hidden */
  68023. export var simpleVertexShader: {
  68024. name: string;
  68025. shader: string;
  68026. };
  68027. }
  68028. declare module BABYLON {
  68029. export class SimpleMaterial extends BABYLON.PushMaterial {
  68030. private _diffuseTexture;
  68031. diffuseTexture: BABYLON.BaseTexture;
  68032. diffuseColor: BABYLON.Color3;
  68033. private _disableLighting;
  68034. disableLighting: boolean;
  68035. private _maxSimultaneousLights;
  68036. maxSimultaneousLights: number;
  68037. private _renderId;
  68038. constructor(name: string, scene: BABYLON.Scene);
  68039. needAlphaBlending(): boolean;
  68040. needAlphaTesting(): boolean;
  68041. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68042. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68044. getAnimatables(): BABYLON.IAnimatable[];
  68045. getActiveTextures(): BABYLON.BaseTexture[];
  68046. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68047. dispose(forceDisposeEffect?: boolean): void;
  68048. clone(name: string): SimpleMaterial;
  68049. serialize(): any;
  68050. getClassName(): string;
  68051. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68052. }
  68053. }
  68054. declare module BABYLON {
  68055. /** @hidden */
  68056. export var skyPixelShader: {
  68057. name: string;
  68058. shader: string;
  68059. };
  68060. }
  68061. declare module BABYLON {
  68062. /** @hidden */
  68063. export var skyVertexShader: {
  68064. name: string;
  68065. shader: string;
  68066. };
  68067. }
  68068. declare module BABYLON {
  68069. /**
  68070. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68071. * @see https://doc.babylonjs.com/extensions/sky
  68072. */
  68073. export class SkyMaterial extends BABYLON.PushMaterial {
  68074. /**
  68075. * Defines the overall luminance of sky in interval ]0, 1[.
  68076. */
  68077. luminance: number;
  68078. /**
  68079. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68080. */
  68081. turbidity: number;
  68082. /**
  68083. * Defines the sky appearance (light intensity).
  68084. */
  68085. rayleigh: number;
  68086. /**
  68087. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68088. */
  68089. mieCoefficient: number;
  68090. /**
  68091. * Defines the amount of haze particles following the Mie scattering theory.
  68092. */
  68093. mieDirectionalG: number;
  68094. /**
  68095. * Defines the distance of the sun according to the active scene camera.
  68096. */
  68097. distance: number;
  68098. /**
  68099. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68100. * "inclined".
  68101. */
  68102. inclination: number;
  68103. /**
  68104. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68105. * an object direction and a reference direction.
  68106. */
  68107. azimuth: number;
  68108. /**
  68109. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68110. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68111. */
  68112. sunPosition: BABYLON.Vector3;
  68113. /**
  68114. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68115. * .sunPosition property.
  68116. */
  68117. useSunPosition: boolean;
  68118. /**
  68119. * Defines an offset vector used to get a horizon offset.
  68120. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68121. */
  68122. cameraOffset: BABYLON.Vector3;
  68123. private _cameraPosition;
  68124. private _renderId;
  68125. /**
  68126. * Instantiates a new sky material.
  68127. * This material allows to create dynamic and texture free
  68128. * effects for skyboxes by taking care of the atmosphere state.
  68129. * @see https://doc.babylonjs.com/extensions/sky
  68130. * @param name Define the name of the material in the scene
  68131. * @param scene Define the scene the material belong to
  68132. */
  68133. constructor(name: string, scene: BABYLON.Scene);
  68134. /**
  68135. * Specifies if the material will require alpha blending
  68136. * @returns a boolean specifying if alpha blending is needed
  68137. */
  68138. needAlphaBlending(): boolean;
  68139. /**
  68140. * Specifies if this material should be rendered in alpha test mode
  68141. * @returns false as the sky material doesn't need alpha testing.
  68142. */
  68143. needAlphaTesting(): boolean;
  68144. /**
  68145. * Get the texture used for alpha test purpose.
  68146. * @returns null as the sky material has no texture.
  68147. */
  68148. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68149. /**
  68150. * Get if the submesh is ready to be used and all its information available.
  68151. * Child classes can use it to update shaders
  68152. * @param mesh defines the mesh to check
  68153. * @param subMesh defines which submesh to check
  68154. * @param useInstances specifies that instances should be used
  68155. * @returns a boolean indicating that the submesh is ready or not
  68156. */
  68157. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68158. /**
  68159. * Binds the submesh to this material by preparing the effect and shader to draw
  68160. * @param world defines the world transformation matrix
  68161. * @param mesh defines the mesh containing the submesh
  68162. * @param subMesh defines the submesh to bind the material to
  68163. */
  68164. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68165. /**
  68166. * Get the list of animatables in the material.
  68167. * @returns the list of animatables object used in the material
  68168. */
  68169. getAnimatables(): BABYLON.IAnimatable[];
  68170. /**
  68171. * Disposes the material
  68172. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68173. */
  68174. dispose(forceDisposeEffect?: boolean): void;
  68175. /**
  68176. * Makes a duplicate of the material, and gives it a new name
  68177. * @param name defines the new name for the duplicated material
  68178. * @returns the cloned material
  68179. */
  68180. clone(name: string): SkyMaterial;
  68181. /**
  68182. * Serializes this material in a JSON representation
  68183. * @returns the serialized material object
  68184. */
  68185. serialize(): any;
  68186. /**
  68187. * Gets the current class name of the material e.g. "SkyMaterial"
  68188. * Mainly use in serialization.
  68189. * @returns the class name
  68190. */
  68191. getClassName(): string;
  68192. /**
  68193. * Creates a sky material from parsed material data
  68194. * @param source defines the JSON representation of the material
  68195. * @param scene defines the hosting scene
  68196. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68197. * @returns a new sky material
  68198. */
  68199. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68200. }
  68201. }
  68202. declare module BABYLON {
  68203. /** @hidden */
  68204. export var terrainPixelShader: {
  68205. name: string;
  68206. shader: string;
  68207. };
  68208. }
  68209. declare module BABYLON {
  68210. /** @hidden */
  68211. export var terrainVertexShader: {
  68212. name: string;
  68213. shader: string;
  68214. };
  68215. }
  68216. declare module BABYLON {
  68217. export class TerrainMaterial extends BABYLON.PushMaterial {
  68218. private _mixTexture;
  68219. mixTexture: BABYLON.BaseTexture;
  68220. private _diffuseTexture1;
  68221. diffuseTexture1: BABYLON.Texture;
  68222. private _diffuseTexture2;
  68223. diffuseTexture2: BABYLON.Texture;
  68224. private _diffuseTexture3;
  68225. diffuseTexture3: BABYLON.Texture;
  68226. private _bumpTexture1;
  68227. bumpTexture1: BABYLON.Texture;
  68228. private _bumpTexture2;
  68229. bumpTexture2: BABYLON.Texture;
  68230. private _bumpTexture3;
  68231. bumpTexture3: BABYLON.Texture;
  68232. diffuseColor: BABYLON.Color3;
  68233. specularColor: BABYLON.Color3;
  68234. specularPower: number;
  68235. private _disableLighting;
  68236. disableLighting: boolean;
  68237. private _maxSimultaneousLights;
  68238. maxSimultaneousLights: number;
  68239. private _renderId;
  68240. constructor(name: string, scene: BABYLON.Scene);
  68241. needAlphaBlending(): boolean;
  68242. needAlphaTesting(): boolean;
  68243. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68244. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68245. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68246. getAnimatables(): BABYLON.IAnimatable[];
  68247. getActiveTextures(): BABYLON.BaseTexture[];
  68248. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68249. dispose(forceDisposeEffect?: boolean): void;
  68250. clone(name: string): TerrainMaterial;
  68251. serialize(): any;
  68252. getClassName(): string;
  68253. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68254. }
  68255. }
  68256. declare module BABYLON {
  68257. /** @hidden */
  68258. export var triplanarPixelShader: {
  68259. name: string;
  68260. shader: string;
  68261. };
  68262. }
  68263. declare module BABYLON {
  68264. /** @hidden */
  68265. export var triplanarVertexShader: {
  68266. name: string;
  68267. shader: string;
  68268. };
  68269. }
  68270. declare module BABYLON {
  68271. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68272. mixTexture: BABYLON.BaseTexture;
  68273. private _diffuseTextureX;
  68274. diffuseTextureX: BABYLON.BaseTexture;
  68275. private _diffuseTextureY;
  68276. diffuseTextureY: BABYLON.BaseTexture;
  68277. private _diffuseTextureZ;
  68278. diffuseTextureZ: BABYLON.BaseTexture;
  68279. private _normalTextureX;
  68280. normalTextureX: BABYLON.BaseTexture;
  68281. private _normalTextureY;
  68282. normalTextureY: BABYLON.BaseTexture;
  68283. private _normalTextureZ;
  68284. normalTextureZ: BABYLON.BaseTexture;
  68285. tileSize: number;
  68286. diffuseColor: BABYLON.Color3;
  68287. specularColor: BABYLON.Color3;
  68288. specularPower: number;
  68289. private _disableLighting;
  68290. disableLighting: boolean;
  68291. private _maxSimultaneousLights;
  68292. maxSimultaneousLights: number;
  68293. private _renderId;
  68294. constructor(name: string, scene: BABYLON.Scene);
  68295. needAlphaBlending(): boolean;
  68296. needAlphaTesting(): boolean;
  68297. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68298. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68299. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68300. getAnimatables(): BABYLON.IAnimatable[];
  68301. getActiveTextures(): BABYLON.BaseTexture[];
  68302. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68303. dispose(forceDisposeEffect?: boolean): void;
  68304. clone(name: string): TriPlanarMaterial;
  68305. serialize(): any;
  68306. getClassName(): string;
  68307. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68308. }
  68309. }
  68310. declare module BABYLON {
  68311. /** @hidden */
  68312. export var waterPixelShader: {
  68313. name: string;
  68314. shader: string;
  68315. };
  68316. }
  68317. declare module BABYLON {
  68318. /** @hidden */
  68319. export var waterVertexShader: {
  68320. name: string;
  68321. shader: string;
  68322. };
  68323. }
  68324. declare module BABYLON {
  68325. export class WaterMaterial extends BABYLON.PushMaterial {
  68326. renderTargetSize: BABYLON.Vector2;
  68327. private _bumpTexture;
  68328. bumpTexture: BABYLON.BaseTexture;
  68329. diffuseColor: BABYLON.Color3;
  68330. specularColor: BABYLON.Color3;
  68331. specularPower: number;
  68332. private _disableLighting;
  68333. disableLighting: boolean;
  68334. private _maxSimultaneousLights;
  68335. maxSimultaneousLights: number;
  68336. /**
  68337. * @param {number}: Represents the wind force
  68338. */
  68339. windForce: number;
  68340. /**
  68341. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68342. */
  68343. windDirection: BABYLON.Vector2;
  68344. /**
  68345. * @param {number}: Wave height, represents the height of the waves
  68346. */
  68347. waveHeight: number;
  68348. /**
  68349. * @param {number}: Bump height, represents the bump height related to the bump map
  68350. */
  68351. bumpHeight: number;
  68352. /**
  68353. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68354. */
  68355. private _bumpSuperimpose;
  68356. bumpSuperimpose: boolean;
  68357. /**
  68358. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68359. */
  68360. private _fresnelSeparate;
  68361. fresnelSeparate: boolean;
  68362. /**
  68363. * @param {boolean}: bump Waves modify the reflection.
  68364. */
  68365. private _bumpAffectsReflection;
  68366. bumpAffectsReflection: boolean;
  68367. /**
  68368. * @param {number}: The water color blended with the refraction (near)
  68369. */
  68370. waterColor: BABYLON.Color3;
  68371. /**
  68372. * @param {number}: The blend factor related to the water color
  68373. */
  68374. colorBlendFactor: number;
  68375. /**
  68376. * @param {number}: The water color blended with the reflection (far)
  68377. */
  68378. waterColor2: BABYLON.Color3;
  68379. /**
  68380. * @param {number}: The blend factor related to the water color (reflection, far)
  68381. */
  68382. colorBlendFactor2: number;
  68383. /**
  68384. * @param {number}: Represents the maximum length of a wave
  68385. */
  68386. waveLength: number;
  68387. /**
  68388. * @param {number}: Defines the waves speed
  68389. */
  68390. waveSpeed: number;
  68391. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68392. private _mesh;
  68393. private _refractionRTT;
  68394. private _reflectionRTT;
  68395. private _reflectionTransform;
  68396. private _lastTime;
  68397. private _lastDeltaTime;
  68398. private _renderId;
  68399. private _useLogarithmicDepth;
  68400. private _waitingRenderList;
  68401. /**
  68402. * Gets a boolean indicating that current material needs to register RTT
  68403. */
  68404. readonly hasRenderTargetTextures: boolean;
  68405. /**
  68406. * Constructor
  68407. */
  68408. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68409. useLogarithmicDepth: boolean;
  68410. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68411. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68412. addToRenderList(node: any): void;
  68413. enableRenderTargets(enable: boolean): void;
  68414. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68415. readonly renderTargetsEnabled: boolean;
  68416. needAlphaBlending(): boolean;
  68417. needAlphaTesting(): boolean;
  68418. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68419. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68420. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68421. private _createRenderTargets;
  68422. getAnimatables(): BABYLON.IAnimatable[];
  68423. getActiveTextures(): BABYLON.BaseTexture[];
  68424. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68425. dispose(forceDisposeEffect?: boolean): void;
  68426. clone(name: string): WaterMaterial;
  68427. serialize(): any;
  68428. getClassName(): string;
  68429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68430. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68431. }
  68432. }
  68433. declare module BABYLON {
  68434. /** @hidden */
  68435. export var asciiartPixelShader: {
  68436. name: string;
  68437. shader: string;
  68438. };
  68439. }
  68440. declare module BABYLON {
  68441. /**
  68442. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68443. *
  68444. * It basically takes care rendering the font front the given font size to a texture.
  68445. * This is used later on in the postprocess.
  68446. */
  68447. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68448. private _font;
  68449. private _text;
  68450. private _charSize;
  68451. /**
  68452. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68453. */
  68454. readonly charSize: number;
  68455. /**
  68456. * Create a new instance of the Ascii Art FontTexture class
  68457. * @param name the name of the texture
  68458. * @param font the font to use, use the W3C CSS notation
  68459. * @param text the caracter set to use in the rendering.
  68460. * @param scene the scene that owns the texture
  68461. */
  68462. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68463. /**
  68464. * Gets the max char width of a font.
  68465. * @param font the font to use, use the W3C CSS notation
  68466. * @return the max char width
  68467. */
  68468. private getFontWidth;
  68469. /**
  68470. * Gets the max char height of a font.
  68471. * @param font the font to use, use the W3C CSS notation
  68472. * @return the max char height
  68473. */
  68474. private getFontHeight;
  68475. /**
  68476. * Clones the current AsciiArtTexture.
  68477. * @return the clone of the texture.
  68478. */
  68479. clone(): AsciiArtFontTexture;
  68480. /**
  68481. * Parses a json object representing the texture and returns an instance of it.
  68482. * @param source the source JSON representation
  68483. * @param scene the scene to create the texture for
  68484. * @return the parsed texture
  68485. */
  68486. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68487. }
  68488. /**
  68489. * Option available in the Ascii Art Post Process.
  68490. */
  68491. export interface IAsciiArtPostProcessOptions {
  68492. /**
  68493. * The font to use following the w3c font definition.
  68494. */
  68495. font?: string;
  68496. /**
  68497. * The character set to use in the postprocess.
  68498. */
  68499. characterSet?: string;
  68500. /**
  68501. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68502. * This number is defined between 0 and 1;
  68503. */
  68504. mixToTile?: number;
  68505. /**
  68506. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68507. * This number is defined between 0 and 1;
  68508. */
  68509. mixToNormal?: number;
  68510. }
  68511. /**
  68512. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68513. *
  68514. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68515. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68516. */
  68517. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68518. /**
  68519. * The font texture used to render the char in the post process.
  68520. */
  68521. private _asciiArtFontTexture;
  68522. /**
  68523. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68524. * This number is defined between 0 and 1;
  68525. */
  68526. mixToTile: number;
  68527. /**
  68528. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68529. * This number is defined between 0 and 1;
  68530. */
  68531. mixToNormal: number;
  68532. /**
  68533. * Instantiates a new Ascii Art Post Process.
  68534. * @param name the name to give to the postprocess
  68535. * @camera the camera to apply the post process to.
  68536. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68537. */
  68538. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68539. }
  68540. }
  68541. declare module BABYLON {
  68542. /** @hidden */
  68543. export var digitalrainPixelShader: {
  68544. name: string;
  68545. shader: string;
  68546. };
  68547. }
  68548. declare module BABYLON {
  68549. /**
  68550. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68551. *
  68552. * It basically takes care rendering the font front the given font size to a texture.
  68553. * This is used later on in the postprocess.
  68554. */
  68555. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68556. private _font;
  68557. private _text;
  68558. private _charSize;
  68559. /**
  68560. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68561. */
  68562. readonly charSize: number;
  68563. /**
  68564. * Create a new instance of the Digital Rain FontTexture class
  68565. * @param name the name of the texture
  68566. * @param font the font to use, use the W3C CSS notation
  68567. * @param text the caracter set to use in the rendering.
  68568. * @param scene the scene that owns the texture
  68569. */
  68570. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68571. /**
  68572. * Gets the max char width of a font.
  68573. * @param font the font to use, use the W3C CSS notation
  68574. * @return the max char width
  68575. */
  68576. private getFontWidth;
  68577. /**
  68578. * Gets the max char height of a font.
  68579. * @param font the font to use, use the W3C CSS notation
  68580. * @return the max char height
  68581. */
  68582. private getFontHeight;
  68583. /**
  68584. * Clones the current DigitalRainFontTexture.
  68585. * @return the clone of the texture.
  68586. */
  68587. clone(): DigitalRainFontTexture;
  68588. /**
  68589. * Parses a json object representing the texture and returns an instance of it.
  68590. * @param source the source JSON representation
  68591. * @param scene the scene to create the texture for
  68592. * @return the parsed texture
  68593. */
  68594. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68595. }
  68596. /**
  68597. * Option available in the Digital Rain Post Process.
  68598. */
  68599. export interface IDigitalRainPostProcessOptions {
  68600. /**
  68601. * The font to use following the w3c font definition.
  68602. */
  68603. font?: string;
  68604. /**
  68605. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68606. * This number is defined between 0 and 1;
  68607. */
  68608. mixToTile?: number;
  68609. /**
  68610. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68611. * This number is defined between 0 and 1;
  68612. */
  68613. mixToNormal?: number;
  68614. }
  68615. /**
  68616. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68617. *
  68618. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68619. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68620. */
  68621. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68622. /**
  68623. * The font texture used to render the char in the post process.
  68624. */
  68625. private _digitalRainFontTexture;
  68626. /**
  68627. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68628. * This number is defined between 0 and 1;
  68629. */
  68630. mixToTile: number;
  68631. /**
  68632. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68633. * This number is defined between 0 and 1;
  68634. */
  68635. mixToNormal: number;
  68636. /**
  68637. * Instantiates a new Digital Rain Post Process.
  68638. * @param name the name to give to the postprocess
  68639. * @camera the camera to apply the post process to.
  68640. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68641. */
  68642. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68643. }
  68644. }
  68645. declare module BABYLON {
  68646. /** @hidden */
  68647. export var oceanPostProcessPixelShader: {
  68648. name: string;
  68649. shader: string;
  68650. };
  68651. }
  68652. declare module BABYLON {
  68653. /**
  68654. * Option available in the Ocean Post Process.
  68655. */
  68656. export interface IOceanPostProcessOptions {
  68657. /**
  68658. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68659. */
  68660. reflectionSize?: number | {
  68661. width: number;
  68662. height: number;
  68663. } | {
  68664. ratio: number;
  68665. };
  68666. /**
  68667. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68668. */
  68669. refractionSize?: number | {
  68670. width: number;
  68671. height: number;
  68672. } | {
  68673. ratio: number;
  68674. };
  68675. }
  68676. /**
  68677. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68678. *
  68679. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68680. * Example usage:
  68681. * var pp = new OceanPostProcess("myOcean", camera);
  68682. * pp.reflectionEnabled = true;
  68683. * pp.refractionEnabled = true;
  68684. */
  68685. export class OceanPostProcess extends BABYLON.PostProcess {
  68686. /**
  68687. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68688. */
  68689. /**
  68690. * Sets weither or not the real-time reflection is enabled on the ocean.
  68691. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68692. */
  68693. reflectionEnabled: boolean;
  68694. /**
  68695. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68696. */
  68697. /**
  68698. * Sets weither or not the real-time refraction is enabled on the ocean.
  68699. * Is set to true, the refraction render target texture will be used as refraction texture.
  68700. */
  68701. refractionEnabled: boolean;
  68702. /**
  68703. * Gets wether or not the post-processes is supported by the running hardware.
  68704. * This requires draw buffer supports.
  68705. */
  68706. readonly isSupported: boolean;
  68707. /**
  68708. * This is the reflection mirror texture used to display reflections on the ocean.
  68709. * By default, render list is empty.
  68710. */
  68711. reflectionTexture: BABYLON.MirrorTexture;
  68712. /**
  68713. * This is the refraction render target texture used to display refraction on the ocean.
  68714. * By default, render list is empty.
  68715. */
  68716. refractionTexture: BABYLON.RenderTargetTexture;
  68717. private _time;
  68718. private _cameraRotation;
  68719. private _cameraViewMatrix;
  68720. private _reflectionEnabled;
  68721. private _refractionEnabled;
  68722. private _geometryRenderer;
  68723. /**
  68724. * Instantiates a new Ocean Post Process.
  68725. * @param name the name to give to the postprocess.
  68726. * @camera the camera to apply the post process to.
  68727. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68728. */
  68729. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68730. /**
  68731. * Returns the appropriate defines according to the current configuration.
  68732. */
  68733. private _getDefines;
  68734. /**
  68735. * Computes the current camera rotation as the shader requires a camera rotation.
  68736. */
  68737. private _computeCameraRotation;
  68738. }
  68739. }
  68740. declare module BABYLON {
  68741. /** @hidden */
  68742. export var brickProceduralTexturePixelShader: {
  68743. name: string;
  68744. shader: string;
  68745. };
  68746. }
  68747. declare module BABYLON {
  68748. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68749. private _numberOfBricksHeight;
  68750. private _numberOfBricksWidth;
  68751. private _jointColor;
  68752. private _brickColor;
  68753. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68754. updateShaderUniforms(): void;
  68755. numberOfBricksHeight: number;
  68756. numberOfBricksWidth: number;
  68757. jointColor: BABYLON.Color3;
  68758. brickColor: BABYLON.Color3;
  68759. /**
  68760. * Serializes this brick procedural texture
  68761. * @returns a serialized brick procedural texture object
  68762. */
  68763. serialize(): any;
  68764. /**
  68765. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68766. * @param parsedTexture defines parsed texture data
  68767. * @param scene defines the current scene
  68768. * @param rootUrl defines the root URL containing brick procedural texture information
  68769. * @returns a parsed Brick Procedural BABYLON.Texture
  68770. */
  68771. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /** @hidden */
  68776. export var cloudProceduralTexturePixelShader: {
  68777. name: string;
  68778. shader: string;
  68779. };
  68780. }
  68781. declare module BABYLON {
  68782. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68783. private _skyColor;
  68784. private _cloudColor;
  68785. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68786. updateShaderUniforms(): void;
  68787. skyColor: BABYLON.Color4;
  68788. cloudColor: BABYLON.Color4;
  68789. /**
  68790. * Serializes this cloud procedural texture
  68791. * @returns a serialized cloud procedural texture object
  68792. */
  68793. serialize(): any;
  68794. /**
  68795. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68796. * @param parsedTexture defines parsed texture data
  68797. * @param scene defines the current scene
  68798. * @param rootUrl defines the root URL containing cloud procedural texture information
  68799. * @returns a parsed Cloud Procedural BABYLON.Texture
  68800. */
  68801. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68802. }
  68803. }
  68804. declare module BABYLON {
  68805. /** @hidden */
  68806. export var fireProceduralTexturePixelShader: {
  68807. name: string;
  68808. shader: string;
  68809. };
  68810. }
  68811. declare module BABYLON {
  68812. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68813. private _time;
  68814. private _speed;
  68815. private _autoGenerateTime;
  68816. private _fireColors;
  68817. private _alphaThreshold;
  68818. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68819. updateShaderUniforms(): void;
  68820. render(useCameraPostProcess?: boolean): void;
  68821. static readonly PurpleFireColors: BABYLON.Color3[];
  68822. static readonly GreenFireColors: BABYLON.Color3[];
  68823. static readonly RedFireColors: BABYLON.Color3[];
  68824. static readonly BlueFireColors: BABYLON.Color3[];
  68825. autoGenerateTime: boolean;
  68826. fireColors: BABYLON.Color3[];
  68827. time: number;
  68828. speed: BABYLON.Vector2;
  68829. alphaThreshold: number;
  68830. /**
  68831. * Serializes this fire procedural texture
  68832. * @returns a serialized fire procedural texture object
  68833. */
  68834. serialize(): any;
  68835. /**
  68836. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68837. * @param parsedTexture defines parsed texture data
  68838. * @param scene defines the current scene
  68839. * @param rootUrl defines the root URL containing fire procedural texture information
  68840. * @returns a parsed Fire Procedural BABYLON.Texture
  68841. */
  68842. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68843. }
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export var grassProceduralTexturePixelShader: {
  68848. name: string;
  68849. shader: string;
  68850. };
  68851. }
  68852. declare module BABYLON {
  68853. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68854. private _grassColors;
  68855. private _groundColor;
  68856. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68857. updateShaderUniforms(): void;
  68858. grassColors: BABYLON.Color3[];
  68859. groundColor: BABYLON.Color3;
  68860. /**
  68861. * Serializes this grass procedural texture
  68862. * @returns a serialized grass procedural texture object
  68863. */
  68864. serialize(): any;
  68865. /**
  68866. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68867. * @param parsedTexture defines parsed texture data
  68868. * @param scene defines the current scene
  68869. * @param rootUrl defines the root URL containing grass procedural texture information
  68870. * @returns a parsed Grass Procedural BABYLON.Texture
  68871. */
  68872. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68873. }
  68874. }
  68875. declare module BABYLON {
  68876. /** @hidden */
  68877. export var marbleProceduralTexturePixelShader: {
  68878. name: string;
  68879. shader: string;
  68880. };
  68881. }
  68882. declare module BABYLON {
  68883. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68884. private _numberOfTilesHeight;
  68885. private _numberOfTilesWidth;
  68886. private _amplitude;
  68887. private _jointColor;
  68888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68889. updateShaderUniforms(): void;
  68890. numberOfTilesHeight: number;
  68891. amplitude: number;
  68892. numberOfTilesWidth: number;
  68893. jointColor: BABYLON.Color3;
  68894. /**
  68895. * Serializes this marble procedural texture
  68896. * @returns a serialized marble procedural texture object
  68897. */
  68898. serialize(): any;
  68899. /**
  68900. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68901. * @param parsedTexture defines parsed texture data
  68902. * @param scene defines the current scene
  68903. * @param rootUrl defines the root URL containing marble procedural texture information
  68904. * @returns a parsed Marble Procedural BABYLON.Texture
  68905. */
  68906. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68907. }
  68908. }
  68909. declare module BABYLON {
  68910. /** @hidden */
  68911. export var normalMapProceduralTexturePixelShader: {
  68912. name: string;
  68913. shader: string;
  68914. };
  68915. }
  68916. declare module BABYLON {
  68917. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68918. private _baseTexture;
  68919. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68920. updateShaderUniforms(): void;
  68921. render(useCameraPostProcess?: boolean): void;
  68922. resize(size: any, generateMipMaps: any): void;
  68923. baseTexture: BABYLON.Texture;
  68924. /**
  68925. * Serializes this normal map procedural texture
  68926. * @returns a serialized normal map procedural texture object
  68927. */
  68928. serialize(): any;
  68929. /**
  68930. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68931. * @param parsedTexture defines parsed texture data
  68932. * @param scene defines the current scene
  68933. * @param rootUrl defines the root URL containing normal map procedural texture information
  68934. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68935. */
  68936. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68937. }
  68938. }
  68939. declare module BABYLON {
  68940. /** @hidden */
  68941. export var perlinNoiseProceduralTexturePixelShader: {
  68942. name: string;
  68943. shader: string;
  68944. };
  68945. }
  68946. declare module BABYLON {
  68947. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68948. time: number;
  68949. timeScale: number;
  68950. translationSpeed: number;
  68951. private _currentTranslation;
  68952. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68953. updateShaderUniforms(): void;
  68954. render(useCameraPostProcess?: boolean): void;
  68955. resize(size: any, generateMipMaps: any): void;
  68956. /**
  68957. * Serializes this perlin noise procedural texture
  68958. * @returns a serialized perlin noise procedural texture object
  68959. */
  68960. serialize(): any;
  68961. /**
  68962. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68963. * @param parsedTexture defines parsed texture data
  68964. * @param scene defines the current scene
  68965. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68966. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68967. */
  68968. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /** @hidden */
  68973. export var roadProceduralTexturePixelShader: {
  68974. name: string;
  68975. shader: string;
  68976. };
  68977. }
  68978. declare module BABYLON {
  68979. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68980. private _roadColor;
  68981. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68982. updateShaderUniforms(): void;
  68983. roadColor: BABYLON.Color3;
  68984. /**
  68985. * Serializes this road procedural texture
  68986. * @returns a serialized road procedural texture object
  68987. */
  68988. serialize(): any;
  68989. /**
  68990. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68991. * @param parsedTexture defines parsed texture data
  68992. * @param scene defines the current scene
  68993. * @param rootUrl defines the root URL containing road procedural texture information
  68994. * @returns a parsed Road Procedural BABYLON.Texture
  68995. */
  68996. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /** @hidden */
  69001. export var starfieldProceduralTexturePixelShader: {
  69002. name: string;
  69003. shader: string;
  69004. };
  69005. }
  69006. declare module BABYLON {
  69007. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69008. private _time;
  69009. private _alpha;
  69010. private _beta;
  69011. private _zoom;
  69012. private _formuparam;
  69013. private _stepsize;
  69014. private _tile;
  69015. private _brightness;
  69016. private _darkmatter;
  69017. private _distfading;
  69018. private _saturation;
  69019. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69020. updateShaderUniforms(): void;
  69021. time: number;
  69022. alpha: number;
  69023. beta: number;
  69024. formuparam: number;
  69025. stepsize: number;
  69026. zoom: number;
  69027. tile: number;
  69028. brightness: number;
  69029. darkmatter: number;
  69030. distfading: number;
  69031. saturation: number;
  69032. /**
  69033. * Serializes this starfield procedural texture
  69034. * @returns a serialized starfield procedural texture object
  69035. */
  69036. serialize(): any;
  69037. /**
  69038. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69039. * @param parsedTexture defines parsed texture data
  69040. * @param scene defines the current scene
  69041. * @param rootUrl defines the root URL containing startfield procedural texture information
  69042. * @returns a parsed Starfield Procedural BABYLON.Texture
  69043. */
  69044. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69045. }
  69046. }
  69047. declare module BABYLON {
  69048. /** @hidden */
  69049. export var woodProceduralTexturePixelShader: {
  69050. name: string;
  69051. shader: string;
  69052. };
  69053. }
  69054. declare module BABYLON {
  69055. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69056. private _ampScale;
  69057. private _woodColor;
  69058. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69059. updateShaderUniforms(): void;
  69060. ampScale: number;
  69061. woodColor: BABYLON.Color3;
  69062. /**
  69063. * Serializes this wood procedural texture
  69064. * @returns a serialized wood procedural texture object
  69065. */
  69066. serialize(): any;
  69067. /**
  69068. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69069. * @param parsedTexture defines parsed texture data
  69070. * @param scene defines the current scene
  69071. * @param rootUrl defines the root URL containing wood procedural texture information
  69072. * @returns a parsed Wood Procedural BABYLON.Texture
  69073. */
  69074. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69075. }
  69076. }