documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and mip = nearest */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  774. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** nearest is mag = nearest and min = nearest and mip = linear */
  778. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** mag = nearest and min = nearest and mip = none */
  792. static readonly TEXTURE_NEAREST_NEAREST: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** mag = linear and min = linear and mip = none */
  798. static readonly TEXTURE_LINEAR_LINEAR: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IColor4Like {
  1471. r: float;
  1472. g: float;
  1473. b: float;
  1474. a: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IColor3Like {
  1480. r: float;
  1481. g: float;
  1482. b: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector4Like {
  1488. x: float;
  1489. y: float;
  1490. z: float;
  1491. w: float;
  1492. }
  1493. /**
  1494. * @hidden
  1495. */
  1496. export interface IVector3Like {
  1497. x: float;
  1498. y: float;
  1499. z: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IVector2Like {
  1505. x: float;
  1506. y: float;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IMatrixLike {
  1512. toArray(): DeepImmutable<Float32Array>;
  1513. updateFlag: int;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IViewportLike {
  1519. x: float;
  1520. y: float;
  1521. width: float;
  1522. height: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IPlaneLike {
  1528. normal: IVector3Like;
  1529. d: float;
  1530. normalize(): void;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /**
  1535. * Interface used to define common properties for effect fallbacks
  1536. */
  1537. export interface IEffectFallbacks {
  1538. /**
  1539. * Removes the defines that should be removed when falling back.
  1540. * @param currentDefines defines the current define statements for the shader.
  1541. * @param effect defines the current effect we try to compile
  1542. * @returns The resulting defines with defines of the current rank removed.
  1543. */
  1544. reduce(currentDefines: string, effect: Effect): string;
  1545. /**
  1546. * Removes the fallback from the bound mesh.
  1547. */
  1548. unBindMesh(): void;
  1549. /**
  1550. * Checks to see if more fallbacks are still availible.
  1551. */
  1552. hasMoreFallbacks: boolean;
  1553. }
  1554. }
  1555. declare module BABYLON {
  1556. /**
  1557. * Class used to evalaute queries containing `and` and `or` operators
  1558. */
  1559. export class AndOrNotEvaluator {
  1560. /**
  1561. * Evaluate a query
  1562. * @param query defines the query to evaluate
  1563. * @param evaluateCallback defines the callback used to filter result
  1564. * @returns true if the query matches
  1565. */
  1566. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1567. private static _HandleParenthesisContent;
  1568. private static _SimplifyNegation;
  1569. }
  1570. }
  1571. declare module BABYLON {
  1572. /**
  1573. * Class used to store custom tags
  1574. */
  1575. export class Tags {
  1576. /**
  1577. * Adds support for tags on the given object
  1578. * @param obj defines the object to use
  1579. */
  1580. static EnableFor(obj: any): void;
  1581. /**
  1582. * Removes tags support
  1583. * @param obj defines the object to use
  1584. */
  1585. static DisableFor(obj: any): void;
  1586. /**
  1587. * Gets a boolean indicating if the given object has tags
  1588. * @param obj defines the object to use
  1589. * @returns a boolean
  1590. */
  1591. static HasTags(obj: any): boolean;
  1592. /**
  1593. * Gets the tags available on a given object
  1594. * @param obj defines the object to use
  1595. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1596. * @returns the tags
  1597. */
  1598. static GetTags(obj: any, asString?: boolean): any;
  1599. /**
  1600. * Adds tags to an object
  1601. * @param obj defines the object to use
  1602. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1603. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1604. */
  1605. static AddTagsTo(obj: any, tagsString: string): void;
  1606. /**
  1607. * @hidden
  1608. */
  1609. static _AddTagTo(obj: any, tag: string): void;
  1610. /**
  1611. * Removes specific tags from a specific object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tags to remove
  1614. */
  1615. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1616. /**
  1617. * @hidden
  1618. */
  1619. static _RemoveTagFrom(obj: any, tag: string): void;
  1620. /**
  1621. * Defines if tags hosted on an object match a given query
  1622. * @param obj defines the object to use
  1623. * @param tagsQuery defines the tag query
  1624. * @returns a boolean
  1625. */
  1626. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Scalar computation library
  1632. */
  1633. export class Scalar {
  1634. /**
  1635. * Two pi constants convenient for computation.
  1636. */
  1637. static TwoPi: number;
  1638. /**
  1639. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1640. * @param a number
  1641. * @param b number
  1642. * @param epsilon (default = 1.401298E-45)
  1643. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1644. */
  1645. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1646. /**
  1647. * Returns a string : the upper case translation of the number i to hexadecimal.
  1648. * @param i number
  1649. * @returns the upper case translation of the number i to hexadecimal.
  1650. */
  1651. static ToHex(i: number): string;
  1652. /**
  1653. * Returns -1 if value is negative and +1 is value is positive.
  1654. * @param value the value
  1655. * @returns the value itself if it's equal to zero.
  1656. */
  1657. static Sign(value: number): number;
  1658. /**
  1659. * Returns the value itself if it's between min and max.
  1660. * Returns min if the value is lower than min.
  1661. * Returns max if the value is greater than max.
  1662. * @param value the value to clmap
  1663. * @param min the min value to clamp to (default: 0)
  1664. * @param max the max value to clamp to (default: 1)
  1665. * @returns the clamped value
  1666. */
  1667. static Clamp(value: number, min?: number, max?: number): number;
  1668. /**
  1669. * the log2 of value.
  1670. * @param value the value to compute log2 of
  1671. * @returns the log2 of value.
  1672. */
  1673. static Log2(value: number): number;
  1674. /**
  1675. * Loops the value, so that it is never larger than length and never smaller than 0.
  1676. *
  1677. * This is similar to the modulo operator but it works with floating point numbers.
  1678. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1679. * With t = 5 and length = 2.5, the result would be 0.0.
  1680. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1681. * @param value the value
  1682. * @param length the length
  1683. * @returns the looped value
  1684. */
  1685. static Repeat(value: number, length: number): number;
  1686. /**
  1687. * Normalize the value between 0.0 and 1.0 using min and max values
  1688. * @param value value to normalize
  1689. * @param min max to normalize between
  1690. * @param max min to normalize between
  1691. * @returns the normalized value
  1692. */
  1693. static Normalize(value: number, min: number, max: number): number;
  1694. /**
  1695. * Denormalize the value from 0.0 and 1.0 using min and max values
  1696. * @param normalized value to denormalize
  1697. * @param min max to denormalize between
  1698. * @param max min to denormalize between
  1699. * @returns the denormalized value
  1700. */
  1701. static Denormalize(normalized: number, min: number, max: number): number;
  1702. /**
  1703. * Calculates the shortest difference between two given angles given in degrees.
  1704. * @param current current angle in degrees
  1705. * @param target target angle in degrees
  1706. * @returns the delta
  1707. */
  1708. static DeltaAngle(current: number, target: number): number;
  1709. /**
  1710. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1711. * @param tx value
  1712. * @param length length
  1713. * @returns The returned value will move back and forth between 0 and length
  1714. */
  1715. static PingPong(tx: number, length: number): number;
  1716. /**
  1717. * Interpolates between min and max with smoothing at the limits.
  1718. *
  1719. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1720. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1721. * @param from from
  1722. * @param to to
  1723. * @param tx value
  1724. * @returns the smooth stepped value
  1725. */
  1726. static SmoothStep(from: number, to: number, tx: number): number;
  1727. /**
  1728. * Moves a value current towards target.
  1729. *
  1730. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1731. * Negative values of maxDelta pushes the value away from target.
  1732. * @param current current value
  1733. * @param target target value
  1734. * @param maxDelta max distance to move
  1735. * @returns resulting value
  1736. */
  1737. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1738. /**
  1739. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1740. *
  1741. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1742. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting angle
  1747. */
  1748. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1751. * @param start start value
  1752. * @param end target value
  1753. * @param amount amount to lerp between
  1754. * @returns the lerped value
  1755. */
  1756. static Lerp(start: number, end: number, amount: number): number;
  1757. /**
  1758. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1760. * @param start start value
  1761. * @param end target value
  1762. * @param amount amount to lerp between
  1763. * @returns the lerped value
  1764. */
  1765. static LerpAngle(start: number, end: number, amount: number): number;
  1766. /**
  1767. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1768. * @param a start value
  1769. * @param b target value
  1770. * @param value value between a and b
  1771. * @returns the inverseLerp value
  1772. */
  1773. static InverseLerp(a: number, b: number, value: number): number;
  1774. /**
  1775. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1776. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1777. * @param value1 spline value
  1778. * @param tangent1 spline value
  1779. * @param value2 spline value
  1780. * @param tangent2 spline value
  1781. * @param amount input value
  1782. * @returns hermite result
  1783. */
  1784. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1785. /**
  1786. * Returns a random float number between and min and max values
  1787. * @param min min value of random
  1788. * @param max max value of random
  1789. * @returns random value
  1790. */
  1791. static RandomRange(min: number, max: number): number;
  1792. /**
  1793. * This function returns percentage of a number in a given range.
  1794. *
  1795. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1796. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1797. * @param number to convert to percentage
  1798. * @param min min range
  1799. * @param max max range
  1800. * @returns the percentage
  1801. */
  1802. static RangeToPercent(number: number, min: number, max: number): number;
  1803. /**
  1804. * This function returns number that corresponds to the percentage in a given range.
  1805. *
  1806. * PercentToRange(0.34,0,100) will return 34.
  1807. * @param percent to convert to number
  1808. * @param min min range
  1809. * @param max max range
  1810. * @returns the number
  1811. */
  1812. static PercentToRange(percent: number, min: number, max: number): number;
  1813. /**
  1814. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1815. * @param angle The angle to normalize in radian.
  1816. * @return The converted angle.
  1817. */
  1818. static NormalizeRadians(angle: number): number;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Constant used to convert a value to gamma space
  1824. * @ignorenaming
  1825. */
  1826. export const ToGammaSpace: number;
  1827. /**
  1828. * Constant used to convert a value to linear space
  1829. * @ignorenaming
  1830. */
  1831. export const ToLinearSpace = 2.2;
  1832. /**
  1833. * Constant used to define the minimal number value in Babylon.js
  1834. * @ignorenaming
  1835. */
  1836. let Epsilon: number;
  1837. }
  1838. declare module BABYLON {
  1839. /**
  1840. * Class used to represent a viewport on screen
  1841. */
  1842. export class Viewport {
  1843. /** viewport left coordinate */
  1844. x: number;
  1845. /** viewport top coordinate */
  1846. y: number;
  1847. /**viewport width */
  1848. width: number;
  1849. /** viewport height */
  1850. height: number;
  1851. /**
  1852. * Creates a Viewport object located at (x, y) and sized (width, height)
  1853. * @param x defines viewport left coordinate
  1854. * @param y defines viewport top coordinate
  1855. * @param width defines the viewport width
  1856. * @param height defines the viewport height
  1857. */
  1858. constructor(
  1859. /** viewport left coordinate */
  1860. x: number,
  1861. /** viewport top coordinate */
  1862. y: number,
  1863. /**viewport width */
  1864. width: number,
  1865. /** viewport height */
  1866. height: number);
  1867. /**
  1868. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @returns a new Viewport
  1872. */
  1873. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1874. /**
  1875. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1876. * @param renderWidth defines the rendering width
  1877. * @param renderHeight defines the rendering height
  1878. * @param ref defines the target viewport
  1879. * @returns the current viewport
  1880. */
  1881. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1882. /**
  1883. * Returns a new Viewport copied from the current one
  1884. * @returns a new Viewport
  1885. */
  1886. clone(): Viewport;
  1887. }
  1888. }
  1889. declare module BABYLON {
  1890. /**
  1891. * Class containing a set of static utilities functions for arrays.
  1892. */
  1893. export class ArrayTools {
  1894. /**
  1895. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1896. * @param size the number of element to construct and put in the array
  1897. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1898. * @returns a new array filled with new objects
  1899. */
  1900. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1901. }
  1902. }
  1903. declare module BABYLON {
  1904. /**
  1905. * Class representing a vector containing 2 coordinates
  1906. */
  1907. export class Vector2 {
  1908. /** defines the first coordinate */
  1909. x: number;
  1910. /** defines the second coordinate */
  1911. y: number;
  1912. /**
  1913. * Creates a new Vector2 from the given x and y coordinates
  1914. * @param x defines the first coordinate
  1915. * @param y defines the second coordinate
  1916. */
  1917. constructor(
  1918. /** defines the first coordinate */
  1919. x?: number,
  1920. /** defines the second coordinate */
  1921. y?: number);
  1922. /**
  1923. * Gets a string with the Vector2 coordinates
  1924. * @returns a string with the Vector2 coordinates
  1925. */
  1926. toString(): string;
  1927. /**
  1928. * Gets class name
  1929. * @returns the string "Vector2"
  1930. */
  1931. getClassName(): string;
  1932. /**
  1933. * Gets current vector hash code
  1934. * @returns the Vector2 hash code as a number
  1935. */
  1936. getHashCode(): number;
  1937. /**
  1938. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1939. * @param array defines the source array
  1940. * @param index defines the offset in source array
  1941. * @returns the current Vector2
  1942. */
  1943. toArray(array: FloatArray, index?: number): Vector2;
  1944. /**
  1945. * Copy the current vector to an array
  1946. * @returns a new array with 2 elements: the Vector2 coordinates.
  1947. */
  1948. asArray(): number[];
  1949. /**
  1950. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1951. * @param source defines the source Vector2
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. copyFromFloats(x: number, y: number): Vector2;
  1962. /**
  1963. * Sets the Vector2 coordinates with the given floats
  1964. * @param x defines the first coordinate
  1965. * @param y defines the second coordinate
  1966. * @returns the current updated Vector2
  1967. */
  1968. set(x: number, y: number): Vector2;
  1969. /**
  1970. * Add another vector with the current one
  1971. * @param otherVector defines the other vector
  1972. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1973. */
  1974. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1977. * @param otherVector defines the other vector
  1978. * @param result defines the target vector
  1979. * @returns the unmodified current Vector2
  1980. */
  1981. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1982. /**
  1983. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. addVector3(otherVector: Vector3): Vector2;
  1994. /**
  1995. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1996. * @param otherVector defines the other vector
  1997. * @returns a new Vector2
  1998. */
  1999. subtract(otherVector: Vector2): Vector2;
  2000. /**
  2001. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2002. * @param otherVector defines the other vector
  2003. * @param result defines the target vector
  2004. * @returns the unmodified current Vector2
  2005. */
  2006. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2007. /**
  2008. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Multiplies in place the current Vector2 coordinates by the given ones
  2015. * @param otherVector defines the other vector
  2016. * @returns the current updated Vector2
  2017. */
  2018. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns a new Vector2
  2023. */
  2024. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2027. * @param otherVector defines the other vector
  2028. * @param result defines the target vector
  2029. * @returns the unmodified current Vector2
  2030. */
  2031. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2032. /**
  2033. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2034. * @param x defines the first coordinate
  2035. * @param y defines the second coordinate
  2036. * @returns a new Vector2
  2037. */
  2038. multiplyByFloats(x: number, y: number): Vector2;
  2039. /**
  2040. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @returns a new Vector2
  2043. */
  2044. divide(otherVector: Vector2): Vector2;
  2045. /**
  2046. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2047. * @param otherVector defines the other vector
  2048. * @param result defines the target vector
  2049. * @returns the unmodified current Vector2
  2050. */
  2051. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2052. /**
  2053. * Divides the current Vector2 coordinates by the given ones
  2054. * @param otherVector defines the other vector
  2055. * @returns the current updated Vector2
  2056. */
  2057. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2058. /**
  2059. * Gets a new Vector2 with current Vector2 negated coordinates
  2060. * @returns a new Vector2
  2061. */
  2062. negate(): Vector2;
  2063. /**
  2064. * Multiply the Vector2 coordinates by scale
  2065. * @param scale defines the scaling factor
  2066. * @returns the current updated Vector2
  2067. */
  2068. scaleInPlace(scale: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2071. * @param scale defines the scaling factor
  2072. * @returns a new Vector2
  2073. */
  2074. scale(scale: number): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2084. * @param scale defines the scale factor
  2085. * @param result defines the Vector2 object where to store the result
  2086. * @returns the unmodified current Vector2
  2087. */
  2088. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2089. /**
  2090. * Gets a boolean if two vectors are equals
  2091. * @param otherVector defines the other vector
  2092. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2093. */
  2094. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2095. /**
  2096. * Gets a boolean if two vectors are equals (using an epsilon value)
  2097. * @param otherVector defines the other vector
  2098. * @param epsilon defines the minimal distance to consider equality
  2099. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2100. */
  2101. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2102. /**
  2103. * Gets a new Vector2 from current Vector2 floored values
  2104. * @returns a new Vector2
  2105. */
  2106. floor(): Vector2;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. fract(): Vector2;
  2112. /**
  2113. * Gets the length of the vector
  2114. * @returns the vector length (float)
  2115. */
  2116. length(): number;
  2117. /**
  2118. * Gets the vector squared length
  2119. * @returns the vector squared length (float)
  2120. */
  2121. lengthSquared(): number;
  2122. /**
  2123. * Normalize the vector
  2124. * @returns the current updated Vector2
  2125. */
  2126. normalize(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 copied from the Vector2
  2129. * @returns a new Vector2
  2130. */
  2131. clone(): Vector2;
  2132. /**
  2133. * Gets a new Vector2(0, 0)
  2134. * @returns a new Vector2
  2135. */
  2136. static Zero(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(1, 1)
  2139. * @returns a new Vector2
  2140. */
  2141. static One(): Vector2;
  2142. /**
  2143. * Gets a new Vector2 set from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @returns a new Vector2
  2147. */
  2148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2149. /**
  2150. * Sets "result" from the given index element of the given array
  2151. * @param array defines the data source
  2152. * @param offset defines the offset in the data source
  2153. * @param result defines the target vector
  2154. */
  2155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2156. /**
  2157. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2158. * @param value1 defines 1st point of control
  2159. * @param value2 defines 2nd point of control
  2160. * @param value3 defines 3rd point of control
  2161. * @param value4 defines 4th point of control
  2162. * @param amount defines the interpolation factor
  2163. * @returns a new Vector2
  2164. */
  2165. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2166. /**
  2167. * 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".
  2168. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2169. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2170. * @param value defines the value to clamp
  2171. * @param min defines the lower limit
  2172. * @param max defines the upper limit
  2173. * @returns a new Vector2
  2174. */
  2175. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2178. * @param value1 defines the 1st control point
  2179. * @param tangent1 defines the outgoing tangent
  2180. * @param value2 defines the 2nd control point
  2181. * @param tangent2 defines the incoming tangent
  2182. * @param amount defines the interpolation factor
  2183. * @returns a new Vector2
  2184. */
  2185. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2188. * @param start defines the start vector
  2189. * @param end defines the end vector
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * Gets the dot product of the vector "left" and the vector "right"
  2196. * @param left defines first vector
  2197. * @param right defines second vector
  2198. * @returns the dot product (float)
  2199. */
  2200. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2201. /**
  2202. * Returns a new Vector2 equal to the normalized given vector
  2203. * @param vector defines the vector to normalize
  2204. * @returns a new Vector2
  2205. */
  2206. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2216. * @param left defines 1st vector
  2217. * @param right defines 2nd vector
  2218. * @returns a new Vector2
  2219. */
  2220. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @returns a new Vector2
  2226. */
  2227. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2228. /**
  2229. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2230. * @param vector defines the vector to transform
  2231. * @param transformation defines the matrix to apply
  2232. * @param result defines the target vector
  2233. */
  2234. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2235. /**
  2236. * Determines if a given vector is included in a triangle
  2237. * @param p defines the vector to test
  2238. * @param p0 defines 1st triangle point
  2239. * @param p1 defines 2nd triangle point
  2240. * @param p2 defines 3rd triangle point
  2241. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2242. */
  2243. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2244. /**
  2245. * Gets the distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the distance between vectors
  2249. */
  2250. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Returns the squared distance between the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns the squared distance between vectors
  2256. */
  2257. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2258. /**
  2259. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns a new Vector2
  2263. */
  2264. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2265. /**
  2266. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2267. * @param p defines the middle point
  2268. * @param segA defines one point of the segment
  2269. * @param segB defines the other point of the segment
  2270. * @returns the shortest distance
  2271. */
  2272. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2273. }
  2274. /**
  2275. * Class used to store (x,y,z) vector representation
  2276. * A Vector3 is the main object used in 3D geometry
  2277. * It can represent etiher the coordinates of a point the space, either a direction
  2278. * Reminder: js uses a left handed forward facing system
  2279. */
  2280. export class Vector3 {
  2281. /**
  2282. * Defines the first coordinates (on X axis)
  2283. */
  2284. x: number;
  2285. /**
  2286. * Defines the second coordinates (on Y axis)
  2287. */
  2288. y: number;
  2289. /**
  2290. * Defines the third coordinates (on Z axis)
  2291. */
  2292. z: number;
  2293. private static _UpReadOnly;
  2294. private static _ZeroReadOnly;
  2295. /**
  2296. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2297. * @param x defines the first coordinates (on X axis)
  2298. * @param y defines the second coordinates (on Y axis)
  2299. * @param z defines the third coordinates (on Z axis)
  2300. */
  2301. constructor(
  2302. /**
  2303. * Defines the first coordinates (on X axis)
  2304. */
  2305. x?: number,
  2306. /**
  2307. * Defines the second coordinates (on Y axis)
  2308. */
  2309. y?: number,
  2310. /**
  2311. * Defines the third coordinates (on Z axis)
  2312. */
  2313. z?: number);
  2314. /**
  2315. * Creates a string representation of the Vector3
  2316. * @returns a string with the Vector3 coordinates.
  2317. */
  2318. toString(): string;
  2319. /**
  2320. * Gets the class name
  2321. * @returns the string "Vector3"
  2322. */
  2323. getClassName(): string;
  2324. /**
  2325. * Creates the Vector3 hash code
  2326. * @returns a number which tends to be unique between Vector3 instances
  2327. */
  2328. getHashCode(): number;
  2329. /**
  2330. * Creates an array containing three elements : the coordinates of the Vector3
  2331. * @returns a new array of numbers
  2332. */
  2333. asArray(): number[];
  2334. /**
  2335. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2336. * @param array defines the destination array
  2337. * @param index defines the offset in the destination array
  2338. * @returns the current Vector3
  2339. */
  2340. toArray(array: FloatArray, index?: number): Vector3;
  2341. /**
  2342. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2343. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2344. */
  2345. toQuaternion(): Quaternion;
  2346. /**
  2347. * Adds the given vector to the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the current updated Vector3
  2350. */
  2351. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Adds the given coordinates to the current Vector3
  2354. * @param x defines the x coordinate of the operand
  2355. * @param y defines the y coordinate of the operand
  2356. * @param z defines the z coordinate of the operand
  2357. * @returns the current updated Vector3
  2358. */
  2359. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2360. /**
  2361. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2362. * @param otherVector defines the second operand
  2363. * @returns the resulting Vector3
  2364. */
  2365. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2368. * @param otherVector defines the second operand
  2369. * @param result defines the Vector3 object where to store the result
  2370. * @returns the current Vector3
  2371. */
  2372. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2373. /**
  2374. * Subtract the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2381. * @param otherVector defines the second operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2387. * @param otherVector defines the second operand
  2388. * @param result defines the Vector3 object where to store the result
  2389. * @returns the current Vector3
  2390. */
  2391. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2392. /**
  2393. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2394. * @param x defines the x coordinate of the operand
  2395. * @param y defines the y coordinate of the operand
  2396. * @param z defines the z coordinate of the operand
  2397. * @returns the resulting Vector3
  2398. */
  2399. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2400. /**
  2401. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2402. * @param x defines the x coordinate of the operand
  2403. * @param y defines the y coordinate of the operand
  2404. * @param z defines the z coordinate of the operand
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the current Vector3
  2407. */
  2408. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2409. /**
  2410. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2411. * @returns a new Vector3
  2412. */
  2413. negate(): Vector3;
  2414. /**
  2415. * Multiplies the Vector3 coordinates by the float "scale"
  2416. * @param scale defines the multiplier factor
  2417. * @returns the current updated Vector3
  2418. */
  2419. scaleInPlace(scale: number): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2422. * @param scale defines the multiplier factor
  2423. * @returns a new Vector3
  2424. */
  2425. scale(scale: number): Vector3;
  2426. /**
  2427. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2428. * @param scale defines the multiplier factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the current Vector3
  2431. */
  2432. scaleToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2435. * @param scale defines the scale factor
  2436. * @param result defines the Vector3 object where to store the result
  2437. * @returns the unmodified current Vector3
  2438. */
  2439. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2440. /**
  2441. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2442. * @param otherVector defines the second operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2448. * @param otherVector defines the second operand
  2449. * @param epsilon defines the minimal distance to define values as equals
  2450. * @returns true if both vectors are distant less than epsilon
  2451. */
  2452. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2453. /**
  2454. * Returns true if the current Vector3 coordinates equals the given floats
  2455. * @param x defines the x coordinate of the operand
  2456. * @param y defines the y coordinate of the operand
  2457. * @param z defines the z coordinate of the operand
  2458. * @returns true if both vectors are equals
  2459. */
  2460. equalsToFloats(x: number, y: number, z: number): boolean;
  2461. /**
  2462. * Multiplies the current Vector3 coordinates by the given ones
  2463. * @param otherVector defines the second operand
  2464. * @returns the current updated Vector3
  2465. */
  2466. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2467. /**
  2468. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2469. * @param otherVector defines the second operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2473. /**
  2474. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2475. * @param otherVector defines the second operand
  2476. * @param result defines the Vector3 object where to store the result
  2477. * @returns the current Vector3
  2478. */
  2479. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2480. /**
  2481. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2482. * @param x defines the x coordinate of the operand
  2483. * @param y defines the y coordinate of the operand
  2484. * @param z defines the z coordinate of the operand
  2485. * @returns the new Vector3
  2486. */
  2487. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2488. /**
  2489. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2490. * @param otherVector defines the second operand
  2491. * @returns the new Vector3
  2492. */
  2493. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2496. * @param otherVector defines the second operand
  2497. * @param result defines the Vector3 object where to store the result
  2498. * @returns the current Vector3
  2499. */
  2500. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2501. /**
  2502. * Divides the current Vector3 coordinates by the given ones.
  2503. * @param otherVector defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. divideInPlace(otherVector: Vector3): Vector3;
  2507. /**
  2508. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2509. * @param other defines the second operand
  2510. * @returns the current updated Vector3
  2511. */
  2512. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2513. /**
  2514. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2515. * @param other defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2521. * @param x defines the x coordinate of the operand
  2522. * @param y defines the y coordinate of the operand
  2523. * @param z defines the z coordinate of the operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2529. * @param x defines the x coordinate of the operand
  2530. * @param y defines the y coordinate of the operand
  2531. * @param z defines the z coordinate of the operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2535. /**
  2536. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2537. * Check if is non uniform within a certain amount of decimal places to account for this
  2538. * @param epsilon the amount the values can differ
  2539. * @returns if the the vector is non uniform to a certain number of decimal places
  2540. */
  2541. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2542. /**
  2543. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2544. */
  2545. get isNonUniform(): boolean;
  2546. /**
  2547. * Gets a new Vector3 from current Vector3 floored values
  2548. * @returns a new Vector3
  2549. */
  2550. floor(): Vector3;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. fract(): Vector3;
  2556. /**
  2557. * Gets the length of the Vector3
  2558. * @returns the length of the Vector3
  2559. */
  2560. length(): number;
  2561. /**
  2562. * Gets the squared length of the Vector3
  2563. * @returns squared length of the Vector3
  2564. */
  2565. lengthSquared(): number;
  2566. /**
  2567. * Normalize the current Vector3.
  2568. * Please note that this is an in place operation.
  2569. * @returns the current updated Vector3
  2570. */
  2571. normalize(): Vector3;
  2572. /**
  2573. * Reorders the x y z properties of the vector in place
  2574. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2575. * @returns the current updated vector
  2576. */
  2577. reorderInPlace(order: string): this;
  2578. /**
  2579. * Rotates the vector around 0,0,0 by a quaternion
  2580. * @param quaternion the rotation quaternion
  2581. * @param result vector to store the result
  2582. * @returns the resulting vector
  2583. */
  2584. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2585. /**
  2586. * Rotates a vector around a given point
  2587. * @param quaternion the rotation quaternion
  2588. * @param point the point to rotate around
  2589. * @param result vector to store the result
  2590. * @returns the resulting vector
  2591. */
  2592. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2593. /**
  2594. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2595. * The cross product is then orthogonal to both current and "other"
  2596. * @param other defines the right operand
  2597. * @returns the cross product
  2598. */
  2599. cross(other: Vector3): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 with the given input length.
  2602. * Please note that this is an in place operation.
  2603. * @param len the length of the vector
  2604. * @returns the current updated Vector3
  2605. */
  2606. normalizeFromLength(len: number): Vector3;
  2607. /**
  2608. * Normalize the current Vector3 to a new vector
  2609. * @returns the new Vector3
  2610. */
  2611. normalizeToNew(): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to the reference
  2614. * @param reference define the Vector3 to update
  2615. * @returns the updated Vector3
  2616. */
  2617. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2618. /**
  2619. * Creates a new Vector3 copied from the current Vector3
  2620. * @returns the new Vector3
  2621. */
  2622. clone(): Vector3;
  2623. /**
  2624. * Copies the given vector coordinates to the current Vector3 ones
  2625. * @param source defines the source Vector3
  2626. * @returns the current updated Vector3
  2627. */
  2628. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2629. /**
  2630. * Copies the given floats to the current Vector3 coordinates
  2631. * @param x defines the x coordinate of the operand
  2632. * @param y defines the y coordinate of the operand
  2633. * @param z defines the z coordinate of the operand
  2634. * @returns the current updated Vector3
  2635. */
  2636. copyFromFloats(x: number, y: number, z: number): Vector3;
  2637. /**
  2638. * Copies the given floats to the current Vector3 coordinates
  2639. * @param x defines the x coordinate of the operand
  2640. * @param y defines the y coordinate of the operand
  2641. * @param z defines the z coordinate of the operand
  2642. * @returns the current updated Vector3
  2643. */
  2644. set(x: number, y: number, z: number): Vector3;
  2645. /**
  2646. * Copies the given float to the current Vector3 coordinates
  2647. * @param v defines the x, y and z coordinates of the operand
  2648. * @returns the current updated Vector3
  2649. */
  2650. setAll(v: number): Vector3;
  2651. /**
  2652. * Get the clip factor between two vectors
  2653. * @param vector0 defines the first operand
  2654. * @param vector1 defines the second operand
  2655. * @param axis defines the axis to use
  2656. * @param size defines the size along the axis
  2657. * @returns the clip factor
  2658. */
  2659. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2660. /**
  2661. * Get angle between two vectors
  2662. * @param vector0 angle between vector0 and vector1
  2663. * @param vector1 angle between vector0 and vector1
  2664. * @param normal direction of the normal
  2665. * @return the angle between vector0 and vector1
  2666. */
  2667. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @returns the new Vector3
  2673. */
  2674. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2675. /**
  2676. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2677. * @param array defines the source array
  2678. * @param offset defines the offset in the source array
  2679. * @returns the new Vector3
  2680. * @deprecated Please use FromArray instead.
  2681. */
  2682. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2685. * @param array defines the source array
  2686. * @param offset defines the offset in the source array
  2687. * @param result defines the Vector3 where to store the result
  2688. */
  2689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2690. /**
  2691. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2692. * @param array defines the source array
  2693. * @param offset defines the offset in the source array
  2694. * @param result defines the Vector3 where to store the result
  2695. * @deprecated Please use FromArrayToRef instead.
  2696. */
  2697. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2698. /**
  2699. * Sets the given vector "result" with the given floats.
  2700. * @param x defines the x coordinate of the source
  2701. * @param y defines the y coordinate of the source
  2702. * @param z defines the z coordinate of the source
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2708. * @returns a new empty Vector3
  2709. */
  2710. static Zero(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2713. * @returns a new unit Vector3
  2714. */
  2715. static One(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2718. * @returns a new up Vector3
  2719. */
  2720. static Up(): Vector3;
  2721. /**
  2722. * Gets a up Vector3 that must not be updated
  2723. */
  2724. static get UpReadOnly(): DeepImmutable<Vector3>;
  2725. /**
  2726. * Gets a zero Vector3 that must not be updated
  2727. */
  2728. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2731. * @returns a new down Vector3
  2732. */
  2733. static Down(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2736. * @returns a new forward Vector3
  2737. */
  2738. static Forward(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Backward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2746. * @returns a new right Vector3
  2747. */
  2748. static Right(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2751. * @returns a new left Vector3
  2752. */
  2753. static Left(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2756. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2757. * @param vector defines the Vector3 to transform
  2758. * @param transformation defines the transformation matrix
  2759. * @returns the transformed Vector3
  2760. */
  2761. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2762. /**
  2763. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2764. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2765. * @param vector defines the Vector3 to transform
  2766. * @param transformation defines the transformation matrix
  2767. * @param result defines the Vector3 where to store the result
  2768. */
  2769. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2770. /**
  2771. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2772. * This method computes tranformed coordinates only, not transformed direction vectors
  2773. * @param x define the x coordinate of the source vector
  2774. * @param y define the y coordinate of the source vector
  2775. * @param z define the z coordinate of the source vector
  2776. * @param transformation defines the transformation matrix
  2777. * @param result defines the Vector3 where to store the result
  2778. */
  2779. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2780. /**
  2781. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2782. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2783. * @param vector defines the Vector3 to transform
  2784. * @param transformation defines the transformation matrix
  2785. * @returns the new Vector3
  2786. */
  2787. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2788. /**
  2789. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2790. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2791. * @param vector defines the Vector3 to transform
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param x define the x coordinate of the source vector
  2800. * @param y define the y coordinate of the source vector
  2801. * @param z define the z coordinate of the source vector
  2802. * @param transformation defines the transformation matrix
  2803. * @param result defines the Vector3 where to store the result
  2804. */
  2805. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2806. /**
  2807. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2808. * @param value1 defines the first control point
  2809. * @param value2 defines the second control point
  2810. * @param value3 defines the third control point
  2811. * @param value4 defines the fourth control point
  2812. * @param amount defines the amount on the spline to use
  2813. * @returns the new Vector3
  2814. */
  2815. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2816. /**
  2817. * 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"
  2818. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2819. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2820. * @param value defines the current value
  2821. * @param min defines the lower range value
  2822. * @param max defines the upper range value
  2823. * @returns the new Vector3
  2824. */
  2825. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2826. /**
  2827. * 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"
  2828. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2829. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2830. * @param value defines the current value
  2831. * @param min defines the lower range value
  2832. * @param max defines the upper range value
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2836. /**
  2837. * Checks if a given vector is inside a specific range
  2838. * @param v defines the vector to test
  2839. * @param min defines the minimum range
  2840. * @param max defines the maximum range
  2841. */
  2842. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2843. /**
  2844. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2845. * @param value1 defines the first control point
  2846. * @param tangent1 defines the first tangent vector
  2847. * @param value2 defines the second control point
  2848. * @param tangent2 defines the second tangent vector
  2849. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2850. * @returns the new Vector3
  2851. */
  2852. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2853. /**
  2854. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2855. * @param start defines the start value
  2856. * @param end defines the end value
  2857. * @param amount max defines amount between both (between 0 and 1)
  2858. * @returns the new Vector3
  2859. */
  2860. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2861. /**
  2862. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2863. * @param start defines the start value
  2864. * @param end defines the end value
  2865. * @param amount max defines amount between both (between 0 and 1)
  2866. * @param result defines the Vector3 where to store the result
  2867. */
  2868. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2869. /**
  2870. * Returns the dot product (float) between the vectors "left" and "right"
  2871. * @param left defines the left operand
  2872. * @param right defines the right operand
  2873. * @returns the dot product
  2874. */
  2875. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2876. /**
  2877. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2878. * The cross product is then orthogonal to both "left" and "right"
  2879. * @param left defines the left operand
  2880. * @param right defines the right operand
  2881. * @returns the cross product
  2882. */
  2883. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the cross product of "left" and "right"
  2886. * The cross product is then orthogonal to both "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 as the normalization of the given vector
  2894. * @param vector defines the Vector3 to normalize
  2895. * @returns the new Vector3
  2896. */
  2897. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2898. /**
  2899. * Sets the given vector "result" with the normalization of the given first vector
  2900. * @param vector defines the Vector3 to normalize
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2904. /**
  2905. * Project a Vector3 onto screen space
  2906. * @param vector defines the Vector3 to project
  2907. * @param world defines the world matrix to use
  2908. * @param transform defines the transform (view x projection) matrix to use
  2909. * @param viewport defines the screen viewport to use
  2910. * @returns the new Vector3
  2911. */
  2912. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2913. /** @hidden */
  2914. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2915. /**
  2916. * Unproject from screen space to object space
  2917. * @param source defines the screen space Vector3 to use
  2918. * @param viewportWidth defines the current width of the viewport
  2919. * @param viewportHeight defines the current height of the viewport
  2920. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2921. * @param transform defines the transform (view x projection) matrix to use
  2922. * @returns the new Vector3
  2923. */
  2924. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2925. /**
  2926. * Unproject from screen space to object space
  2927. * @param source defines the screen space Vector3 to use
  2928. * @param viewportWidth defines the current width of the viewport
  2929. * @param viewportHeight defines the current height of the viewport
  2930. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2931. * @param view defines the view matrix to use
  2932. * @param projection defines the projection matrix to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2936. /**
  2937. * Unproject from screen space to object space
  2938. * @param source defines the screen space Vector3 to use
  2939. * @param viewportWidth defines the current width of the viewport
  2940. * @param viewportHeight defines the current height of the viewport
  2941. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2942. * @param view defines the view matrix to use
  2943. * @param projection defines the projection matrix to use
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Unproject from screen space to object space
  2949. * @param sourceX defines the screen space x coordinate to use
  2950. * @param sourceY defines the screen space y coordinate to use
  2951. * @param sourceZ defines the screen space z coordinate to use
  2952. * @param viewportWidth defines the current width of the viewport
  2953. * @param viewportHeight defines the current height of the viewport
  2954. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2955. * @param view defines the view matrix to use
  2956. * @param projection defines the projection matrix to use
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2960. /**
  2961. * Gets the minimal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Gets the maximal coordinate values between two Vector3
  2969. * @param left defines the first operand
  2970. * @param right defines the second operand
  2971. * @returns the new Vector3
  2972. */
  2973. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2974. /**
  2975. * Returns the distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the distance
  2979. */
  2980. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns the squared distance between the vectors "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the squared distance
  2986. */
  2987. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2988. /**
  2989. * Returns a new Vector3 located at the center between "value1" and "value2"
  2990. * @param value1 defines the first operand
  2991. * @param value2 defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2997. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2998. * to something in order to rotate it from its local system to the given target system
  2999. * Note: axis1, axis2 and axis3 are normalized during this operation
  3000. * @param axis1 defines the first axis
  3001. * @param axis2 defines the second axis
  3002. * @param axis3 defines the third axis
  3003. * @returns a new Vector3
  3004. */
  3005. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3006. /**
  3007. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3008. * @param axis1 defines the first axis
  3009. * @param axis2 defines the second axis
  3010. * @param axis3 defines the third axis
  3011. * @param ref defines the Vector3 where to store the result
  3012. */
  3013. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3014. }
  3015. /**
  3016. * Vector4 class created for EulerAngle class conversion to Quaternion
  3017. */
  3018. export class Vector4 {
  3019. /** x value of the vector */
  3020. x: number;
  3021. /** y value of the vector */
  3022. y: number;
  3023. /** z value of the vector */
  3024. z: number;
  3025. /** w value of the vector */
  3026. w: number;
  3027. /**
  3028. * Creates a Vector4 object from the given floats.
  3029. * @param x x value of the vector
  3030. * @param y y value of the vector
  3031. * @param z z value of the vector
  3032. * @param w w value of the vector
  3033. */
  3034. constructor(
  3035. /** x value of the vector */
  3036. x: number,
  3037. /** y value of the vector */
  3038. y: number,
  3039. /** z value of the vector */
  3040. z: number,
  3041. /** w value of the vector */
  3042. w: number);
  3043. /**
  3044. * Returns the string with the Vector4 coordinates.
  3045. * @returns a string containing all the vector values
  3046. */
  3047. toString(): string;
  3048. /**
  3049. * Returns the string "Vector4".
  3050. * @returns "Vector4"
  3051. */
  3052. getClassName(): string;
  3053. /**
  3054. * Returns the Vector4 hash code.
  3055. * @returns a unique hash code
  3056. */
  3057. getHashCode(): number;
  3058. /**
  3059. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3060. * @returns the resulting array
  3061. */
  3062. asArray(): number[];
  3063. /**
  3064. * Populates the given array from the given index with the Vector4 coordinates.
  3065. * @param array array to populate
  3066. * @param index index of the array to start at (default: 0)
  3067. * @returns the Vector4.
  3068. */
  3069. toArray(array: FloatArray, index?: number): Vector4;
  3070. /**
  3071. * Adds the given vector to the current Vector4.
  3072. * @param otherVector the vector to add
  3073. * @returns the updated Vector4.
  3074. */
  3075. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3076. /**
  3077. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3078. * @param otherVector the vector to add
  3079. * @returns the resulting vector
  3080. */
  3081. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3082. /**
  3083. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3084. * @param otherVector the vector to add
  3085. * @param result the vector to store the result
  3086. * @returns the current Vector4.
  3087. */
  3088. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3089. /**
  3090. * Subtract in place the given vector from the current Vector4.
  3091. * @param otherVector the vector to subtract
  3092. * @returns the updated Vector4.
  3093. */
  3094. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3095. /**
  3096. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the new vector with the result
  3099. */
  3100. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3103. * @param otherVector the vector to subtract
  3104. * @param result the vector to store the result
  3105. * @returns the current Vector4.
  3106. */
  3107. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3110. */
  3111. /**
  3112. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3113. * @param x value to subtract
  3114. * @param y value to subtract
  3115. * @param z value to subtract
  3116. * @param w value to subtract
  3117. * @returns new vector containing the result
  3118. */
  3119. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3120. /**
  3121. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. * @param x value to subtract
  3123. * @param y value to subtract
  3124. * @param z value to subtract
  3125. * @param w value to subtract
  3126. * @param result the vector to store the result in
  3127. * @returns the current Vector4.
  3128. */
  3129. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3130. /**
  3131. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3132. * @returns a new vector with the negated values
  3133. */
  3134. negate(): Vector4;
  3135. /**
  3136. * Multiplies the current Vector4 coordinates by scale (float).
  3137. * @param scale the number to scale with
  3138. * @returns the updated Vector4.
  3139. */
  3140. scaleInPlace(scale: number): Vector4;
  3141. /**
  3142. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3143. * @param scale the number to scale with
  3144. * @returns a new vector with the result
  3145. */
  3146. scale(scale: number): Vector4;
  3147. /**
  3148. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3149. * @param scale the number to scale with
  3150. * @param result a vector to store the result in
  3151. * @returns the current Vector4.
  3152. */
  3153. scaleToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3156. * @param scale defines the scale factor
  3157. * @param result defines the Vector4 object where to store the result
  3158. * @returns the unmodified current Vector4
  3159. */
  3160. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3161. /**
  3162. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3163. * @param otherVector the vector to compare against
  3164. * @returns true if they are equal
  3165. */
  3166. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3167. /**
  3168. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3169. * @param otherVector vector to compare against
  3170. * @param epsilon (Default: very small number)
  3171. * @returns true if they are equal
  3172. */
  3173. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3174. /**
  3175. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3176. * @param x x value to compare against
  3177. * @param y y value to compare against
  3178. * @param z z value to compare against
  3179. * @param w w value to compare against
  3180. * @returns true if equal
  3181. */
  3182. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3183. /**
  3184. * Multiplies in place the current Vector4 by the given one.
  3185. * @param otherVector vector to multiple with
  3186. * @returns the updated Vector4.
  3187. */
  3188. multiplyInPlace(otherVector: Vector4): Vector4;
  3189. /**
  3190. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3191. * @param otherVector vector to multiple with
  3192. * @returns resulting new vector
  3193. */
  3194. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3195. /**
  3196. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3197. * @param otherVector vector to multiple with
  3198. * @param result vector to store the result
  3199. * @returns the current Vector4.
  3200. */
  3201. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3202. /**
  3203. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3204. * @param x x value multiply with
  3205. * @param y y value multiply with
  3206. * @param z z value multiply with
  3207. * @param w w value multiply with
  3208. * @returns resulting new vector
  3209. */
  3210. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3211. /**
  3212. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3213. * @param otherVector vector to devide with
  3214. * @returns resulting new vector
  3215. */
  3216. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3217. /**
  3218. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3219. * @param otherVector vector to devide with
  3220. * @param result vector to store the result
  3221. * @returns the current Vector4.
  3222. */
  3223. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3224. /**
  3225. * Divides the current Vector3 coordinates by the given ones.
  3226. * @param otherVector vector to devide with
  3227. * @returns the updated Vector3.
  3228. */
  3229. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3230. /**
  3231. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3232. * @param other defines the second operand
  3233. * @returns the current updated Vector4
  3234. */
  3235. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3236. /**
  3237. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3238. * @param other defines the second operand
  3239. * @returns the current updated Vector4
  3240. */
  3241. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3242. /**
  3243. * Gets a new Vector4 from current Vector4 floored values
  3244. * @returns a new Vector4
  3245. */
  3246. floor(): Vector4;
  3247. /**
  3248. * Gets a new Vector4 from current Vector3 floored values
  3249. * @returns a new Vector4
  3250. */
  3251. fract(): Vector4;
  3252. /**
  3253. * Returns the Vector4 length (float).
  3254. * @returns the length
  3255. */
  3256. length(): number;
  3257. /**
  3258. * Returns the Vector4 squared length (float).
  3259. * @returns the length squared
  3260. */
  3261. lengthSquared(): number;
  3262. /**
  3263. * Normalizes in place the Vector4.
  3264. * @returns the updated Vector4.
  3265. */
  3266. normalize(): Vector4;
  3267. /**
  3268. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3269. * @returns this converted to a new vector3
  3270. */
  3271. toVector3(): Vector3;
  3272. /**
  3273. * Returns a new Vector4 copied from the current one.
  3274. * @returns the new cloned vector
  3275. */
  3276. clone(): Vector4;
  3277. /**
  3278. * Updates the current Vector4 with the given one coordinates.
  3279. * @param source the source vector to copy from
  3280. * @returns the updated Vector4.
  3281. */
  3282. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Updates the current Vector4 coordinates with the given floats.
  3285. * @param x float to copy from
  3286. * @param y float to copy from
  3287. * @param z float to copy from
  3288. * @param w float to copy from
  3289. * @returns the updated Vector4.
  3290. */
  3291. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3292. /**
  3293. * Updates the current Vector4 coordinates with the given floats.
  3294. * @param x float to set from
  3295. * @param y float to set from
  3296. * @param z float to set from
  3297. * @param w float to set from
  3298. * @returns the updated Vector4.
  3299. */
  3300. set(x: number, y: number, z: number, w: number): Vector4;
  3301. /**
  3302. * Copies the given float to the current Vector3 coordinates
  3303. * @param v defines the x, y, z and w coordinates of the operand
  3304. * @returns the current updated Vector3
  3305. */
  3306. setAll(v: number): Vector4;
  3307. /**
  3308. * Returns a new Vector4 set from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @returns the new vector
  3312. */
  3313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" from the starting index of the given Float32Array.
  3323. * @param array the array to pull values from
  3324. * @param offset the offset into the array to start at
  3325. * @param result the vector to store the result in
  3326. */
  3327. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3328. /**
  3329. * Updates the given vector "result" coordinates from the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @param result the vector to the floats in
  3335. */
  3336. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3337. /**
  3338. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3339. * @returns the new vector
  3340. */
  3341. static Zero(): Vector4;
  3342. /**
  3343. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3344. * @returns the new vector
  3345. */
  3346. static One(): Vector4;
  3347. /**
  3348. * Returns a new normalized Vector4 from the given one.
  3349. * @param vector the vector to normalize
  3350. * @returns the vector
  3351. */
  3352. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Updates the given vector "result" from the normalization of the given one.
  3355. * @param vector the vector to normalize
  3356. * @param result the vector to store the result in
  3357. */
  3358. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3359. /**
  3360. * Returns a vector with the minimum values from the left and right vectors
  3361. * @param left left vector to minimize
  3362. * @param right right vector to minimize
  3363. * @returns a new vector with the minimum of the left and right vector values
  3364. */
  3365. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns a vector with the maximum values from the left and right vectors
  3368. * @param left left vector to maximize
  3369. * @param right right vector to maximize
  3370. * @returns a new vector with the maximum of the left and right vector values
  3371. */
  3372. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Returns the distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors
  3378. */
  3379. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the distance between
  3383. * @param value2 value to calulate the distance between
  3384. * @return the distance between the two vectors squared
  3385. */
  3386. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3387. /**
  3388. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3389. * @param value1 value to calulate the center between
  3390. * @param value2 value to calulate the center between
  3391. * @return the center between the two vectors
  3392. */
  3393. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param vector the vector to transform
  3398. * @param transformation the transformation matrix to apply
  3399. * @returns the new vector
  3400. */
  3401. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3404. * This methods computes transformed normalized direction vectors only.
  3405. * @param vector the vector to transform
  3406. * @param transformation the transformation matrix to apply
  3407. * @param result the vector to store the result in
  3408. */
  3409. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3410. /**
  3411. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param x value to transform
  3414. * @param y value to transform
  3415. * @param z value to transform
  3416. * @param w value to transform
  3417. * @param transformation the transformation matrix to apply
  3418. * @param result the vector to store the results in
  3419. */
  3420. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3421. /**
  3422. * Creates a new Vector4 from a Vector3
  3423. * @param source defines the source data
  3424. * @param w defines the 4th component (default is 0)
  3425. * @returns a new Vector4
  3426. */
  3427. static FromVector3(source: Vector3, w?: number): Vector4;
  3428. }
  3429. /**
  3430. * Class used to store quaternion data
  3431. * @see https://en.wikipedia.org/wiki/Quaternion
  3432. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3433. */
  3434. export class Quaternion {
  3435. /** defines the first component (0 by default) */
  3436. x: number;
  3437. /** defines the second component (0 by default) */
  3438. y: number;
  3439. /** defines the third component (0 by default) */
  3440. z: number;
  3441. /** defines the fourth component (1.0 by default) */
  3442. w: number;
  3443. /**
  3444. * Creates a new Quaternion from the given floats
  3445. * @param x defines the first component (0 by default)
  3446. * @param y defines the second component (0 by default)
  3447. * @param z defines the third component (0 by default)
  3448. * @param w defines the fourth component (1.0 by default)
  3449. */
  3450. constructor(
  3451. /** defines the first component (0 by default) */
  3452. x?: number,
  3453. /** defines the second component (0 by default) */
  3454. y?: number,
  3455. /** defines the third component (0 by default) */
  3456. z?: number,
  3457. /** defines the fourth component (1.0 by default) */
  3458. w?: number);
  3459. /**
  3460. * Gets a string representation for the current quaternion
  3461. * @returns a string with the Quaternion coordinates
  3462. */
  3463. toString(): string;
  3464. /**
  3465. * Gets the class name of the quaternion
  3466. * @returns the string "Quaternion"
  3467. */
  3468. getClassName(): string;
  3469. /**
  3470. * Gets a hash code for this quaternion
  3471. * @returns the quaternion hash code
  3472. */
  3473. getHashCode(): number;
  3474. /**
  3475. * Copy the quaternion to an array
  3476. * @returns a new array populated with 4 elements from the quaternion coordinates
  3477. */
  3478. asArray(): number[];
  3479. /**
  3480. * Check if two quaternions are equals
  3481. * @param otherQuaternion defines the second operand
  3482. * @return true if the current quaternion and the given one coordinates are strictly equals
  3483. */
  3484. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3485. /**
  3486. * Clone the current quaternion
  3487. * @returns a new quaternion copied from the current one
  3488. */
  3489. clone(): Quaternion;
  3490. /**
  3491. * Copy a quaternion to the current one
  3492. * @param other defines the other quaternion
  3493. * @returns the updated current quaternion
  3494. */
  3495. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3496. /**
  3497. * Updates the current quaternion with the given float coordinates
  3498. * @param x defines the x coordinate
  3499. * @param y defines the y coordinate
  3500. * @param z defines the z coordinate
  3501. * @param w defines the w coordinate
  3502. * @returns the updated current quaternion
  3503. */
  3504. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3505. /**
  3506. * Updates the current quaternion from the given float coordinates
  3507. * @param x defines the x coordinate
  3508. * @param y defines the y coordinate
  3509. * @param z defines the z coordinate
  3510. * @param w defines the w coordinate
  3511. * @returns the updated current quaternion
  3512. */
  3513. set(x: number, y: number, z: number, w: number): Quaternion;
  3514. /**
  3515. * Adds two quaternions
  3516. * @param other defines the second operand
  3517. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3518. */
  3519. add(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Add a quaternion to the current one
  3522. * @param other defines the quaternion to add
  3523. * @returns the current quaternion
  3524. */
  3525. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Subtract two quaternions
  3528. * @param other defines the second operand
  3529. * @returns a new quaternion as the subtraction result of the given one from the current one
  3530. */
  3531. subtract(other: Quaternion): Quaternion;
  3532. /**
  3533. * Multiplies the current quaternion by a scale factor
  3534. * @param value defines the scale factor
  3535. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3536. */
  3537. scale(value: number): Quaternion;
  3538. /**
  3539. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3540. * @param scale defines the scale factor
  3541. * @param result defines the Quaternion object where to store the result
  3542. * @returns the unmodified current quaternion
  3543. */
  3544. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3545. /**
  3546. * Multiplies in place the current quaternion by a scale factor
  3547. * @param value defines the scale factor
  3548. * @returns the current modified quaternion
  3549. */
  3550. scaleInPlace(value: number): Quaternion;
  3551. /**
  3552. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3553. * @param scale defines the scale factor
  3554. * @param result defines the Quaternion object where to store the result
  3555. * @returns the unmodified current quaternion
  3556. */
  3557. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3558. /**
  3559. * Multiplies two quaternions
  3560. * @param q1 defines the second operand
  3561. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3562. */
  3563. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @param result defines the target quaternion
  3568. * @returns the current quaternion
  3569. */
  3570. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3571. /**
  3572. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3573. * @param q1 defines the second operand
  3574. * @returns the currentupdated quaternion
  3575. */
  3576. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3577. /**
  3578. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3579. * @param ref defines the target quaternion
  3580. * @returns the current quaternion
  3581. */
  3582. conjugateToRef(ref: Quaternion): Quaternion;
  3583. /**
  3584. * Conjugates in place (1-q) the current quaternion
  3585. * @returns the current updated quaternion
  3586. */
  3587. conjugateInPlace(): Quaternion;
  3588. /**
  3589. * Conjugates in place (1-q) the current quaternion
  3590. * @returns a new quaternion
  3591. */
  3592. conjugate(): Quaternion;
  3593. /**
  3594. * Gets length of current quaternion
  3595. * @returns the quaternion length (float)
  3596. */
  3597. length(): number;
  3598. /**
  3599. * Normalize in place the current quaternion
  3600. * @returns the current updated quaternion
  3601. */
  3602. normalize(): Quaternion;
  3603. /**
  3604. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns a new Vector3 containing the Euler angles
  3607. */
  3608. toEulerAngles(order?: string): Vector3;
  3609. /**
  3610. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3611. * @param result defines the vector which will be filled with the Euler angles
  3612. * @param order is a reserved parameter and is ignore for now
  3613. * @returns the current unchanged quaternion
  3614. */
  3615. toEulerAnglesToRef(result: Vector3): Quaternion;
  3616. /**
  3617. * Updates the given rotation matrix with the current quaternion values
  3618. * @param result defines the target matrix
  3619. * @returns the current unchanged quaternion
  3620. */
  3621. toRotationMatrix(result: Matrix): Quaternion;
  3622. /**
  3623. * Updates the current quaternion from the given rotation matrix values
  3624. * @param matrix defines the source matrix
  3625. * @returns the current updated quaternion
  3626. */
  3627. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3628. /**
  3629. * Creates a new quaternion from a rotation matrix
  3630. * @param matrix defines the source matrix
  3631. * @returns a new quaternion created from the given rotation matrix values
  3632. */
  3633. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3634. /**
  3635. * Updates the given quaternion with the given rotation matrix values
  3636. * @param matrix defines the source matrix
  3637. * @param result defines the target quaternion
  3638. */
  3639. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3640. /**
  3641. * Returns the dot product (float) between the quaternions "left" and "right"
  3642. * @param left defines the left operand
  3643. * @param right defines the right operand
  3644. * @returns the dot product
  3645. */
  3646. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3647. /**
  3648. * Checks if the two quaternions are close to each other
  3649. * @param quat0 defines the first quaternion to check
  3650. * @param quat1 defines the second quaternion to check
  3651. * @returns true if the two quaternions are close to each other
  3652. */
  3653. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3654. /**
  3655. * Creates an empty quaternion
  3656. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3657. */
  3658. static Zero(): Quaternion;
  3659. /**
  3660. * Inverse a given quaternion
  3661. * @param q defines the source quaternion
  3662. * @returns a new quaternion as the inverted current quaternion
  3663. */
  3664. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3665. /**
  3666. * Inverse a given quaternion
  3667. * @param q defines the source quaternion
  3668. * @param result the quaternion the result will be stored in
  3669. * @returns the result quaternion
  3670. */
  3671. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3672. /**
  3673. * Creates an identity quaternion
  3674. * @returns the identity quaternion
  3675. */
  3676. static Identity(): Quaternion;
  3677. /**
  3678. * Gets a boolean indicating if the given quaternion is identity
  3679. * @param quaternion defines the quaternion to check
  3680. * @returns true if the quaternion is identity
  3681. */
  3682. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3683. /**
  3684. * Creates a quaternion from a rotation around an axis
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3688. */
  3689. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3690. /**
  3691. * Creates a rotation around an axis and stores it into the given quaternion
  3692. * @param axis defines the axis to use
  3693. * @param angle defines the angle to use
  3694. * @param result defines the target quaternion
  3695. * @returns the target quaternion
  3696. */
  3697. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3698. /**
  3699. * Creates a new quaternion from data stored into an array
  3700. * @param array defines the data source
  3701. * @param offset defines the offset in the source array where the data starts
  3702. * @returns a new quaternion
  3703. */
  3704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3705. /**
  3706. * Create a quaternion from Euler rotation angles
  3707. * @param x Pitch
  3708. * @param y Yaw
  3709. * @param z Roll
  3710. * @returns the new Quaternion
  3711. */
  3712. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3713. /**
  3714. * Updates a quaternion from Euler rotation angles
  3715. * @param x Pitch
  3716. * @param y Yaw
  3717. * @param z Roll
  3718. * @param result the quaternion to store the result
  3719. * @returns the updated quaternion
  3720. */
  3721. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Create a quaternion from Euler rotation vector
  3724. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3725. * @returns the new Quaternion
  3726. */
  3727. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3728. /**
  3729. * Updates a quaternion from Euler rotation vector
  3730. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3731. * @param result the quaternion to store the result
  3732. * @returns the updated quaternion
  3733. */
  3734. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3737. * @param yaw defines the rotation around Y axis
  3738. * @param pitch defines the rotation around X axis
  3739. * @param roll defines the rotation around Z axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3743. /**
  3744. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3745. * @param yaw defines the rotation around Y axis
  3746. * @param pitch defines the rotation around X axis
  3747. * @param roll defines the rotation around Z axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3751. /**
  3752. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3753. * @param alpha defines the rotation around first axis
  3754. * @param beta defines the rotation around second axis
  3755. * @param gamma defines the rotation around third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3761. * @param alpha defines the rotation around first axis
  3762. * @param beta defines the rotation around second axis
  3763. * @param gamma defines the rotation around third axis
  3764. * @param result defines the target quaternion
  3765. */
  3766. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3767. /**
  3768. * 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)
  3769. * @param axis1 defines the first axis
  3770. * @param axis2 defines the second axis
  3771. * @param axis3 defines the third axis
  3772. * @returns the new quaternion
  3773. */
  3774. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3775. /**
  3776. * 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
  3777. * @param axis1 defines the first axis
  3778. * @param axis2 defines the second axis
  3779. * @param axis3 defines the third axis
  3780. * @param ref defines the target quaternion
  3781. */
  3782. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3783. /**
  3784. * Interpolates between two quaternions
  3785. * @param left defines first quaternion
  3786. * @param right defines second quaternion
  3787. * @param amount defines the gradient to use
  3788. * @returns the new interpolated quaternion
  3789. */
  3790. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3791. /**
  3792. * Interpolates between two quaternions and stores it into a target quaternion
  3793. * @param left defines first quaternion
  3794. * @param right defines second quaternion
  3795. * @param amount defines the gradient to use
  3796. * @param result defines the target quaternion
  3797. */
  3798. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3799. /**
  3800. * Interpolate between two quaternions using Hermite interpolation
  3801. * @param value1 defines first quaternion
  3802. * @param tangent1 defines the incoming tangent
  3803. * @param value2 defines second quaternion
  3804. * @param tangent2 defines the outgoing tangent
  3805. * @param amount defines the target quaternion
  3806. * @returns the new interpolated quaternion
  3807. */
  3808. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3809. }
  3810. /**
  3811. * Class used to store matrix data (4x4)
  3812. */
  3813. export class Matrix {
  3814. private static _updateFlagSeed;
  3815. private static _identityReadOnly;
  3816. private _isIdentity;
  3817. private _isIdentityDirty;
  3818. private _isIdentity3x2;
  3819. private _isIdentity3x2Dirty;
  3820. /**
  3821. * Gets the update flag of the matrix which is an unique number for the matrix.
  3822. * It will be incremented every time the matrix data change.
  3823. * You can use it to speed the comparison between two versions of the same matrix.
  3824. */
  3825. updateFlag: number;
  3826. private readonly _m;
  3827. /**
  3828. * Gets the internal data of the matrix
  3829. */
  3830. get m(): DeepImmutable<Float32Array>;
  3831. /** @hidden */
  3832. _markAsUpdated(): void;
  3833. /** @hidden */
  3834. private _updateIdentityStatus;
  3835. /**
  3836. * Creates an empty matrix (filled with zeros)
  3837. */
  3838. constructor();
  3839. /**
  3840. * Check if the current matrix is identity
  3841. * @returns true is the matrix is the identity matrix
  3842. */
  3843. isIdentity(): boolean;
  3844. /**
  3845. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3846. * @returns true is the matrix is the identity matrix
  3847. */
  3848. isIdentityAs3x2(): boolean;
  3849. /**
  3850. * Gets the determinant of the matrix
  3851. * @returns the matrix determinant
  3852. */
  3853. determinant(): number;
  3854. /**
  3855. * Returns the matrix as a Float32Array
  3856. * @returns the matrix underlying array
  3857. */
  3858. toArray(): DeepImmutable<Float32Array>;
  3859. /**
  3860. * Returns the matrix as a Float32Array
  3861. * @returns the matrix underlying array.
  3862. */
  3863. asArray(): DeepImmutable<Float32Array>;
  3864. /**
  3865. * Inverts the current matrix in place
  3866. * @returns the current inverted matrix
  3867. */
  3868. invert(): Matrix;
  3869. /**
  3870. * Sets all the matrix elements to zero
  3871. * @returns the current matrix
  3872. */
  3873. reset(): Matrix;
  3874. /**
  3875. * Adds the current matrix with a second one
  3876. * @param other defines the matrix to add
  3877. * @returns a new matrix as the addition of the current matrix and the given one
  3878. */
  3879. add(other: DeepImmutable<Matrix>): Matrix;
  3880. /**
  3881. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3882. * @param other defines the matrix to add
  3883. * @param result defines the target matrix
  3884. * @returns the current matrix
  3885. */
  3886. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3887. /**
  3888. * Adds in place the given matrix to the current matrix
  3889. * @param other defines the second operand
  3890. * @returns the current updated matrix
  3891. */
  3892. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3893. /**
  3894. * Sets the given matrix to the current inverted Matrix
  3895. * @param other defines the target matrix
  3896. * @returns the unmodified current matrix
  3897. */
  3898. invertToRef(other: Matrix): Matrix;
  3899. /**
  3900. * add a value at the specified position in the current Matrix
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. addAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * mutiply the specified position in the current Matrix by a value
  3908. * @param index the index of the value within the matrix. between 0 and 15.
  3909. * @param value the value to be added
  3910. * @returns the current updated matrix
  3911. */
  3912. multiplyAtIndex(index: number, value: number): Matrix;
  3913. /**
  3914. * Inserts the translation vector (using 3 floats) in the current matrix
  3915. * @param x defines the 1st component of the translation
  3916. * @param y defines the 2nd component of the translation
  3917. * @param z defines the 3rd component of the translation
  3918. * @returns the current updated matrix
  3919. */
  3920. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3921. /**
  3922. * Adds the translation vector (using 3 floats) in the current matrix
  3923. * @param x defines the 1st component of the translation
  3924. * @param y defines the 2nd component of the translation
  3925. * @param z defines the 3rd component of the translation
  3926. * @returns the current updated matrix
  3927. */
  3928. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3929. /**
  3930. * Inserts the translation vector in the current matrix
  3931. * @param vector3 defines the translation to insert
  3932. * @returns the current updated matrix
  3933. */
  3934. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3935. /**
  3936. * Gets the translation value of the current matrix
  3937. * @returns a new Vector3 as the extracted translation from the matrix
  3938. */
  3939. getTranslation(): Vector3;
  3940. /**
  3941. * Fill a Vector3 with the extracted translation from the matrix
  3942. * @param result defines the Vector3 where to store the translation
  3943. * @returns the current matrix
  3944. */
  3945. getTranslationToRef(result: Vector3): Matrix;
  3946. /**
  3947. * Remove rotation and scaling part from the matrix
  3948. * @returns the updated matrix
  3949. */
  3950. removeRotationAndScaling(): Matrix;
  3951. /**
  3952. * Multiply two matrices
  3953. * @param other defines the second operand
  3954. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3955. */
  3956. multiply(other: DeepImmutable<Matrix>): Matrix;
  3957. /**
  3958. * Copy the current matrix from the given one
  3959. * @param other defines the source matrix
  3960. * @returns the current updated matrix
  3961. */
  3962. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3963. /**
  3964. * Populates the given array from the starting index with the current matrix values
  3965. * @param array defines the target array
  3966. * @param offset defines the offset in the target array where to start storing values
  3967. * @returns the current matrix
  3968. */
  3969. copyToArray(array: Float32Array, offset?: number): Matrix;
  3970. /**
  3971. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the matrix where to store the multiplication
  3974. * @returns the current matrix
  3975. */
  3976. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3977. /**
  3978. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3979. * @param other defines the second operand
  3980. * @param result defines the array where to store the multiplication
  3981. * @param offset defines the offset in the target array where to start storing values
  3982. * @returns the current matrix
  3983. */
  3984. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3985. /**
  3986. * Check equality between this matrix and a second one
  3987. * @param value defines the second matrix to compare
  3988. * @returns true is the current matrix and the given one values are strictly equal
  3989. */
  3990. equals(value: DeepImmutable<Matrix>): boolean;
  3991. /**
  3992. * Clone the current matrix
  3993. * @returns a new matrix from the current matrix
  3994. */
  3995. clone(): Matrix;
  3996. /**
  3997. * Returns the name of the current matrix class
  3998. * @returns the string "Matrix"
  3999. */
  4000. getClassName(): string;
  4001. /**
  4002. * Gets the hash code of the current matrix
  4003. * @returns the hash code
  4004. */
  4005. getHashCode(): number;
  4006. /**
  4007. * Decomposes the current Matrix into a translation, rotation and scaling components
  4008. * @param scale defines the scale vector3 given as a reference to update
  4009. * @param rotation defines the rotation quaternion given as a reference to update
  4010. * @param translation defines the translation vector3 given as a reference to update
  4011. * @returns true if operation was successful
  4012. */
  4013. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4014. /**
  4015. * Gets specific row of the matrix
  4016. * @param index defines the number of the row to get
  4017. * @returns the index-th row of the current matrix as a new Vector4
  4018. */
  4019. getRow(index: number): Nullable<Vector4>;
  4020. /**
  4021. * Sets the index-th row of the current matrix to the vector4 values
  4022. * @param index defines the number of the row to set
  4023. * @param row defines the target vector4
  4024. * @returns the updated current matrix
  4025. */
  4026. setRow(index: number, row: Vector4): Matrix;
  4027. /**
  4028. * Compute the transpose of the matrix
  4029. * @returns the new transposed matrix
  4030. */
  4031. transpose(): Matrix;
  4032. /**
  4033. * Compute the transpose of the matrix and store it in a given matrix
  4034. * @param result defines the target matrix
  4035. * @returns the current matrix
  4036. */
  4037. transposeToRef(result: Matrix): Matrix;
  4038. /**
  4039. * Sets the index-th row of the current matrix with the given 4 x float values
  4040. * @param index defines the row index
  4041. * @param x defines the x component to set
  4042. * @param y defines the y component to set
  4043. * @param z defines the z component to set
  4044. * @param w defines the w component to set
  4045. * @returns the updated current matrix
  4046. */
  4047. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4048. /**
  4049. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4050. * @param scale defines the scale factor
  4051. * @returns a new matrix
  4052. */
  4053. scale(scale: number): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor to a given result matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Scale the current matrix values by a factor and add the result to a given matrix
  4063. * @param scale defines the scale factor
  4064. * @param result defines the Matrix to store the result
  4065. * @returns the current matrix
  4066. */
  4067. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4068. /**
  4069. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4070. * @param ref matrix to store the result
  4071. */
  4072. toNormalMatrix(ref: Matrix): void;
  4073. /**
  4074. * Gets only rotation part of the current matrix
  4075. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4076. */
  4077. getRotationMatrix(): Matrix;
  4078. /**
  4079. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4080. * @param result defines the target matrix to store data to
  4081. * @returns the current matrix
  4082. */
  4083. getRotationMatrixToRef(result: Matrix): Matrix;
  4084. /**
  4085. * Toggles model matrix from being right handed to left handed in place and vice versa
  4086. */
  4087. toggleModelMatrixHandInPlace(): void;
  4088. /**
  4089. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4090. */
  4091. toggleProjectionMatrixHandInPlace(): void;
  4092. /**
  4093. * Creates a matrix from an array
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @returns a new Matrix set from the starting index of the given array
  4097. */
  4098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4099. /**
  4100. * Copy the content of an array into a given matrix
  4101. * @param array defines the source array
  4102. * @param offset defines an offset in the source array
  4103. * @param result defines the target matrix
  4104. */
  4105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4106. /**
  4107. * Stores an array into a matrix after having multiplied each component by a given factor
  4108. * @param array defines the source array
  4109. * @param offset defines the offset in the source array
  4110. * @param scale defines the scaling factor
  4111. * @param result defines the target matrix
  4112. */
  4113. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4114. /**
  4115. * Gets an identity matrix that must not be updated
  4116. */
  4117. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4118. /**
  4119. * Stores a list of values (16) inside a given matrix
  4120. * @param initialM11 defines 1st value of 1st row
  4121. * @param initialM12 defines 2nd value of 1st row
  4122. * @param initialM13 defines 3rd value of 1st row
  4123. * @param initialM14 defines 4th value of 1st row
  4124. * @param initialM21 defines 1st value of 2nd row
  4125. * @param initialM22 defines 2nd value of 2nd row
  4126. * @param initialM23 defines 3rd value of 2nd row
  4127. * @param initialM24 defines 4th value of 2nd row
  4128. * @param initialM31 defines 1st value of 3rd row
  4129. * @param initialM32 defines 2nd value of 3rd row
  4130. * @param initialM33 defines 3rd value of 3rd row
  4131. * @param initialM34 defines 4th value of 3rd row
  4132. * @param initialM41 defines 1st value of 4th row
  4133. * @param initialM42 defines 2nd value of 4th row
  4134. * @param initialM43 defines 3rd value of 4th row
  4135. * @param initialM44 defines 4th value of 4th row
  4136. * @param result defines the target matrix
  4137. */
  4138. 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;
  4139. /**
  4140. * Creates new matrix from a list of values (16)
  4141. * @param initialM11 defines 1st value of 1st row
  4142. * @param initialM12 defines 2nd value of 1st row
  4143. * @param initialM13 defines 3rd value of 1st row
  4144. * @param initialM14 defines 4th value of 1st row
  4145. * @param initialM21 defines 1st value of 2nd row
  4146. * @param initialM22 defines 2nd value of 2nd row
  4147. * @param initialM23 defines 3rd value of 2nd row
  4148. * @param initialM24 defines 4th value of 2nd row
  4149. * @param initialM31 defines 1st value of 3rd row
  4150. * @param initialM32 defines 2nd value of 3rd row
  4151. * @param initialM33 defines 3rd value of 3rd row
  4152. * @param initialM34 defines 4th value of 3rd row
  4153. * @param initialM41 defines 1st value of 4th row
  4154. * @param initialM42 defines 2nd value of 4th row
  4155. * @param initialM43 defines 3rd value of 4th row
  4156. * @param initialM44 defines 4th value of 4th row
  4157. * @returns the new matrix
  4158. */
  4159. 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;
  4160. /**
  4161. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4162. * @param scale defines the scale vector3
  4163. * @param rotation defines the rotation quaternion
  4164. * @param translation defines the translation vector3
  4165. * @returns a new matrix
  4166. */
  4167. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4168. /**
  4169. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4170. * @param scale defines the scale vector3
  4171. * @param rotation defines the rotation quaternion
  4172. * @param translation defines the translation vector3
  4173. * @param result defines the target matrix
  4174. */
  4175. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4176. /**
  4177. * Creates a new identity matrix
  4178. * @returns a new identity matrix
  4179. */
  4180. static Identity(): Matrix;
  4181. /**
  4182. * Creates a new identity matrix and stores the result in a given matrix
  4183. * @param result defines the target matrix
  4184. */
  4185. static IdentityToRef(result: Matrix): void;
  4186. /**
  4187. * Creates a new zero matrix
  4188. * @returns a new zero matrix
  4189. */
  4190. static Zero(): Matrix;
  4191. /**
  4192. * Creates a new rotation matrix for "angle" radians around the X axis
  4193. * @param angle defines the angle (in radians) to use
  4194. * @return the new matrix
  4195. */
  4196. static RotationX(angle: number): Matrix;
  4197. /**
  4198. * Creates a new matrix as the invert of a given matrix
  4199. * @param source defines the source matrix
  4200. * @returns the new matrix
  4201. */
  4202. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4203. /**
  4204. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4205. * @param angle defines the angle (in radians) to use
  4206. * @param result defines the target matrix
  4207. */
  4208. static RotationXToRef(angle: number, result: Matrix): void;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the Y axis
  4211. * @param angle defines the angle (in radians) to use
  4212. * @return the new matrix
  4213. */
  4214. static RotationY(angle: number): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4217. * @param angle defines the angle (in radians) to use
  4218. * @param result defines the target matrix
  4219. */
  4220. static RotationYToRef(angle: number, result: Matrix): void;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the Z axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationZ(angle: number): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationZToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @return the new matrix
  4238. */
  4239. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4240. /**
  4241. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4242. * @param axis defines the axis to use
  4243. * @param angle defines the angle (in radians) to use
  4244. * @param result defines the target matrix
  4245. */
  4246. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4247. /**
  4248. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4249. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4250. * @param from defines the vector to align
  4251. * @param to defines the vector to align to
  4252. * @param result defines the target matrix
  4253. */
  4254. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4255. /**
  4256. * Creates a rotation matrix
  4257. * @param yaw defines the yaw angle in radians (Y axis)
  4258. * @param pitch defines the pitch angle in radians (X axis)
  4259. * @param roll defines the roll angle in radians (X axis)
  4260. * @returns the new rotation matrix
  4261. */
  4262. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4263. /**
  4264. * Creates a rotation matrix and stores it in a given matrix
  4265. * @param yaw defines the yaw angle in radians (Y axis)
  4266. * @param pitch defines the pitch angle in radians (X axis)
  4267. * @param roll defines the roll angle in radians (X axis)
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4271. /**
  4272. * Creates a scaling matrix
  4273. * @param x defines the scale factor on X axis
  4274. * @param y defines the scale factor on Y axis
  4275. * @param z defines the scale factor on Z axis
  4276. * @returns the new matrix
  4277. */
  4278. static Scaling(x: number, y: number, z: number): Matrix;
  4279. /**
  4280. * Creates a scaling matrix and stores it in a given matrix
  4281. * @param x defines the scale factor on X axis
  4282. * @param y defines the scale factor on Y axis
  4283. * @param z defines the scale factor on Z axis
  4284. * @param result defines the target matrix
  4285. */
  4286. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4287. /**
  4288. * Creates a translation matrix
  4289. * @param x defines the translation on X axis
  4290. * @param y defines the translation on Y axis
  4291. * @param z defines the translationon Z axis
  4292. * @returns the new matrix
  4293. */
  4294. static Translation(x: number, y: number, z: number): Matrix;
  4295. /**
  4296. * Creates a translation matrix and stores it in a given matrix
  4297. * @param x defines the translation on X axis
  4298. * @param y defines the translation on Y axis
  4299. * @param z defines the translationon Z axis
  4300. * @param result defines the target matrix
  4301. */
  4302. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4303. /**
  4304. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4305. * @param startValue defines the start value
  4306. * @param endValue defines the end value
  4307. * @param gradient defines the gradient factor
  4308. * @returns the new matrix
  4309. */
  4310. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4311. /**
  4312. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4313. * @param startValue defines the start value
  4314. * @param endValue defines the end value
  4315. * @param gradient defines the gradient factor
  4316. * @param result defines the Matrix object where to store data
  4317. */
  4318. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4319. /**
  4320. * Builds a new matrix whose values are computed by:
  4321. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4322. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4323. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4324. * @param startValue defines the first matrix
  4325. * @param endValue defines the second matrix
  4326. * @param gradient defines the gradient between the two matrices
  4327. * @returns the new matrix
  4328. */
  4329. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4330. /**
  4331. * Update a matrix to values which are computed by:
  4332. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4333. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4334. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4335. * @param startValue defines the first matrix
  4336. * @param endValue defines the second matrix
  4337. * @param gradient defines the gradient between the two matrices
  4338. * @param result defines the target matrix
  4339. */
  4340. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4341. /**
  4342. * 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"
  4343. * This function works in left handed mode
  4344. * @param eye defines the final position of the entity
  4345. * @param target defines where the entity should look at
  4346. * @param up defines the up vector for the entity
  4347. * @returns the new matrix
  4348. */
  4349. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * 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".
  4352. * This function works in left handed mode
  4353. * @param eye defines the final position of the entity
  4354. * @param target defines where the entity should look at
  4355. * @param up defines the up vector for the entity
  4356. * @param result defines the target matrix
  4357. */
  4358. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4359. /**
  4360. * 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"
  4361. * This function works in right handed mode
  4362. * @param eye defines the final position of the entity
  4363. * @param target defines where the entity should look at
  4364. * @param up defines the up vector for the entity
  4365. * @returns the new matrix
  4366. */
  4367. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4368. /**
  4369. * 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".
  4370. * This function works in right handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @param result defines the target matrix
  4375. */
  4376. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4377. /**
  4378. * Create a left-handed orthographic projection matrix
  4379. * @param width defines the viewport width
  4380. * @param height defines the viewport height
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @returns a new matrix as a left-handed orthographic projection matrix
  4384. */
  4385. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4386. /**
  4387. * Store a left-handed orthographic projection to a given matrix
  4388. * @param width defines the viewport width
  4389. * @param height defines the viewport height
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @param result defines the target matrix
  4393. */
  4394. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4395. /**
  4396. * Create a left-handed orthographic projection matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @returns a new matrix as a left-handed orthographic projection matrix
  4404. */
  4405. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4406. /**
  4407. * Stores a left-handed orthographic projection into a given matrix
  4408. * @param left defines the viewport left coordinate
  4409. * @param right defines the viewport right coordinate
  4410. * @param bottom defines the viewport bottom coordinate
  4411. * @param top defines the viewport top coordinate
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @param result defines the target matrix
  4415. */
  4416. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4417. /**
  4418. * Creates a right-handed orthographic projection matrix
  4419. * @param left defines the viewport left coordinate
  4420. * @param right defines the viewport right coordinate
  4421. * @param bottom defines the viewport bottom coordinate
  4422. * @param top defines the viewport top coordinate
  4423. * @param znear defines the near clip plane
  4424. * @param zfar defines the far clip plane
  4425. * @returns a new matrix as a right-handed orthographic projection matrix
  4426. */
  4427. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4428. /**
  4429. * Stores a right-handed orthographic projection into a given matrix
  4430. * @param left defines the viewport left coordinate
  4431. * @param right defines the viewport right coordinate
  4432. * @param bottom defines the viewport bottom coordinate
  4433. * @param top defines the viewport top coordinate
  4434. * @param znear defines the near clip plane
  4435. * @param zfar defines the far clip plane
  4436. * @param result defines the target matrix
  4437. */
  4438. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4439. /**
  4440. * Creates a left-handed perspective projection matrix
  4441. * @param width defines the viewport width
  4442. * @param height defines the viewport height
  4443. * @param znear defines the near clip plane
  4444. * @param zfar defines the far clip plane
  4445. * @returns a new matrix as a left-handed perspective projection matrix
  4446. */
  4447. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4448. /**
  4449. * Creates a left-handed perspective projection matrix
  4450. * @param fov defines the horizontal field of view
  4451. * @param aspect defines the aspect ratio
  4452. * @param znear defines the near clip plane
  4453. * @param zfar defines the far clip plane
  4454. * @returns a new matrix as a left-handed perspective projection matrix
  4455. */
  4456. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4457. /**
  4458. * Stores a left-handed perspective projection into a given matrix
  4459. * @param fov defines the horizontal field of view
  4460. * @param aspect defines the aspect ratio
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @param result defines the target matrix
  4464. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4465. */
  4466. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4467. /**
  4468. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4469. * @param fov defines the horizontal field of view
  4470. * @param aspect defines the aspect ratio
  4471. * @param znear defines the near clip plane
  4472. * @param zfar not used as infinity is used as far clip
  4473. * @param result defines the target matrix
  4474. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4475. */
  4476. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4477. /**
  4478. * Creates a right-handed perspective projection matrix
  4479. * @param fov defines the horizontal field of view
  4480. * @param aspect defines the aspect ratio
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed perspective projection matrix
  4484. */
  4485. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed perspective projection into a given matrix
  4488. * @param fov defines the horizontal field of view
  4489. * @param aspect defines the aspect ratio
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4494. */
  4495. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4496. /**
  4497. * Stores a right-handed perspective projection into a given matrix
  4498. * @param fov defines the horizontal field of view
  4499. * @param aspect defines the aspect ratio
  4500. * @param znear defines the near clip plane
  4501. * @param zfar not used as infinity is used as far clip
  4502. * @param result defines the target matrix
  4503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4504. */
  4505. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4506. /**
  4507. * Stores a perspective projection for WebVR info a given matrix
  4508. * @param fov defines the field of view
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @param result defines the target matrix
  4512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4513. */
  4514. static PerspectiveFovWebVRToRef(fov: {
  4515. upDegrees: number;
  4516. downDegrees: number;
  4517. leftDegrees: number;
  4518. rightDegrees: number;
  4519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4520. /**
  4521. * Computes a complete transformation matrix
  4522. * @param viewport defines the viewport to use
  4523. * @param world defines the world matrix
  4524. * @param view defines the view matrix
  4525. * @param projection defines the projection matrix
  4526. * @param zmin defines the near clip plane
  4527. * @param zmax defines the far clip plane
  4528. * @returns the transformation matrix
  4529. */
  4530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4531. /**
  4532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4533. * @param matrix defines the matrix to use
  4534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4535. */
  4536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4537. /**
  4538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4539. * @param matrix defines the matrix to use
  4540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4541. */
  4542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4543. /**
  4544. * Compute the transpose of a given matrix
  4545. * @param matrix defines the matrix to transpose
  4546. * @returns the new matrix
  4547. */
  4548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4549. /**
  4550. * Compute the transpose of a matrix and store it in a target matrix
  4551. * @param matrix defines the matrix to transpose
  4552. * @param result defines the target matrix
  4553. */
  4554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4555. /**
  4556. * Computes a reflection matrix from a plane
  4557. * @param plane defines the reflection plane
  4558. * @returns a new matrix
  4559. */
  4560. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4561. /**
  4562. * Computes a reflection matrix from a plane
  4563. * @param plane defines the reflection plane
  4564. * @param result defines the target matrix
  4565. */
  4566. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4567. /**
  4568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4569. * @param xaxis defines the value of the 1st axis
  4570. * @param yaxis defines the value of the 2nd axis
  4571. * @param zaxis defines the value of the 3rd axis
  4572. * @param result defines the target matrix
  4573. */
  4574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4575. /**
  4576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4577. * @param quat defines the quaternion to use
  4578. * @param result defines the target matrix
  4579. */
  4580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4581. }
  4582. /**
  4583. * @hidden
  4584. */
  4585. export class TmpVectors {
  4586. static Vector2: Vector2[];
  4587. static Vector3: Vector3[];
  4588. static Vector4: Vector4[];
  4589. static Quaternion: Quaternion[];
  4590. static Matrix: Matrix[];
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /**
  4595. * Defines potential orientation for back face culling
  4596. */
  4597. export enum Orientation {
  4598. /**
  4599. * Clockwise
  4600. */
  4601. CW = 0,
  4602. /** Counter clockwise */
  4603. CCW = 1
  4604. }
  4605. /** Class used to represent a Bezier curve */
  4606. export class BezierCurve {
  4607. /**
  4608. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4609. * @param t defines the time
  4610. * @param x1 defines the left coordinate on X axis
  4611. * @param y1 defines the left coordinate on Y axis
  4612. * @param x2 defines the right coordinate on X axis
  4613. * @param y2 defines the right coordinate on Y axis
  4614. * @returns the interpolated value
  4615. */
  4616. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4617. }
  4618. /**
  4619. * Defines angle representation
  4620. */
  4621. export class Angle {
  4622. private _radians;
  4623. /**
  4624. * Creates an Angle object of "radians" radians (float).
  4625. * @param radians the angle in radians
  4626. */
  4627. constructor(radians: number);
  4628. /**
  4629. * Get value in degrees
  4630. * @returns the Angle value in degrees (float)
  4631. */
  4632. degrees(): number;
  4633. /**
  4634. * Get value in radians
  4635. * @returns the Angle value in radians (float)
  4636. */
  4637. radians(): number;
  4638. /**
  4639. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4640. * @param a defines first vector
  4641. * @param b defines second vector
  4642. * @returns a new Angle
  4643. */
  4644. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4645. /**
  4646. * Gets a new Angle object from the given float in radians
  4647. * @param radians defines the angle value in radians
  4648. * @returns a new Angle
  4649. */
  4650. static FromRadians(radians: number): Angle;
  4651. /**
  4652. * Gets a new Angle object from the given float in degrees
  4653. * @param degrees defines the angle value in degrees
  4654. * @returns a new Angle
  4655. */
  4656. static FromDegrees(degrees: number): Angle;
  4657. }
  4658. /**
  4659. * This represents an arc in a 2d space.
  4660. */
  4661. export class Arc2 {
  4662. /** Defines the start point of the arc */
  4663. startPoint: Vector2;
  4664. /** Defines the mid point of the arc */
  4665. midPoint: Vector2;
  4666. /** Defines the end point of the arc */
  4667. endPoint: Vector2;
  4668. /**
  4669. * Defines the center point of the arc.
  4670. */
  4671. centerPoint: Vector2;
  4672. /**
  4673. * Defines the radius of the arc.
  4674. */
  4675. radius: number;
  4676. /**
  4677. * Defines the angle of the arc (from mid point to end point).
  4678. */
  4679. angle: Angle;
  4680. /**
  4681. * Defines the start angle of the arc (from start point to middle point).
  4682. */
  4683. startAngle: Angle;
  4684. /**
  4685. * Defines the orientation of the arc (clock wise/counter clock wise).
  4686. */
  4687. orientation: Orientation;
  4688. /**
  4689. * Creates an Arc object from the three given points : start, middle and end.
  4690. * @param startPoint Defines the start point of the arc
  4691. * @param midPoint Defines the midlle point of the arc
  4692. * @param endPoint Defines the end point of the arc
  4693. */
  4694. constructor(
  4695. /** Defines the start point of the arc */
  4696. startPoint: Vector2,
  4697. /** Defines the mid point of the arc */
  4698. midPoint: Vector2,
  4699. /** Defines the end point of the arc */
  4700. endPoint: Vector2);
  4701. }
  4702. /**
  4703. * Represents a 2D path made up of multiple 2D points
  4704. */
  4705. export class Path2 {
  4706. private _points;
  4707. private _length;
  4708. /**
  4709. * If the path start and end point are the same
  4710. */
  4711. closed: boolean;
  4712. /**
  4713. * Creates a Path2 object from the starting 2D coordinates x and y.
  4714. * @param x the starting points x value
  4715. * @param y the starting points y value
  4716. */
  4717. constructor(x: number, y: number);
  4718. /**
  4719. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4720. * @param x the added points x value
  4721. * @param y the added points y value
  4722. * @returns the updated Path2.
  4723. */
  4724. addLineTo(x: number, y: number): Path2;
  4725. /**
  4726. * 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.
  4727. * @param midX middle point x value
  4728. * @param midY middle point y value
  4729. * @param endX end point x value
  4730. * @param endY end point y value
  4731. * @param numberOfSegments (default: 36)
  4732. * @returns the updated Path2.
  4733. */
  4734. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4735. /**
  4736. * Closes the Path2.
  4737. * @returns the Path2.
  4738. */
  4739. close(): Path2;
  4740. /**
  4741. * Gets the sum of the distance between each sequential point in the path
  4742. * @returns the Path2 total length (float).
  4743. */
  4744. length(): number;
  4745. /**
  4746. * Gets the points which construct the path
  4747. * @returns the Path2 internal array of points.
  4748. */
  4749. getPoints(): Vector2[];
  4750. /**
  4751. * Retreives the point at the distance aways from the starting point
  4752. * @param normalizedLengthPosition the length along the path to retreive the point from
  4753. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4754. */
  4755. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4756. /**
  4757. * Creates a new path starting from an x and y position
  4758. * @param x starting x value
  4759. * @param y starting y value
  4760. * @returns a new Path2 starting at the coordinates (x, y).
  4761. */
  4762. static StartingAt(x: number, y: number): Path2;
  4763. }
  4764. /**
  4765. * Represents a 3D path made up of multiple 3D points
  4766. */
  4767. export class Path3D {
  4768. /**
  4769. * an array of Vector3, the curve axis of the Path3D
  4770. */
  4771. path: Vector3[];
  4772. private _curve;
  4773. private _distances;
  4774. private _tangents;
  4775. private _normals;
  4776. private _binormals;
  4777. private _raw;
  4778. private _alignTangentsWithPath;
  4779. private readonly _pointAtData;
  4780. /**
  4781. * new Path3D(path, normal, raw)
  4782. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4783. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4784. * @param path an array of Vector3, the curve axis of the Path3D
  4785. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4786. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4787. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4788. */
  4789. constructor(
  4790. /**
  4791. * an array of Vector3, the curve axis of the Path3D
  4792. */
  4793. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4794. /**
  4795. * Returns the Path3D array of successive Vector3 designing its curve.
  4796. * @returns the Path3D array of successive Vector3 designing its curve.
  4797. */
  4798. getCurve(): Vector3[];
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getPoints(): Vector3[];
  4804. /**
  4805. * @returns the computed length (float) of the path.
  4806. */
  4807. length(): number;
  4808. /**
  4809. * Returns an array populated with tangent vectors on each Path3D curve point.
  4810. * @returns an array populated with tangent vectors on each Path3D curve point.
  4811. */
  4812. getTangents(): Vector3[];
  4813. /**
  4814. * Returns an array populated with normal vectors on each Path3D curve point.
  4815. * @returns an array populated with normal vectors on each Path3D curve point.
  4816. */
  4817. getNormals(): Vector3[];
  4818. /**
  4819. * Returns an array populated with binormal vectors on each Path3D curve point.
  4820. * @returns an array populated with binormal vectors on each Path3D curve point.
  4821. */
  4822. getBinormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4825. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4826. */
  4827. getDistances(): number[];
  4828. /**
  4829. * Returns an interpolated point along this path
  4830. * @param position the position of the point along this path, from 0.0 to 1.0
  4831. * @returns a new Vector3 as the point
  4832. */
  4833. getPointAt(position: number): Vector3;
  4834. /**
  4835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4836. * @param position the position of the point along this path, from 0.0 to 1.0
  4837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4838. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4839. */
  4840. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4841. /**
  4842. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4843. * @param position the position of the point along this path, from 0.0 to 1.0
  4844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4845. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4846. */
  4847. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4848. /**
  4849. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4850. * @param position the position of the point along this path, from 0.0 to 1.0
  4851. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4852. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4853. */
  4854. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4855. /**
  4856. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4857. * @param position the position of the point along this path, from 0.0 to 1.0
  4858. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4859. */
  4860. getDistanceAt(position: number): number;
  4861. /**
  4862. * Returns the array index of the previous point of an interpolated point along this path
  4863. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4864. * @returns the array index
  4865. */
  4866. getPreviousPointIndexAt(position: number): number;
  4867. /**
  4868. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4869. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4870. * @returns the sub position
  4871. */
  4872. getSubPositionAt(position: number): number;
  4873. /**
  4874. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4875. * @param target the vector of which to get the closest position to
  4876. * @returns the position of the closest virtual point on this path to the target vector
  4877. */
  4878. getClosestPositionTo(target: Vector3): number;
  4879. /**
  4880. * Returns a sub path (slice) of this path
  4881. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4882. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4883. * @returns a sub path (slice) of this path
  4884. */
  4885. slice(start?: number, end?: number): Path3D;
  4886. /**
  4887. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4888. * @param path path which all values are copied into the curves points
  4889. * @param firstNormal which should be projected onto the curve
  4890. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4891. * @returns the same object updated.
  4892. */
  4893. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4894. private _compute;
  4895. private _getFirstNonNullVector;
  4896. private _getLastNonNullVector;
  4897. private _normalVector;
  4898. /**
  4899. * Updates the point at data for an interpolated point along this curve
  4900. * @param position the position of the point along this curve, from 0.0 to 1.0
  4901. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4902. * @returns the (updated) point at data
  4903. */
  4904. private _updatePointAtData;
  4905. /**
  4906. * Updates the point at data from the specified parameters
  4907. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4908. * @param point the interpolated point
  4909. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4910. */
  4911. private _setPointAtData;
  4912. /**
  4913. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4914. */
  4915. private _updateInterpolationMatrix;
  4916. }
  4917. /**
  4918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4919. * A Curve3 is designed from a series of successive Vector3.
  4920. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4921. */
  4922. export class Curve3 {
  4923. private _points;
  4924. private _length;
  4925. /**
  4926. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4927. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4928. * @param v1 (Vector3) the control point
  4929. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4930. * @param nbPoints (integer) the wanted number of points in the curve
  4931. * @returns the created Curve3
  4932. */
  4933. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4934. /**
  4935. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4936. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4937. * @param v1 (Vector3) the first control point
  4938. * @param v2 (Vector3) the second control point
  4939. * @param v3 (Vector3) the end point of the Cubic Bezier
  4940. * @param nbPoints (integer) the wanted number of points in the curve
  4941. * @returns the created Curve3
  4942. */
  4943. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4944. /**
  4945. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4946. * @param p1 (Vector3) the origin point of the Hermite Spline
  4947. * @param t1 (Vector3) the tangent vector at the origin point
  4948. * @param p2 (Vector3) the end point of the Hermite Spline
  4949. * @param t2 (Vector3) the tangent vector at the end point
  4950. * @param nbPoints (integer) the wanted number of points in the curve
  4951. * @returns the created Curve3
  4952. */
  4953. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4954. /**
  4955. * Returns a Curve3 object along a CatmullRom Spline curve :
  4956. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4957. * @param nbPoints (integer) the wanted number of points between each curve control points
  4958. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4959. * @returns the created Curve3
  4960. */
  4961. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4962. /**
  4963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4964. * A Curve3 is designed from a series of successive Vector3.
  4965. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4966. * @param points points which make up the curve
  4967. */
  4968. constructor(points: Vector3[]);
  4969. /**
  4970. * @returns the Curve3 stored array of successive Vector3
  4971. */
  4972. getPoints(): Vector3[];
  4973. /**
  4974. * @returns the computed length (float) of the curve.
  4975. */
  4976. length(): number;
  4977. /**
  4978. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4979. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4980. * curveA and curveB keep unchanged.
  4981. * @param curve the curve to continue from this curve
  4982. * @returns the newly constructed curve
  4983. */
  4984. continue(curve: DeepImmutable<Curve3>): Curve3;
  4985. private _computeLength;
  4986. }
  4987. }
  4988. declare module BABYLON {
  4989. /**
  4990. * This represents the main contract an easing function should follow.
  4991. * Easing functions are used throughout the animation system.
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export interface IEasingFunction {
  4995. /**
  4996. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4997. * of the easing function.
  4998. * The link below provides some of the most common examples of easing functions.
  4999. * @see https://easings.net/
  5000. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5001. * @returns the corresponding value on the curve defined by the easing function
  5002. */
  5003. ease(gradient: number): number;
  5004. }
  5005. /**
  5006. * Base class used for every default easing function.
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class EasingFunction implements IEasingFunction {
  5010. /**
  5011. * Interpolation follows the mathematical formula associated with the easing function.
  5012. */
  5013. static readonly EASINGMODE_EASEIN: number;
  5014. /**
  5015. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5016. */
  5017. static readonly EASINGMODE_EASEOUT: number;
  5018. /**
  5019. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5020. */
  5021. static readonly EASINGMODE_EASEINOUT: number;
  5022. private _easingMode;
  5023. /**
  5024. * Sets the easing mode of the current function.
  5025. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5026. */
  5027. setEasingMode(easingMode: number): void;
  5028. /**
  5029. * Gets the current easing mode.
  5030. * @returns the easing mode
  5031. */
  5032. getEasingMode(): number;
  5033. /**
  5034. * @hidden
  5035. */
  5036. easeInCore(gradient: number): number;
  5037. /**
  5038. * Given an input gradient between 0 and 1, this returns the corresponding value
  5039. * of the easing function.
  5040. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5041. * @returns the corresponding value on the curve defined by the easing function
  5042. */
  5043. ease(gradient: number): number;
  5044. }
  5045. /**
  5046. * Easing function with a circle shape (see link below).
  5047. * @see https://easings.net/#easeInCirc
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class CircleEase extends EasingFunction implements IEasingFunction {
  5051. /** @hidden */
  5052. easeInCore(gradient: number): number;
  5053. }
  5054. /**
  5055. * Easing function with a ease back shape (see link below).
  5056. * @see https://easings.net/#easeInBack
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class BackEase extends EasingFunction implements IEasingFunction {
  5060. /** Defines the amplitude of the function */
  5061. amplitude: number;
  5062. /**
  5063. * Instantiates a back ease easing
  5064. * @see https://easings.net/#easeInBack
  5065. * @param amplitude Defines the amplitude of the function
  5066. */
  5067. constructor(
  5068. /** Defines the amplitude of the function */
  5069. amplitude?: number);
  5070. /** @hidden */
  5071. easeInCore(gradient: number): number;
  5072. }
  5073. /**
  5074. * Easing function with a bouncing shape (see link below).
  5075. * @see https://easings.net/#easeInBounce
  5076. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5077. */
  5078. export class BounceEase extends EasingFunction implements IEasingFunction {
  5079. /** Defines the number of bounces */
  5080. bounces: number;
  5081. /** Defines the amplitude of the bounce */
  5082. bounciness: number;
  5083. /**
  5084. * Instantiates a bounce easing
  5085. * @see https://easings.net/#easeInBounce
  5086. * @param bounces Defines the number of bounces
  5087. * @param bounciness Defines the amplitude of the bounce
  5088. */
  5089. constructor(
  5090. /** Defines the number of bounces */
  5091. bounces?: number,
  5092. /** Defines the amplitude of the bounce */
  5093. bounciness?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a power of 3 shape (see link below).
  5099. * @see https://easings.net/#easeInCubic
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CubicEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with an elastic shape (see link below).
  5108. * @see https://easings.net/#easeInElastic
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the number of oscillations*/
  5113. oscillations: number;
  5114. /** Defines the amplitude of the oscillations*/
  5115. springiness: number;
  5116. /**
  5117. * Instantiates an elastic easing function
  5118. * @see https://easings.net/#easeInElastic
  5119. * @param oscillations Defines the number of oscillations
  5120. * @param springiness Defines the amplitude of the oscillations
  5121. */
  5122. constructor(
  5123. /** Defines the number of oscillations*/
  5124. oscillations?: number,
  5125. /** Defines the amplitude of the oscillations*/
  5126. springiness?: number);
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an exponential shape (see link below).
  5132. * @see https://easings.net/#easeInExpo
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the exponent of the function */
  5137. exponent: number;
  5138. /**
  5139. * Instantiates an exponential easing function
  5140. * @see https://easings.net/#easeInExpo
  5141. * @param exponent Defines the exponent of the function
  5142. */
  5143. constructor(
  5144. /** Defines the exponent of the function */
  5145. exponent?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power shape (see link below).
  5151. * @see https://easings.net/#easeInQuad
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class PowerEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the power of the function */
  5156. power: number;
  5157. /**
  5158. * Instantiates an power base easing function
  5159. * @see https://easings.net/#easeInQuad
  5160. * @param power Defines the power of the function
  5161. */
  5162. constructor(
  5163. /** Defines the power of the function */
  5164. power?: number);
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with a power of 2 shape (see link below).
  5170. * @see https://easings.net/#easeInQuad
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a power of 4 shape (see link below).
  5179. * @see https://easings.net/#easeInQuart
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5183. /** @hidden */
  5184. easeInCore(gradient: number): number;
  5185. }
  5186. /**
  5187. * Easing function with a power of 5 shape (see link below).
  5188. * @see https://easings.net/#easeInQuint
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5192. /** @hidden */
  5193. easeInCore(gradient: number): number;
  5194. }
  5195. /**
  5196. * Easing function with a sin shape (see link below).
  5197. * @see https://easings.net/#easeInSine
  5198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5199. */
  5200. export class SineEase extends EasingFunction implements IEasingFunction {
  5201. /** @hidden */
  5202. easeInCore(gradient: number): number;
  5203. }
  5204. /**
  5205. * Easing function with a bezier shape (see link below).
  5206. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5208. */
  5209. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5210. /** Defines the x component of the start tangent in the bezier curve */
  5211. x1: number;
  5212. /** Defines the y component of the start tangent in the bezier curve */
  5213. y1: number;
  5214. /** Defines the x component of the end tangent in the bezier curve */
  5215. x2: number;
  5216. /** Defines the y component of the end tangent in the bezier curve */
  5217. y2: number;
  5218. /**
  5219. * Instantiates a bezier function
  5220. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5221. * @param x1 Defines the x component of the start tangent in the bezier curve
  5222. * @param y1 Defines the y component of the start tangent in the bezier curve
  5223. * @param x2 Defines the x component of the end tangent in the bezier curve
  5224. * @param y2 Defines the y component of the end tangent in the bezier curve
  5225. */
  5226. constructor(
  5227. /** Defines the x component of the start tangent in the bezier curve */
  5228. x1?: number,
  5229. /** Defines the y component of the start tangent in the bezier curve */
  5230. y1?: number,
  5231. /** Defines the x component of the end tangent in the bezier curve */
  5232. x2?: number,
  5233. /** Defines the y component of the end tangent in the bezier curve */
  5234. y2?: number);
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to hold a RBG color
  5242. */
  5243. export class Color3 {
  5244. /**
  5245. * Defines the red component (between 0 and 1, default is 0)
  5246. */
  5247. r: number;
  5248. /**
  5249. * Defines the green component (between 0 and 1, default is 0)
  5250. */
  5251. g: number;
  5252. /**
  5253. * Defines the blue component (between 0 and 1, default is 0)
  5254. */
  5255. b: number;
  5256. /**
  5257. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5258. * @param r defines the red component (between 0 and 1, default is 0)
  5259. * @param g defines the green component (between 0 and 1, default is 0)
  5260. * @param b defines the blue component (between 0 and 1, default is 0)
  5261. */
  5262. constructor(
  5263. /**
  5264. * Defines the red component (between 0 and 1, default is 0)
  5265. */
  5266. r?: number,
  5267. /**
  5268. * Defines the green component (between 0 and 1, default is 0)
  5269. */
  5270. g?: number,
  5271. /**
  5272. * Defines the blue component (between 0 and 1, default is 0)
  5273. */
  5274. b?: number);
  5275. /**
  5276. * Creates a string with the Color3 current values
  5277. * @returns the string representation of the Color3 object
  5278. */
  5279. toString(): string;
  5280. /**
  5281. * Returns the string "Color3"
  5282. * @returns "Color3"
  5283. */
  5284. getClassName(): string;
  5285. /**
  5286. * Compute the Color3 hash code
  5287. * @returns an unique number that can be used to hash Color3 objects
  5288. */
  5289. getHashCode(): number;
  5290. /**
  5291. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5292. * @param array defines the array where to store the r,g,b components
  5293. * @param index defines an optional index in the target array to define where to start storing values
  5294. * @returns the current Color3 object
  5295. */
  5296. toArray(array: FloatArray, index?: number): Color3;
  5297. /**
  5298. * Returns a new Color4 object from the current Color3 and the given alpha
  5299. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5300. * @returns a new Color4 object
  5301. */
  5302. toColor4(alpha?: number): Color4;
  5303. /**
  5304. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5305. * @returns the new array
  5306. */
  5307. asArray(): number[];
  5308. /**
  5309. * Returns the luminance value
  5310. * @returns a float value
  5311. */
  5312. toLuminance(): number;
  5313. /**
  5314. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5315. * @param otherColor defines the second operand
  5316. * @returns the new Color3 object
  5317. */
  5318. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5319. /**
  5320. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5321. * @param otherColor defines the second operand
  5322. * @param result defines the Color3 object where to store the result
  5323. * @returns the current Color3
  5324. */
  5325. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5326. /**
  5327. * Determines equality between Color3 objects
  5328. * @param otherColor defines the second operand
  5329. * @returns true if the rgb values are equal to the given ones
  5330. */
  5331. equals(otherColor: DeepImmutable<Color3>): boolean;
  5332. /**
  5333. * Determines equality between the current Color3 object and a set of r,b,g values
  5334. * @param r defines the red component to check
  5335. * @param g defines the green component to check
  5336. * @param b defines the blue component to check
  5337. * @returns true if the rgb values are equal to the given ones
  5338. */
  5339. equalsFloats(r: number, g: number, b: number): boolean;
  5340. /**
  5341. * Multiplies in place each rgb value by scale
  5342. * @param scale defines the scaling factor
  5343. * @returns the updated Color3
  5344. */
  5345. scale(scale: number): Color3;
  5346. /**
  5347. * Multiplies the rgb values by scale and stores the result into "result"
  5348. * @param scale defines the scaling factor
  5349. * @param result defines the Color3 object where to store the result
  5350. * @returns the unmodified current Color3
  5351. */
  5352. scaleToRef(scale: number, result: Color3): Color3;
  5353. /**
  5354. * Scale the current Color3 values by a factor and add the result to a given Color3
  5355. * @param scale defines the scale factor
  5356. * @param result defines color to store the result into
  5357. * @returns the unmodified current Color3
  5358. */
  5359. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5360. /**
  5361. * Clamps the rgb values by the min and max values and stores the result into "result"
  5362. * @param min defines minimum clamping value (default is 0)
  5363. * @param max defines maximum clamping value (default is 1)
  5364. * @param result defines color to store the result into
  5365. * @returns the original Color3
  5366. */
  5367. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5368. /**
  5369. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5370. * @param otherColor defines the second operand
  5371. * @returns the new Color3
  5372. */
  5373. add(otherColor: DeepImmutable<Color3>): Color3;
  5374. /**
  5375. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5376. * @param otherColor defines the second operand
  5377. * @param result defines Color3 object to store the result into
  5378. * @returns the unmodified current Color3
  5379. */
  5380. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5381. /**
  5382. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5383. * @param otherColor defines the second operand
  5384. * @returns the new Color3
  5385. */
  5386. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5387. /**
  5388. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5389. * @param otherColor defines the second operand
  5390. * @param result defines Color3 object to store the result into
  5391. * @returns the unmodified current Color3
  5392. */
  5393. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5394. /**
  5395. * Copy the current object
  5396. * @returns a new Color3 copied the current one
  5397. */
  5398. clone(): Color3;
  5399. /**
  5400. * Copies the rgb values from the source in the current Color3
  5401. * @param source defines the source Color3 object
  5402. * @returns the updated Color3 object
  5403. */
  5404. copyFrom(source: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Updates the Color3 rgb values from the given floats
  5407. * @param r defines the red component to read from
  5408. * @param g defines the green component to read from
  5409. * @param b defines the blue component to read from
  5410. * @returns the current Color3 object
  5411. */
  5412. copyFromFloats(r: number, g: number, b: number): Color3;
  5413. /**
  5414. * Updates the Color3 rgb values from the given floats
  5415. * @param r defines the red component to read from
  5416. * @param g defines the green component to read from
  5417. * @param b defines the blue component to read from
  5418. * @returns the current Color3 object
  5419. */
  5420. set(r: number, g: number, b: number): Color3;
  5421. /**
  5422. * Compute the Color3 hexadecimal code as a string
  5423. * @returns a string containing the hexadecimal representation of the Color3 object
  5424. */
  5425. toHexString(): string;
  5426. /**
  5427. * Computes a new Color3 converted from the current one to linear space
  5428. * @returns a new Color3 object
  5429. */
  5430. toLinearSpace(): Color3;
  5431. /**
  5432. * Converts current color in rgb space to HSV values
  5433. * @returns a new color3 representing the HSV values
  5434. */
  5435. toHSV(): Color3;
  5436. /**
  5437. * Converts current color in rgb space to HSV values
  5438. * @param result defines the Color3 where to store the HSV values
  5439. */
  5440. toHSVToRef(result: Color3): void;
  5441. /**
  5442. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5443. * @param convertedColor defines the Color3 object where to store the linear space version
  5444. * @returns the unmodified Color3
  5445. */
  5446. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5447. /**
  5448. * Computes a new Color3 converted from the current one to gamma space
  5449. * @returns a new Color3 object
  5450. */
  5451. toGammaSpace(): Color3;
  5452. /**
  5453. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5454. * @param convertedColor defines the Color3 object where to store the gamma space version
  5455. * @returns the unmodified Color3
  5456. */
  5457. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5458. private static _BlackReadOnly;
  5459. /**
  5460. * Convert Hue, saturation and value to a Color3 (RGB)
  5461. * @param hue defines the hue
  5462. * @param saturation defines the saturation
  5463. * @param value defines the value
  5464. * @param result defines the Color3 where to store the RGB values
  5465. */
  5466. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5467. /**
  5468. * Creates a new Color3 from the string containing valid hexadecimal values
  5469. * @param hex defines a string containing valid hexadecimal values
  5470. * @returns a new Color3 object
  5471. */
  5472. static FromHexString(hex: string): Color3;
  5473. /**
  5474. * Creates a new Color3 from the starting index of the given array
  5475. * @param array defines the source array
  5476. * @param offset defines an offset in the source array
  5477. * @returns a new Color3 object
  5478. */
  5479. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5480. /**
  5481. * Creates a new Color3 from integer values (< 256)
  5482. * @param r defines the red component to read from (value between 0 and 255)
  5483. * @param g defines the green component to read from (value between 0 and 255)
  5484. * @param b defines the blue component to read from (value between 0 and 255)
  5485. * @returns a new Color3 object
  5486. */
  5487. static FromInts(r: number, g: number, b: number): Color3;
  5488. /**
  5489. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5490. * @param start defines the start Color3 value
  5491. * @param end defines the end Color3 value
  5492. * @param amount defines the gradient value between start and end
  5493. * @returns a new Color3 object
  5494. */
  5495. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5496. /**
  5497. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5498. * @param left defines the start value
  5499. * @param right defines the end value
  5500. * @param amount defines the gradient factor
  5501. * @param result defines the Color3 object where to store the result
  5502. */
  5503. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5504. /**
  5505. * Returns a Color3 value containing a red color
  5506. * @returns a new Color3 object
  5507. */
  5508. static Red(): Color3;
  5509. /**
  5510. * Returns a Color3 value containing a green color
  5511. * @returns a new Color3 object
  5512. */
  5513. static Green(): Color3;
  5514. /**
  5515. * Returns a Color3 value containing a blue color
  5516. * @returns a new Color3 object
  5517. */
  5518. static Blue(): Color3;
  5519. /**
  5520. * Returns a Color3 value containing a black color
  5521. * @returns a new Color3 object
  5522. */
  5523. static Black(): Color3;
  5524. /**
  5525. * Gets a Color3 value containing a black color that must not be updated
  5526. */
  5527. static get BlackReadOnly(): DeepImmutable<Color3>;
  5528. /**
  5529. * Returns a Color3 value containing a white color
  5530. * @returns a new Color3 object
  5531. */
  5532. static White(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a purple color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Purple(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a magenta color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Magenta(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a yellow color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Yellow(): Color3;
  5548. /**
  5549. * Returns a Color3 value containing a gray color
  5550. * @returns a new Color3 object
  5551. */
  5552. static Gray(): Color3;
  5553. /**
  5554. * Returns a Color3 value containing a teal color
  5555. * @returns a new Color3 object
  5556. */
  5557. static Teal(): Color3;
  5558. /**
  5559. * Returns a Color3 value containing a random color
  5560. * @returns a new Color3 object
  5561. */
  5562. static Random(): Color3;
  5563. }
  5564. /**
  5565. * Class used to hold a RBGA color
  5566. */
  5567. export class Color4 {
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r: number;
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g: number;
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b: number;
  5580. /**
  5581. * Defines the alpha component (between 0 and 1, default is 1)
  5582. */
  5583. a: number;
  5584. /**
  5585. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5586. * @param r defines the red component (between 0 and 1, default is 0)
  5587. * @param g defines the green component (between 0 and 1, default is 0)
  5588. * @param b defines the blue component (between 0 and 1, default is 0)
  5589. * @param a defines the alpha component (between 0 and 1, default is 1)
  5590. */
  5591. constructor(
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r?: number,
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g?: number,
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b?: number,
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a?: number);
  5608. /**
  5609. * Adds in place the given Color4 values to the current Color4 object
  5610. * @param right defines the second operand
  5611. * @returns the current updated Color4 object
  5612. */
  5613. addInPlace(right: DeepImmutable<Color4>): Color4;
  5614. /**
  5615. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5616. * @returns the new array
  5617. */
  5618. asArray(): number[];
  5619. /**
  5620. * Stores from the starting index in the given array the Color4 successive values
  5621. * @param array defines the array where to store the r,g,b components
  5622. * @param index defines an optional index in the target array to define where to start storing values
  5623. * @returns the current Color4 object
  5624. */
  5625. toArray(array: number[], index?: number): Color4;
  5626. /**
  5627. * Determines equality between Color4 objects
  5628. * @param otherColor defines the second operand
  5629. * @returns true if the rgba values are equal to the given ones
  5630. */
  5631. equals(otherColor: DeepImmutable<Color4>): boolean;
  5632. /**
  5633. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5634. * @param right defines the second operand
  5635. * @returns a new Color4 object
  5636. */
  5637. add(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. subtract(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5646. * @param right defines the second operand
  5647. * @param result defines the Color4 object where to store the result
  5648. * @returns the current Color4 object
  5649. */
  5650. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5651. /**
  5652. * Creates a new Color4 with the current Color4 values multiplied by scale
  5653. * @param scale defines the scaling factor to apply
  5654. * @returns a new Color4 object
  5655. */
  5656. scale(scale: number): Color4;
  5657. /**
  5658. * Multiplies the current Color4 values by scale and stores the result in "result"
  5659. * @param scale defines the scaling factor to apply
  5660. * @param result defines the Color4 object where to store the result
  5661. * @returns the current unmodified Color4
  5662. */
  5663. scaleToRef(scale: number, result: Color4): Color4;
  5664. /**
  5665. * Scale the current Color4 values by a factor and add the result to a given Color4
  5666. * @param scale defines the scale factor
  5667. * @param result defines the Color4 object where to store the result
  5668. * @returns the unmodified current Color4
  5669. */
  5670. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5671. /**
  5672. * Clamps the rgb values by the min and max values and stores the result into "result"
  5673. * @param min defines minimum clamping value (default is 0)
  5674. * @param max defines maximum clamping value (default is 1)
  5675. * @param result defines color to store the result into.
  5676. * @returns the cuurent Color4
  5677. */
  5678. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5679. /**
  5680. * Multipy an Color4 value by another and return a new Color4 object
  5681. * @param color defines the Color4 value to multiply by
  5682. * @returns a new Color4 object
  5683. */
  5684. multiply(color: Color4): Color4;
  5685. /**
  5686. * Multipy a Color4 value by another and push the result in a reference value
  5687. * @param color defines the Color4 value to multiply by
  5688. * @param result defines the Color4 to fill the result in
  5689. * @returns the result Color4
  5690. */
  5691. multiplyToRef(color: Color4, result: Color4): Color4;
  5692. /**
  5693. * Creates a string with the Color4 current values
  5694. * @returns the string representation of the Color4 object
  5695. */
  5696. toString(): string;
  5697. /**
  5698. * Returns the string "Color4"
  5699. * @returns "Color4"
  5700. */
  5701. getClassName(): string;
  5702. /**
  5703. * Compute the Color4 hash code
  5704. * @returns an unique number that can be used to hash Color4 objects
  5705. */
  5706. getHashCode(): number;
  5707. /**
  5708. * Creates a new Color4 copied from the current one
  5709. * @returns a new Color4 object
  5710. */
  5711. clone(): Color4;
  5712. /**
  5713. * Copies the given Color4 values into the current one
  5714. * @param source defines the source Color4 object
  5715. * @returns the current updated Color4 object
  5716. */
  5717. copyFrom(source: Color4): Color4;
  5718. /**
  5719. * Copies the given float values into the current one
  5720. * @param r defines the red component to read from
  5721. * @param g defines the green component to read from
  5722. * @param b defines the blue component to read from
  5723. * @param a defines the alpha component to read from
  5724. * @returns the current updated Color4 object
  5725. */
  5726. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5727. /**
  5728. * Copies the given float values into the current one
  5729. * @param r defines the red component to read from
  5730. * @param g defines the green component to read from
  5731. * @param b defines the blue component to read from
  5732. * @param a defines the alpha component to read from
  5733. * @returns the current updated Color4 object
  5734. */
  5735. set(r: number, g: number, b: number, a: number): Color4;
  5736. /**
  5737. * Compute the Color4 hexadecimal code as a string
  5738. * @returns a string containing the hexadecimal representation of the Color4 object
  5739. */
  5740. toHexString(): string;
  5741. /**
  5742. * Computes a new Color4 converted from the current one to linear space
  5743. * @returns a new Color4 object
  5744. */
  5745. toLinearSpace(): Color4;
  5746. /**
  5747. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5748. * @param convertedColor defines the Color4 object where to store the linear space version
  5749. * @returns the unmodified Color4
  5750. */
  5751. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5752. /**
  5753. * Computes a new Color4 converted from the current one to gamma space
  5754. * @returns a new Color4 object
  5755. */
  5756. toGammaSpace(): Color4;
  5757. /**
  5758. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5759. * @param convertedColor defines the Color4 object where to store the gamma space version
  5760. * @returns the unmodified Color4
  5761. */
  5762. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5763. /**
  5764. * Creates a new Color4 from the string containing valid hexadecimal values
  5765. * @param hex defines a string containing valid hexadecimal values
  5766. * @returns a new Color4 object
  5767. */
  5768. static FromHexString(hex: string): Color4;
  5769. /**
  5770. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5771. * @param left defines the start value
  5772. * @param right defines the end value
  5773. * @param amount defines the gradient factor
  5774. * @returns a new Color4 object
  5775. */
  5776. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5777. /**
  5778. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5779. * @param left defines the start value
  5780. * @param right defines the end value
  5781. * @param amount defines the gradient factor
  5782. * @param result defines the Color4 object where to store data
  5783. */
  5784. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5785. /**
  5786. * Creates a new Color4 from a Color3 and an alpha value
  5787. * @param color3 defines the source Color3 to read from
  5788. * @param alpha defines the alpha component (1.0 by default)
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5792. /**
  5793. * Creates a new Color4 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @returns a new Color4 object
  5797. */
  5798. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @param a defines the alpha component to read from (value between 0 and 255)
  5805. * @returns a new Color3 object
  5806. */
  5807. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5808. /**
  5809. * Check the content of a given array and convert it to an array containing RGBA data
  5810. * If the original array was already containing count * 4 values then it is returned directly
  5811. * @param colors defines the array to check
  5812. * @param count defines the number of RGBA data to expect
  5813. * @returns an array containing count * 4 values (RGBA)
  5814. */
  5815. static CheckColors4(colors: number[], count: number): number[];
  5816. }
  5817. /**
  5818. * @hidden
  5819. */
  5820. export class TmpColors {
  5821. static Color3: Color3[];
  5822. static Color4: Color4[];
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. /**
  5827. * Defines an interface which represents an animation key frame
  5828. */
  5829. export interface IAnimationKey {
  5830. /**
  5831. * Frame of the key frame
  5832. */
  5833. frame: number;
  5834. /**
  5835. * Value at the specifies key frame
  5836. */
  5837. value: any;
  5838. /**
  5839. * The input tangent for the cubic hermite spline
  5840. */
  5841. inTangent?: any;
  5842. /**
  5843. * The output tangent for the cubic hermite spline
  5844. */
  5845. outTangent?: any;
  5846. /**
  5847. * The animation interpolation type
  5848. */
  5849. interpolation?: AnimationKeyInterpolation;
  5850. }
  5851. /**
  5852. * Enum for the animation key frame interpolation type
  5853. */
  5854. export enum AnimationKeyInterpolation {
  5855. /**
  5856. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5857. */
  5858. STEP = 1
  5859. }
  5860. }
  5861. declare module BABYLON {
  5862. /**
  5863. * Represents the range of an animation
  5864. */
  5865. export class AnimationRange {
  5866. /**The name of the animation range**/
  5867. name: string;
  5868. /**The starting frame of the animation */
  5869. from: number;
  5870. /**The ending frame of the animation*/
  5871. to: number;
  5872. /**
  5873. * Initializes the range of an animation
  5874. * @param name The name of the animation range
  5875. * @param from The starting frame of the animation
  5876. * @param to The ending frame of the animation
  5877. */
  5878. constructor(
  5879. /**The name of the animation range**/
  5880. name: string,
  5881. /**The starting frame of the animation */
  5882. from: number,
  5883. /**The ending frame of the animation*/
  5884. to: number);
  5885. /**
  5886. * Makes a copy of the animation range
  5887. * @returns A copy of the animation range
  5888. */
  5889. clone(): AnimationRange;
  5890. }
  5891. }
  5892. declare module BABYLON {
  5893. /**
  5894. * Composed of a frame, and an action function
  5895. */
  5896. export class AnimationEvent {
  5897. /** The frame for which the event is triggered **/
  5898. frame: number;
  5899. /** The event to perform when triggered **/
  5900. action: (currentFrame: number) => void;
  5901. /** Specifies if the event should be triggered only once**/
  5902. onlyOnce?: boolean | undefined;
  5903. /**
  5904. * Specifies if the animation event is done
  5905. */
  5906. isDone: boolean;
  5907. /**
  5908. * Initializes the animation event
  5909. * @param frame The frame for which the event is triggered
  5910. * @param action The event to perform when triggered
  5911. * @param onlyOnce Specifies if the event should be triggered only once
  5912. */
  5913. constructor(
  5914. /** The frame for which the event is triggered **/
  5915. frame: number,
  5916. /** The event to perform when triggered **/
  5917. action: (currentFrame: number) => void,
  5918. /** Specifies if the event should be triggered only once**/
  5919. onlyOnce?: boolean | undefined);
  5920. /** @hidden */
  5921. _clone(): AnimationEvent;
  5922. }
  5923. }
  5924. declare module BABYLON {
  5925. /**
  5926. * Interface used to define a behavior
  5927. */
  5928. export interface Behavior<T> {
  5929. /** gets or sets behavior's name */
  5930. name: string;
  5931. /**
  5932. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5933. */
  5934. init(): void;
  5935. /**
  5936. * Called when the behavior is attached to a target
  5937. * @param target defines the target where the behavior is attached to
  5938. */
  5939. attach(target: T): void;
  5940. /**
  5941. * Called when the behavior is detached from its target
  5942. */
  5943. detach(): void;
  5944. }
  5945. /**
  5946. * Interface implemented by classes supporting behaviors
  5947. */
  5948. export interface IBehaviorAware<T> {
  5949. /**
  5950. * Attach a behavior
  5951. * @param behavior defines the behavior to attach
  5952. * @returns the current host
  5953. */
  5954. addBehavior(behavior: Behavior<T>): T;
  5955. /**
  5956. * Remove a behavior from the current object
  5957. * @param behavior defines the behavior to detach
  5958. * @returns the current host
  5959. */
  5960. removeBehavior(behavior: Behavior<T>): T;
  5961. /**
  5962. * Gets a behavior using its name to search
  5963. * @param name defines the name to search
  5964. * @returns the behavior or null if not found
  5965. */
  5966. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * Defines an array and its length.
  5972. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5973. */
  5974. export interface ISmartArrayLike<T> {
  5975. /**
  5976. * The data of the array.
  5977. */
  5978. data: Array<T>;
  5979. /**
  5980. * The active length of the array.
  5981. */
  5982. length: number;
  5983. }
  5984. /**
  5985. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5986. */
  5987. export class SmartArray<T> implements ISmartArrayLike<T> {
  5988. /**
  5989. * The full set of data from the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. protected _id: number;
  5997. /**
  5998. * Instantiates a Smart Array.
  5999. * @param capacity defines the default capacity of the array.
  6000. */
  6001. constructor(capacity: number);
  6002. /**
  6003. * Pushes a value at the end of the active data.
  6004. * @param value defines the object to push in the array.
  6005. */
  6006. push(value: T): void;
  6007. /**
  6008. * Iterates over the active data and apply the lambda to them.
  6009. * @param func defines the action to apply on each value.
  6010. */
  6011. forEach(func: (content: T) => void): void;
  6012. /**
  6013. * Sorts the full sets of data.
  6014. * @param compareFn defines the comparison function to apply.
  6015. */
  6016. sort(compareFn: (a: T, b: T) => number): void;
  6017. /**
  6018. * Resets the active data to an empty array.
  6019. */
  6020. reset(): void;
  6021. /**
  6022. * Releases all the data from the array as well as the array.
  6023. */
  6024. dispose(): void;
  6025. /**
  6026. * Concats the active data with a given array.
  6027. * @param array defines the data to concatenate with.
  6028. */
  6029. concat(array: any): void;
  6030. /**
  6031. * Returns the position of a value in the active data.
  6032. * @param value defines the value to find the index for
  6033. * @returns the index if found in the active data otherwise -1
  6034. */
  6035. indexOf(value: T): number;
  6036. /**
  6037. * Returns whether an element is part of the active data.
  6038. * @param value defines the value to look for
  6039. * @returns true if found in the active data otherwise false
  6040. */
  6041. contains(value: T): boolean;
  6042. private static _GlobalId;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. * The data in this array can only be present once
  6047. */
  6048. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6049. private _duplicateId;
  6050. /**
  6051. * Pushes a value at the end of the active data.
  6052. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6053. * @param value defines the object to push in the array.
  6054. */
  6055. push(value: T): void;
  6056. /**
  6057. * Pushes a value at the end of the active data.
  6058. * If the data is already present, it won t be added again
  6059. * @param value defines the object to push in the array.
  6060. * @returns true if added false if it was already present
  6061. */
  6062. pushNoDuplicate(value: T): boolean;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * This ensures no dupplicate will be present in the result.
  6070. * @param array defines the data to concatenate with.
  6071. */
  6072. concatWithNoDuplicate(array: any): void;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * @ignore
  6078. * This is a list of all the different input types that are available in the application.
  6079. * Fo instance: ArcRotateCameraGamepadInput...
  6080. */
  6081. export var CameraInputTypes: {};
  6082. /**
  6083. * This is the contract to implement in order to create a new input class.
  6084. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6085. */
  6086. export interface ICameraInput<TCamera extends Camera> {
  6087. /**
  6088. * Defines the camera the input is attached to.
  6089. */
  6090. camera: Nullable<TCamera>;
  6091. /**
  6092. * Gets the class name of the current intput.
  6093. * @returns the class name
  6094. */
  6095. getClassName(): string;
  6096. /**
  6097. * Get the friendly name associated with the input class.
  6098. * @returns the input friendly name
  6099. */
  6100. getSimpleName(): string;
  6101. /**
  6102. * Attach the input controls to a specific dom element to get the input from.
  6103. * @param element Defines the element the controls should be listened from
  6104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6105. */
  6106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6107. /**
  6108. * Detach the current controls from the specified dom element.
  6109. * @param element Defines the element to stop listening the inputs from
  6110. */
  6111. detachControl(element: Nullable<HTMLElement>): void;
  6112. /**
  6113. * Update the current camera state depending on the inputs that have been used this frame.
  6114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6115. */
  6116. checkInputs?: () => void;
  6117. }
  6118. /**
  6119. * Represents a map of input types to input instance or input index to input instance.
  6120. */
  6121. export interface CameraInputsMap<TCamera extends Camera> {
  6122. /**
  6123. * Accessor to the input by input type.
  6124. */
  6125. [name: string]: ICameraInput<TCamera>;
  6126. /**
  6127. * Accessor to the input by input index.
  6128. */
  6129. [idx: number]: ICameraInput<TCamera>;
  6130. }
  6131. /**
  6132. * This represents the input manager used within a camera.
  6133. * It helps dealing with all the different kind of input attached to a camera.
  6134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6135. */
  6136. export class CameraInputsManager<TCamera extends Camera> {
  6137. /**
  6138. * Defines the list of inputs attahed to the camera.
  6139. */
  6140. attached: CameraInputsMap<TCamera>;
  6141. /**
  6142. * Defines the dom element the camera is collecting inputs from.
  6143. * This is null if the controls have not been attached.
  6144. */
  6145. attachedElement: Nullable<HTMLElement>;
  6146. /**
  6147. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6148. */
  6149. noPreventDefault: boolean;
  6150. /**
  6151. * Defined the camera the input manager belongs to.
  6152. */
  6153. camera: TCamera;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs: () => void;
  6159. /**
  6160. * Instantiate a new Camera Input Manager.
  6161. * @param camera Defines the camera the input manager blongs to
  6162. */
  6163. constructor(camera: TCamera);
  6164. /**
  6165. * Add an input method to a camera
  6166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6167. * @param input camera input method
  6168. */
  6169. add(input: ICameraInput<TCamera>): void;
  6170. /**
  6171. * Remove a specific input method from a camera
  6172. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6173. * @param inputToRemove camera input method
  6174. */
  6175. remove(inputToRemove: ICameraInput<TCamera>): void;
  6176. /**
  6177. * Remove a specific input type from a camera
  6178. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6179. * @param inputType the type of the input to remove
  6180. */
  6181. removeByType(inputType: string): void;
  6182. private _addCheckInputs;
  6183. /**
  6184. * Attach the input controls to the currently attached dom element to listen the events from.
  6185. * @param input Defines the input to attach
  6186. */
  6187. attachInput(input: ICameraInput<TCamera>): void;
  6188. /**
  6189. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6190. * @param element Defines the dom element to collect the events from
  6191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6192. */
  6193. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6194. /**
  6195. * Detach the current manager inputs controls from a specific dom element.
  6196. * @param element Defines the dom element to collect the events from
  6197. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6198. */
  6199. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6200. /**
  6201. * Rebuild the dynamic inputCheck function from the current list of
  6202. * defined inputs in the manager.
  6203. */
  6204. rebuildInputCheck(): void;
  6205. /**
  6206. * Remove all attached input methods from a camera
  6207. */
  6208. clear(): void;
  6209. /**
  6210. * Serialize the current input manager attached to a camera.
  6211. * This ensures than once parsed,
  6212. * the input associated to the camera will be identical to the current ones
  6213. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6214. */
  6215. serialize(serializedCamera: any): void;
  6216. /**
  6217. * Parses an input manager serialized JSON to restore the previous list of inputs
  6218. * and states associated to a camera.
  6219. * @param parsedCamera Defines the JSON to parse
  6220. */
  6221. parse(parsedCamera: any): void;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * Class used to store data that will be store in GPU memory
  6227. */
  6228. export class Buffer {
  6229. private _engine;
  6230. private _buffer;
  6231. /** @hidden */
  6232. _data: Nullable<DataArray>;
  6233. private _updatable;
  6234. private _instanced;
  6235. private _divisor;
  6236. /**
  6237. * Gets the byte stride.
  6238. */
  6239. readonly byteStride: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this buffer
  6244. * @param updatable whether the data is updatable
  6245. * @param stride the stride (optional)
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param instanced whether the buffer is instanced (optional)
  6248. * @param useBytes set to true if the stride in in bytes (optional)
  6249. * @param divisor sets an optional divisor for instances (1 by default)
  6250. */
  6251. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6252. /**
  6253. * Create a new VertexBuffer based on the current buffer
  6254. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6255. * @param offset defines offset in the buffer (0 by default)
  6256. * @param size defines the size in floats of attributes (position is 3 for instance)
  6257. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6258. * @param instanced defines if the vertex buffer contains indexed data
  6259. * @param useBytes defines if the offset and stride are in bytes *
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. * @returns the new vertex buffer
  6262. */
  6263. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6264. /**
  6265. * Gets a boolean indicating if the Buffer is updatable?
  6266. * @returns true if the buffer is updatable
  6267. */
  6268. isUpdatable(): boolean;
  6269. /**
  6270. * Gets current buffer's data
  6271. * @returns a DataArray or null
  6272. */
  6273. getData(): Nullable<DataArray>;
  6274. /**
  6275. * Gets underlying native buffer
  6276. * @returns underlying native buffer
  6277. */
  6278. getBuffer(): Nullable<DataBuffer>;
  6279. /**
  6280. * Gets the stride in float32 units (i.e. byte stride / 4).
  6281. * May not be an integer if the byte stride is not divisible by 4.
  6282. * @returns the stride in float32 units
  6283. * @deprecated Please use byteStride instead.
  6284. */
  6285. getStrideSize(): number;
  6286. /**
  6287. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6288. * @param data defines the data to store
  6289. */
  6290. create(data?: Nullable<DataArray>): void;
  6291. /** @hidden */
  6292. _rebuild(): void;
  6293. /**
  6294. * Update current buffer data
  6295. * @param data defines the data to store
  6296. */
  6297. update(data: DataArray): void;
  6298. /**
  6299. * Updates the data directly.
  6300. * @param data the new data
  6301. * @param offset the new offset
  6302. * @param vertexCount the vertex count (optional)
  6303. * @param useBytes set to true if the offset is in bytes
  6304. */
  6305. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6306. /**
  6307. * Release all resources
  6308. */
  6309. dispose(): void;
  6310. }
  6311. /**
  6312. * Specialized buffer used to store vertex data
  6313. */
  6314. export class VertexBuffer {
  6315. /** @hidden */
  6316. _buffer: Buffer;
  6317. private _kind;
  6318. private _size;
  6319. private _ownsBuffer;
  6320. private _instanced;
  6321. private _instanceDivisor;
  6322. /**
  6323. * The byte type.
  6324. */
  6325. static readonly BYTE: number;
  6326. /**
  6327. * The unsigned byte type.
  6328. */
  6329. static readonly UNSIGNED_BYTE: number;
  6330. /**
  6331. * The short type.
  6332. */
  6333. static readonly SHORT: number;
  6334. /**
  6335. * The unsigned short type.
  6336. */
  6337. static readonly UNSIGNED_SHORT: number;
  6338. /**
  6339. * The integer type.
  6340. */
  6341. static readonly INT: number;
  6342. /**
  6343. * The unsigned integer type.
  6344. */
  6345. static readonly UNSIGNED_INT: number;
  6346. /**
  6347. * The float type.
  6348. */
  6349. static readonly FLOAT: number;
  6350. /**
  6351. * Gets or sets the instance divisor when in instanced mode
  6352. */
  6353. get instanceDivisor(): number;
  6354. set instanceDivisor(value: number);
  6355. /**
  6356. * Gets the byte stride.
  6357. */
  6358. readonly byteStride: number;
  6359. /**
  6360. * Gets the byte offset.
  6361. */
  6362. readonly byteOffset: number;
  6363. /**
  6364. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6365. */
  6366. readonly normalized: boolean;
  6367. /**
  6368. * Gets the data type of each component in the array.
  6369. */
  6370. readonly type: number;
  6371. /**
  6372. * Constructor
  6373. * @param engine the engine
  6374. * @param data the data to use for this vertex buffer
  6375. * @param kind the vertex buffer kind
  6376. * @param updatable whether the data is updatable
  6377. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6378. * @param stride the stride (optional)
  6379. * @param instanced whether the buffer is instanced (optional)
  6380. * @param offset the offset of the data (optional)
  6381. * @param size the number of components (optional)
  6382. * @param type the type of the component (optional)
  6383. * @param normalized whether the data contains normalized data (optional)
  6384. * @param useBytes set to true if stride and offset are in bytes (optional)
  6385. * @param divisor defines the instance divisor to use (1 by default)
  6386. */
  6387. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6388. /** @hidden */
  6389. _rebuild(): void;
  6390. /**
  6391. * Returns the kind of the VertexBuffer (string)
  6392. * @returns a string
  6393. */
  6394. getKind(): string;
  6395. /**
  6396. * Gets a boolean indicating if the VertexBuffer is updatable?
  6397. * @returns true if the buffer is updatable
  6398. */
  6399. isUpdatable(): boolean;
  6400. /**
  6401. * Gets current buffer's data
  6402. * @returns a DataArray or null
  6403. */
  6404. getData(): Nullable<DataArray>;
  6405. /**
  6406. * Gets underlying native buffer
  6407. * @returns underlying native buffer
  6408. */
  6409. getBuffer(): Nullable<DataBuffer>;
  6410. /**
  6411. * Gets the stride in float32 units (i.e. byte stride / 4).
  6412. * May not be an integer if the byte stride is not divisible by 4.
  6413. * @returns the stride in float32 units
  6414. * @deprecated Please use byteStride instead.
  6415. */
  6416. getStrideSize(): number;
  6417. /**
  6418. * Returns the offset as a multiple of the type byte length.
  6419. * @returns the offset in bytes
  6420. * @deprecated Please use byteOffset instead.
  6421. */
  6422. getOffset(): number;
  6423. /**
  6424. * Returns the number of components per vertex attribute (integer)
  6425. * @returns the size in float
  6426. */
  6427. getSize(): number;
  6428. /**
  6429. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6430. * @returns true if this buffer is instanced
  6431. */
  6432. getIsInstanced(): boolean;
  6433. /**
  6434. * Returns the instancing divisor, zero for non-instanced (integer).
  6435. * @returns a number
  6436. */
  6437. getInstanceDivisor(): number;
  6438. /**
  6439. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6440. * @param data defines the data to store
  6441. */
  6442. create(data?: DataArray): void;
  6443. /**
  6444. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6445. * This function will create a new buffer if the current one is not updatable
  6446. * @param data defines the data to store
  6447. */
  6448. update(data: DataArray): void;
  6449. /**
  6450. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6451. * Returns the directly updated WebGLBuffer.
  6452. * @param data the new data
  6453. * @param offset the new offset
  6454. * @param useBytes set to true if the offset is in bytes
  6455. */
  6456. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6457. /**
  6458. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6459. */
  6460. dispose(): void;
  6461. /**
  6462. * Enumerates each value of this vertex buffer as numbers.
  6463. * @param count the number of values to enumerate
  6464. * @param callback the callback function called for each value
  6465. */
  6466. forEach(count: number, callback: (value: number, index: number) => void): void;
  6467. /**
  6468. * Positions
  6469. */
  6470. static readonly PositionKind: string;
  6471. /**
  6472. * Normals
  6473. */
  6474. static readonly NormalKind: string;
  6475. /**
  6476. * Tangents
  6477. */
  6478. static readonly TangentKind: string;
  6479. /**
  6480. * Texture coordinates
  6481. */
  6482. static readonly UVKind: string;
  6483. /**
  6484. * Texture coordinates 2
  6485. */
  6486. static readonly UV2Kind: string;
  6487. /**
  6488. * Texture coordinates 3
  6489. */
  6490. static readonly UV3Kind: string;
  6491. /**
  6492. * Texture coordinates 4
  6493. */
  6494. static readonly UV4Kind: string;
  6495. /**
  6496. * Texture coordinates 5
  6497. */
  6498. static readonly UV5Kind: string;
  6499. /**
  6500. * Texture coordinates 6
  6501. */
  6502. static readonly UV6Kind: string;
  6503. /**
  6504. * Colors
  6505. */
  6506. static readonly ColorKind: string;
  6507. /**
  6508. * Matrix indices (for bones)
  6509. */
  6510. static readonly MatricesIndicesKind: string;
  6511. /**
  6512. * Matrix weights (for bones)
  6513. */
  6514. static readonly MatricesWeightsKind: string;
  6515. /**
  6516. * Additional matrix indices (for bones)
  6517. */
  6518. static readonly MatricesIndicesExtraKind: string;
  6519. /**
  6520. * Additional matrix weights (for bones)
  6521. */
  6522. static readonly MatricesWeightsExtraKind: string;
  6523. /**
  6524. * Deduces the stride given a kind.
  6525. * @param kind The kind string to deduce
  6526. * @returns The deduced stride
  6527. */
  6528. static DeduceStride(kind: string): number;
  6529. /**
  6530. * Gets the byte length of the given type.
  6531. * @param type the type
  6532. * @returns the number of bytes
  6533. */
  6534. static GetTypeByteLength(type: number): number;
  6535. /**
  6536. * Enumerates each value of the given parameters as numbers.
  6537. * @param data the data to enumerate
  6538. * @param byteOffset the byte offset of the data
  6539. * @param byteStride the byte stride of the data
  6540. * @param componentCount the number of components per element
  6541. * @param componentType the type of the component
  6542. * @param count the number of values to enumerate
  6543. * @param normalized whether the data is normalized
  6544. * @param callback the callback function called for each value
  6545. */
  6546. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6547. private static _GetFloatValue;
  6548. }
  6549. }
  6550. declare module BABYLON {
  6551. /**
  6552. * @hidden
  6553. */
  6554. export class IntersectionInfo {
  6555. bu: Nullable<number>;
  6556. bv: Nullable<number>;
  6557. distance: number;
  6558. faceId: number;
  6559. subMeshId: number;
  6560. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6561. }
  6562. }
  6563. declare module BABYLON {
  6564. /**
  6565. * Represens a plane by the equation ax + by + cz + d = 0
  6566. */
  6567. export class Plane {
  6568. private static _TmpMatrix;
  6569. /**
  6570. * Normal of the plane (a,b,c)
  6571. */
  6572. normal: Vector3;
  6573. /**
  6574. * d component of the plane
  6575. */
  6576. d: number;
  6577. /**
  6578. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6579. * @param a a component of the plane
  6580. * @param b b component of the plane
  6581. * @param c c component of the plane
  6582. * @param d d component of the plane
  6583. */
  6584. constructor(a: number, b: number, c: number, d: number);
  6585. /**
  6586. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6587. */
  6588. asArray(): number[];
  6589. /**
  6590. * @returns a new plane copied from the current Plane.
  6591. */
  6592. clone(): Plane;
  6593. /**
  6594. * @returns the string "Plane".
  6595. */
  6596. getClassName(): string;
  6597. /**
  6598. * @returns the Plane hash code.
  6599. */
  6600. getHashCode(): number;
  6601. /**
  6602. * Normalize the current Plane in place.
  6603. * @returns the updated Plane.
  6604. */
  6605. normalize(): Plane;
  6606. /**
  6607. * Applies a transformation the plane and returns the result
  6608. * @param transformation the transformation matrix to be applied to the plane
  6609. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6610. */
  6611. transform(transformation: DeepImmutable<Matrix>): Plane;
  6612. /**
  6613. * Calcualtte the dot product between the point and the plane normal
  6614. * @param point point to calculate the dot product with
  6615. * @returns the dot product (float) of the point coordinates and the plane normal.
  6616. */
  6617. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6618. /**
  6619. * Updates the current Plane from the plane defined by the three given points.
  6620. * @param point1 one of the points used to contruct the plane
  6621. * @param point2 one of the points used to contruct the plane
  6622. * @param point3 one of the points used to contruct the plane
  6623. * @returns the updated Plane.
  6624. */
  6625. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6626. /**
  6627. * Checks if the plane is facing a given direction
  6628. * @param direction the direction to check if the plane is facing
  6629. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6630. * @returns True is the vector "direction" is the same side than the plane normal.
  6631. */
  6632. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6633. /**
  6634. * Calculates the distance to a point
  6635. * @param point point to calculate distance to
  6636. * @returns the signed distance (float) from the given point to the Plane.
  6637. */
  6638. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6639. /**
  6640. * Creates a plane from an array
  6641. * @param array the array to create a plane from
  6642. * @returns a new Plane from the given array.
  6643. */
  6644. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6645. /**
  6646. * Creates a plane from three points
  6647. * @param point1 point used to create the plane
  6648. * @param point2 point used to create the plane
  6649. * @param point3 point used to create the plane
  6650. * @returns a new Plane defined by the three given points.
  6651. */
  6652. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Creates a plane from an origin point and a normal
  6655. * @param origin origin of the plane to be constructed
  6656. * @param normal normal of the plane to be constructed
  6657. * @returns a new Plane the normal vector to this plane at the given origin point.
  6658. * Note : the vector "normal" is updated because normalized.
  6659. */
  6660. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6661. /**
  6662. * Calculates the distance from a plane and a point
  6663. * @param origin origin of the plane to be constructed
  6664. * @param normal normal of the plane to be constructed
  6665. * @param point point to calculate distance to
  6666. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6667. */
  6668. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6669. }
  6670. }
  6671. declare module BABYLON {
  6672. /**
  6673. * Class used to store bounding sphere information
  6674. */
  6675. export class BoundingSphere {
  6676. /**
  6677. * Gets the center of the bounding sphere in local space
  6678. */
  6679. readonly center: Vector3;
  6680. /**
  6681. * Radius of the bounding sphere in local space
  6682. */
  6683. radius: number;
  6684. /**
  6685. * Gets the center of the bounding sphere in world space
  6686. */
  6687. readonly centerWorld: Vector3;
  6688. /**
  6689. * Radius of the bounding sphere in world space
  6690. */
  6691. radiusWorld: number;
  6692. /**
  6693. * Gets the minimum vector in local space
  6694. */
  6695. readonly minimum: Vector3;
  6696. /**
  6697. * Gets the maximum vector in local space
  6698. */
  6699. readonly maximum: Vector3;
  6700. private _worldMatrix;
  6701. private static readonly TmpVector3;
  6702. /**
  6703. * Creates a new bounding sphere
  6704. * @param min defines the minimum vector (in local space)
  6705. * @param max defines the maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6709. /**
  6710. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6711. * @param min defines the new minimum vector (in local space)
  6712. * @param max defines the new maximum vector (in local space)
  6713. * @param worldMatrix defines the new world matrix
  6714. */
  6715. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6716. /**
  6717. * Scale the current bounding sphere by applying a scale factor
  6718. * @param factor defines the scale factor to apply
  6719. * @returns the current bounding box
  6720. */
  6721. scale(factor: number): BoundingSphere;
  6722. /**
  6723. * Gets the world matrix of the bounding box
  6724. * @returns a matrix
  6725. */
  6726. getWorldMatrix(): DeepImmutable<Matrix>;
  6727. /** @hidden */
  6728. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6729. /**
  6730. * Tests if the bounding sphere is intersecting the frustum planes
  6731. * @param frustumPlanes defines the frustum planes to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6735. /**
  6736. * Tests if the bounding sphere center is in between the frustum planes.
  6737. * Used for optimistic fast inclusion.
  6738. * @param frustumPlanes defines the frustum planes to test
  6739. * @returns true if the sphere center is in between the frustum planes
  6740. */
  6741. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6742. /**
  6743. * Tests if a point is inside the bounding sphere
  6744. * @param point defines the point to test
  6745. * @returns true if the point is inside the bounding sphere
  6746. */
  6747. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6748. /**
  6749. * Checks if two sphere intersct
  6750. * @param sphere0 sphere 0
  6751. * @param sphere1 sphere 1
  6752. * @returns true if the speres intersect
  6753. */
  6754. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6755. }
  6756. }
  6757. declare module BABYLON {
  6758. /**
  6759. * Class used to store bounding box information
  6760. */
  6761. export class BoundingBox implements ICullable {
  6762. /**
  6763. * Gets the 8 vectors representing the bounding box in local space
  6764. */
  6765. readonly vectors: Vector3[];
  6766. /**
  6767. * Gets the center of the bounding box in local space
  6768. */
  6769. readonly center: Vector3;
  6770. /**
  6771. * Gets the center of the bounding box in world space
  6772. */
  6773. readonly centerWorld: Vector3;
  6774. /**
  6775. * Gets the extend size in local space
  6776. */
  6777. readonly extendSize: Vector3;
  6778. /**
  6779. * Gets the extend size in world space
  6780. */
  6781. readonly extendSizeWorld: Vector3;
  6782. /**
  6783. * Gets the OBB (object bounding box) directions
  6784. */
  6785. readonly directions: Vector3[];
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in world space
  6788. */
  6789. readonly vectorsWorld: Vector3[];
  6790. /**
  6791. * Gets the minimum vector in world space
  6792. */
  6793. readonly minimumWorld: Vector3;
  6794. /**
  6795. * Gets the maximum vector in world space
  6796. */
  6797. readonly maximumWorld: Vector3;
  6798. /**
  6799. * Gets the minimum vector in local space
  6800. */
  6801. readonly minimum: Vector3;
  6802. /**
  6803. * Gets the maximum vector in local space
  6804. */
  6805. readonly maximum: Vector3;
  6806. private _worldMatrix;
  6807. private static readonly TmpVector3;
  6808. /**
  6809. * @hidden
  6810. */
  6811. _tag: number;
  6812. /**
  6813. * Creates a new bounding box
  6814. * @param min defines the minimum vector (in local space)
  6815. * @param max defines the maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6819. /**
  6820. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. * @param worldMatrix defines the new world matrix
  6824. */
  6825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6826. /**
  6827. * Scale the current bounding box by applying a scale factor
  6828. * @param factor defines the scale factor to apply
  6829. * @returns the current bounding box
  6830. */
  6831. scale(factor: number): BoundingBox;
  6832. /**
  6833. * Gets the world matrix of the bounding box
  6834. * @returns a matrix
  6835. */
  6836. getWorldMatrix(): DeepImmutable<Matrix>;
  6837. /** @hidden */
  6838. _update(world: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Tests if the bounding box is intersecting the frustum planes
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @returns true if there is an intersection
  6843. */
  6844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if the bounding box is entirely inside the frustum planes
  6847. * @param frustumPlanes defines the frustum planes to test
  6848. * @returns true if there is an inclusion
  6849. */
  6850. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6851. /**
  6852. * Tests if a point is inside the bounding box
  6853. * @param point defines the point to test
  6854. * @returns true if the point is inside the bounding box
  6855. */
  6856. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6857. /**
  6858. * Tests if the bounding box intersects with a bounding sphere
  6859. * @param sphere defines the sphere to test
  6860. * @returns true if there is an intersection
  6861. */
  6862. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6863. /**
  6864. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6865. * @param min defines the min vector to use
  6866. * @param max defines the max vector to use
  6867. * @returns true if there is an intersection
  6868. */
  6869. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6870. /**
  6871. * Tests if two bounding boxes are intersections
  6872. * @param box0 defines the first box to test
  6873. * @param box1 defines the second box to test
  6874. * @returns true if there is an intersection
  6875. */
  6876. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6877. /**
  6878. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6879. * @param minPoint defines the minimum vector of the bounding box
  6880. * @param maxPoint defines the maximum vector of the bounding box
  6881. * @param sphereCenter defines the sphere center
  6882. * @param sphereRadius defines the sphere radius
  6883. * @returns true if there is an intersection
  6884. */
  6885. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6886. /**
  6887. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6888. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @return true if there is an inclusion
  6891. */
  6892. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6895. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @return true if there is an intersection
  6898. */
  6899. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /** @hidden */
  6904. export class Collider {
  6905. /** Define if a collision was found */
  6906. collisionFound: boolean;
  6907. /**
  6908. * Define last intersection point in local space
  6909. */
  6910. intersectionPoint: Vector3;
  6911. /**
  6912. * Define last collided mesh
  6913. */
  6914. collidedMesh: Nullable<AbstractMesh>;
  6915. private _collisionPoint;
  6916. private _planeIntersectionPoint;
  6917. private _tempVector;
  6918. private _tempVector2;
  6919. private _tempVector3;
  6920. private _tempVector4;
  6921. private _edge;
  6922. private _baseToVertex;
  6923. private _destinationPoint;
  6924. private _slidePlaneNormal;
  6925. private _displacementVector;
  6926. /** @hidden */
  6927. _radius: Vector3;
  6928. /** @hidden */
  6929. _retry: number;
  6930. private _velocity;
  6931. private _basePoint;
  6932. private _epsilon;
  6933. /** @hidden */
  6934. _velocityWorldLength: number;
  6935. /** @hidden */
  6936. _basePointWorld: Vector3;
  6937. private _velocityWorld;
  6938. private _normalizedVelocity;
  6939. /** @hidden */
  6940. _initialVelocity: Vector3;
  6941. /** @hidden */
  6942. _initialPosition: Vector3;
  6943. private _nearestDistance;
  6944. private _collisionMask;
  6945. get collisionMask(): number;
  6946. set collisionMask(mask: number);
  6947. /**
  6948. * Gets the plane normal used to compute the sliding response (in local space)
  6949. */
  6950. get slidePlaneNormal(): Vector3;
  6951. /** @hidden */
  6952. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6953. /** @hidden */
  6954. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6955. /** @hidden */
  6956. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6957. /** @hidden */
  6958. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6959. /** @hidden */
  6960. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6961. /** @hidden */
  6962. _getResponse(pos: Vector3, vel: Vector3): void;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Interface for cullable objects
  6968. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6969. */
  6970. export interface ICullable {
  6971. /**
  6972. * Checks if the object or part of the object is in the frustum
  6973. * @param frustumPlanes Camera near/planes
  6974. * @returns true if the object is in frustum otherwise false
  6975. */
  6976. isInFrustum(frustumPlanes: Plane[]): boolean;
  6977. /**
  6978. * Checks if a cullable object (mesh...) is in the camera frustum
  6979. * Unlike isInFrustum this cheks the full bounding box
  6980. * @param frustumPlanes Camera near/planes
  6981. * @returns true if the object is in frustum otherwise false
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6984. }
  6985. /**
  6986. * Info for a bounding data of a mesh
  6987. */
  6988. export class BoundingInfo implements ICullable {
  6989. /**
  6990. * Bounding box for the mesh
  6991. */
  6992. readonly boundingBox: BoundingBox;
  6993. /**
  6994. * Bounding sphere for the mesh
  6995. */
  6996. readonly boundingSphere: BoundingSphere;
  6997. private _isLocked;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * Constructs bounding info
  7001. * @param minimum min vector of the bounding box/sphere
  7002. * @param maximum max vector of the bounding box/sphere
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7006. /**
  7007. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7008. * @param min defines the new minimum vector (in local space)
  7009. * @param max defines the new maximum vector (in local space)
  7010. * @param worldMatrix defines the new world matrix
  7011. */
  7012. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7013. /**
  7014. * min vector of the bounding box/sphere
  7015. */
  7016. get minimum(): Vector3;
  7017. /**
  7018. * max vector of the bounding box/sphere
  7019. */
  7020. get maximum(): Vector3;
  7021. /**
  7022. * If the info is locked and won't be updated to avoid perf overhead
  7023. */
  7024. get isLocked(): boolean;
  7025. set isLocked(value: boolean);
  7026. /**
  7027. * Updates the bounding sphere and box
  7028. * @param world world matrix to be used to update
  7029. */
  7030. update(world: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7033. * @param center New center of the bounding info
  7034. * @param extend New extend of the bounding info
  7035. * @returns the current bounding info
  7036. */
  7037. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7038. /**
  7039. * Scale the current bounding info by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding info
  7042. */
  7043. scale(factor: number): BoundingInfo;
  7044. /**
  7045. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7046. * @param frustumPlanes defines the frustum to test
  7047. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7048. * @returns true if the bounding info is in the frustum planes
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7051. /**
  7052. * Gets the world distance between the min and max points of the bounding box
  7053. */
  7054. get diagonalLength(): number;
  7055. /**
  7056. * Checks if a cullable object (mesh...) is in the camera frustum
  7057. * Unlike isInFrustum this cheks the full bounding box
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /** @hidden */
  7063. _checkCollision(collider: Collider): boolean;
  7064. /**
  7065. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7066. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7067. * @param point the point to check intersection with
  7068. * @returns if the point intersects
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7073. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7074. * @param boundingInfo the bounding info to check intersection with
  7075. * @param precise if the intersection should be done using OBB
  7076. * @returns if the bounding info intersects
  7077. */
  7078. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7079. }
  7080. }
  7081. declare module BABYLON {
  7082. /**
  7083. * Extracts minimum and maximum values from a list of indexed positions
  7084. * @param positions defines the positions to use
  7085. * @param indices defines the indices to the positions
  7086. * @param indexStart defines the start index
  7087. * @param indexCount defines the end index
  7088. * @param bias defines bias value to add to the result
  7089. * @return minimum and maximum values
  7090. */
  7091. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7092. minimum: Vector3;
  7093. maximum: Vector3;
  7094. };
  7095. /**
  7096. * Extracts minimum and maximum values from a list of positions
  7097. * @param positions defines the positions to use
  7098. * @param start defines the start index in the positions array
  7099. * @param count defines the number of positions to handle
  7100. * @param bias defines bias value to add to the result
  7101. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7102. * @return minimum and maximum values
  7103. */
  7104. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7105. minimum: Vector3;
  7106. maximum: Vector3;
  7107. };
  7108. }
  7109. declare module BABYLON {
  7110. /** @hidden */
  7111. export class WebGLDataBuffer extends DataBuffer {
  7112. private _buffer;
  7113. constructor(resource: WebGLBuffer);
  7114. get underlyingResource(): any;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class WebGLPipelineContext implements IPipelineContext {
  7120. engine: ThinEngine;
  7121. program: Nullable<WebGLProgram>;
  7122. context?: WebGLRenderingContext;
  7123. vertexShader?: WebGLShader;
  7124. fragmentShader?: WebGLShader;
  7125. isParallelCompiled: boolean;
  7126. onCompiled?: () => void;
  7127. transformFeedback?: WebGLTransformFeedback | null;
  7128. vertexCompilationError: Nullable<string>;
  7129. fragmentCompilationError: Nullable<string>;
  7130. programLinkError: Nullable<string>;
  7131. programValidationError: Nullable<string>;
  7132. get isAsync(): boolean;
  7133. get isReady(): boolean;
  7134. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7135. }
  7136. }
  7137. declare module BABYLON {
  7138. interface ThinEngine {
  7139. /**
  7140. * Create an uniform buffer
  7141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7142. * @param elements defines the content of the uniform buffer
  7143. * @returns the webGL uniform buffer
  7144. */
  7145. createUniformBuffer(elements: FloatArray): DataBuffer;
  7146. /**
  7147. * Create a dynamic uniform buffer
  7148. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7149. * @param elements defines the content of the uniform buffer
  7150. * @returns the webGL uniform buffer
  7151. */
  7152. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7153. /**
  7154. * Update an existing uniform buffer
  7155. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7156. * @param uniformBuffer defines the target uniform buffer
  7157. * @param elements defines the content to update
  7158. * @param offset defines the offset in the uniform buffer where update should start
  7159. * @param count defines the size of the data to update
  7160. */
  7161. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7162. /**
  7163. * Bind an uniform buffer to the current webGL context
  7164. * @param buffer defines the buffer to bind
  7165. */
  7166. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7167. /**
  7168. * Bind a buffer to the current webGL context at a given location
  7169. * @param buffer defines the buffer to bind
  7170. * @param location defines the index where to bind the buffer
  7171. */
  7172. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7173. /**
  7174. * Bind a specific block at a given index in a specific shader program
  7175. * @param pipelineContext defines the pipeline context to use
  7176. * @param blockName defines the block name
  7177. * @param index defines the index where to bind the block
  7178. */
  7179. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7180. }
  7181. }
  7182. declare module BABYLON {
  7183. /**
  7184. * Uniform buffer objects.
  7185. *
  7186. * Handles blocks of uniform on the GPU.
  7187. *
  7188. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7189. *
  7190. * For more information, please refer to :
  7191. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7192. */
  7193. export class UniformBuffer {
  7194. private _engine;
  7195. private _buffer;
  7196. private _data;
  7197. private _bufferData;
  7198. private _dynamic?;
  7199. private _uniformLocations;
  7200. private _uniformSizes;
  7201. private _uniformLocationPointer;
  7202. private _needSync;
  7203. private _noUBO;
  7204. private _currentEffect;
  7205. /** @hidden */
  7206. _alreadyBound: boolean;
  7207. private static _MAX_UNIFORM_SIZE;
  7208. private static _tempBuffer;
  7209. /**
  7210. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7211. * This is dynamic to allow compat with webgl 1 and 2.
  7212. * You will need to pass the name of the uniform as well as the value.
  7213. */
  7214. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7215. /**
  7216. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7217. * This is dynamic to allow compat with webgl 1 and 2.
  7218. * You will need to pass the name of the uniform as well as the value.
  7219. */
  7220. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7221. /**
  7222. * Lambda to Update a single float in a uniform buffer.
  7223. * This is dynamic to allow compat with webgl 1 and 2.
  7224. * You will need to pass the name of the uniform as well as the value.
  7225. */
  7226. updateFloat: (name: string, x: number) => void;
  7227. /**
  7228. * Lambda to Update a vec2 of float in a uniform buffer.
  7229. * This is dynamic to allow compat with webgl 1 and 2.
  7230. * You will need to pass the name of the uniform as well as the value.
  7231. */
  7232. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7233. /**
  7234. * Lambda to Update a vec3 of float in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7239. /**
  7240. * Lambda to Update a vec4 of float in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7245. /**
  7246. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateMatrix: (name: string, mat: Matrix) => void;
  7251. /**
  7252. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateVector3: (name: string, vector: Vector3) => void;
  7257. /**
  7258. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateVector4: (name: string, vector: Vector4) => void;
  7263. /**
  7264. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7275. /**
  7276. * Instantiates a new Uniform buffer objects.
  7277. *
  7278. * Handles blocks of uniform on the GPU.
  7279. *
  7280. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7281. *
  7282. * For more information, please refer to :
  7283. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7284. * @param engine Define the engine the buffer is associated with
  7285. * @param data Define the data contained in the buffer
  7286. * @param dynamic Define if the buffer is updatable
  7287. */
  7288. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7289. /**
  7290. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7291. * or just falling back on setUniformXXX calls.
  7292. */
  7293. get useUbo(): boolean;
  7294. /**
  7295. * Indicates if the WebGL underlying uniform buffer is in sync
  7296. * with the javascript cache data.
  7297. */
  7298. get isSync(): boolean;
  7299. /**
  7300. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7301. * Also, a dynamic UniformBuffer will disable cache verification and always
  7302. * update the underlying WebGL uniform buffer to the GPU.
  7303. * @returns if Dynamic, otherwise false
  7304. */
  7305. isDynamic(): boolean;
  7306. /**
  7307. * The data cache on JS side.
  7308. * @returns the underlying data as a float array
  7309. */
  7310. getData(): Float32Array;
  7311. /**
  7312. * The underlying WebGL Uniform buffer.
  7313. * @returns the webgl buffer
  7314. */
  7315. getBuffer(): Nullable<DataBuffer>;
  7316. /**
  7317. * std140 layout specifies how to align data within an UBO structure.
  7318. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7319. * for specs.
  7320. */
  7321. private _fillAlignment;
  7322. /**
  7323. * Adds an uniform in the buffer.
  7324. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7325. * for the layout to be correct !
  7326. * @param name Name of the uniform, as used in the uniform block in the shader.
  7327. * @param size Data size, or data directly.
  7328. */
  7329. addUniform(name: string, size: number | number[]): void;
  7330. /**
  7331. * Adds a Matrix 4x4 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param mat A 4x4 matrix.
  7334. */
  7335. addMatrix(name: string, mat: Matrix): void;
  7336. /**
  7337. * Adds a vec2 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param x Define the x component value of the vec2
  7340. * @param y Define the y component value of the vec2
  7341. */
  7342. addFloat2(name: string, x: number, y: number): void;
  7343. /**
  7344. * Adds a vec3 to the uniform buffer.
  7345. * @param name Name of the uniform, as used in the uniform block in the shader.
  7346. * @param x Define the x component value of the vec3
  7347. * @param y Define the y component value of the vec3
  7348. * @param z Define the z component value of the vec3
  7349. */
  7350. addFloat3(name: string, x: number, y: number, z: number): void;
  7351. /**
  7352. * Adds a vec3 to the uniform buffer.
  7353. * @param name Name of the uniform, as used in the uniform block in the shader.
  7354. * @param color Define the vec3 from a Color
  7355. */
  7356. addColor3(name: string, color: Color3): void;
  7357. /**
  7358. * Adds a vec4 to the uniform buffer.
  7359. * @param name Name of the uniform, as used in the uniform block in the shader.
  7360. * @param color Define the rgb components from a Color
  7361. * @param alpha Define the a component of the vec4
  7362. */
  7363. addColor4(name: string, color: Color3, alpha: number): void;
  7364. /**
  7365. * Adds a vec3 to the uniform buffer.
  7366. * @param name Name of the uniform, as used in the uniform block in the shader.
  7367. * @param vector Define the vec3 components from a Vector
  7368. */
  7369. addVector3(name: string, vector: Vector3): void;
  7370. /**
  7371. * Adds a Matrix 3x3 to the uniform buffer.
  7372. * @param name Name of the uniform, as used in the uniform block in the shader.
  7373. */
  7374. addMatrix3x3(name: string): void;
  7375. /**
  7376. * Adds a Matrix 2x2 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. */
  7379. addMatrix2x2(name: string): void;
  7380. /**
  7381. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7382. */
  7383. create(): void;
  7384. /** @hidden */
  7385. _rebuild(): void;
  7386. /**
  7387. * Updates the WebGL Uniform Buffer on the GPU.
  7388. * If the `dynamic` flag is set to true, no cache comparison is done.
  7389. * Otherwise, the buffer will be updated only if the cache differs.
  7390. */
  7391. update(): void;
  7392. /**
  7393. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7394. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7395. * @param data Define the flattened data
  7396. * @param size Define the size of the data.
  7397. */
  7398. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7399. private _valueCache;
  7400. private _cacheMatrix;
  7401. private _updateMatrix3x3ForUniform;
  7402. private _updateMatrix3x3ForEffect;
  7403. private _updateMatrix2x2ForEffect;
  7404. private _updateMatrix2x2ForUniform;
  7405. private _updateFloatForEffect;
  7406. private _updateFloatForUniform;
  7407. private _updateFloat2ForEffect;
  7408. private _updateFloat2ForUniform;
  7409. private _updateFloat3ForEffect;
  7410. private _updateFloat3ForUniform;
  7411. private _updateFloat4ForEffect;
  7412. private _updateFloat4ForUniform;
  7413. private _updateMatrixForEffect;
  7414. private _updateMatrixForUniform;
  7415. private _updateVector3ForEffect;
  7416. private _updateVector3ForUniform;
  7417. private _updateVector4ForEffect;
  7418. private _updateVector4ForUniform;
  7419. private _updateColor3ForEffect;
  7420. private _updateColor3ForUniform;
  7421. private _updateColor4ForEffect;
  7422. private _updateColor4ForUniform;
  7423. /**
  7424. * Sets a sampler uniform on the effect.
  7425. * @param name Define the name of the sampler.
  7426. * @param texture Define the texture to set in the sampler
  7427. */
  7428. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7429. /**
  7430. * Directly updates the value of the uniform in the cache AND on the GPU.
  7431. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7432. * @param data Define the flattened data
  7433. */
  7434. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7435. /**
  7436. * Binds this uniform buffer to an effect.
  7437. * @param effect Define the effect to bind the buffer to
  7438. * @param name Name of the uniform block in the shader.
  7439. */
  7440. bindToEffect(effect: Effect, name: string): void;
  7441. /**
  7442. * Disposes the uniform buffer.
  7443. */
  7444. dispose(): void;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * Enum that determines the text-wrapping mode to use.
  7450. */
  7451. export enum InspectableType {
  7452. /**
  7453. * Checkbox for booleans
  7454. */
  7455. Checkbox = 0,
  7456. /**
  7457. * Sliders for numbers
  7458. */
  7459. Slider = 1,
  7460. /**
  7461. * Vector3
  7462. */
  7463. Vector3 = 2,
  7464. /**
  7465. * Quaternions
  7466. */
  7467. Quaternion = 3,
  7468. /**
  7469. * Color3
  7470. */
  7471. Color3 = 4,
  7472. /**
  7473. * String
  7474. */
  7475. String = 5
  7476. }
  7477. /**
  7478. * Interface used to define custom inspectable properties.
  7479. * This interface is used by the inspector to display custom property grids
  7480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7481. */
  7482. export interface IInspectable {
  7483. /**
  7484. * Gets the label to display
  7485. */
  7486. label: string;
  7487. /**
  7488. * Gets the name of the property to edit
  7489. */
  7490. propertyName: string;
  7491. /**
  7492. * Gets the type of the editor to use
  7493. */
  7494. type: InspectableType;
  7495. /**
  7496. * Gets the minimum value of the property when using in "slider" mode
  7497. */
  7498. min?: number;
  7499. /**
  7500. * Gets the maximum value of the property when using in "slider" mode
  7501. */
  7502. max?: number;
  7503. /**
  7504. * Gets the setp to use when using in "slider" mode
  7505. */
  7506. step?: number;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * Class used to provide helper for timing
  7512. */
  7513. export class TimingTools {
  7514. /**
  7515. * Polyfill for setImmediate
  7516. * @param action defines the action to execute after the current execution block
  7517. */
  7518. static SetImmediate(action: () => void): void;
  7519. }
  7520. }
  7521. declare module BABYLON {
  7522. /**
  7523. * Class used to enable instatition of objects by class name
  7524. */
  7525. export class InstantiationTools {
  7526. /**
  7527. * Use this object to register external classes like custom textures or material
  7528. * to allow the laoders to instantiate them
  7529. */
  7530. static RegisteredExternalClasses: {
  7531. [key: string]: Object;
  7532. };
  7533. /**
  7534. * Tries to instantiate a new object from a given class name
  7535. * @param className defines the class name to instantiate
  7536. * @returns the new object or null if the system was not able to do the instantiation
  7537. */
  7538. static Instantiate(className: string): any;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * Define options used to create a depth texture
  7544. */
  7545. export class DepthTextureCreationOptions {
  7546. /** Specifies whether or not a stencil should be allocated in the texture */
  7547. generateStencil?: boolean;
  7548. /** Specifies whether or not bilinear filtering is enable on the texture */
  7549. bilinearFiltering?: boolean;
  7550. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7551. comparisonFunction?: number;
  7552. /** Specifies if the created texture is a cube texture */
  7553. isCube?: boolean;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. interface ThinEngine {
  7558. /**
  7559. * Creates a depth stencil cube texture.
  7560. * This is only available in WebGL 2.
  7561. * @param size The size of face edge in the cube texture.
  7562. * @param options The options defining the cube texture.
  7563. * @returns The cube texture
  7564. */
  7565. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7566. /**
  7567. * Creates a cube texture
  7568. * @param rootUrl defines the url where the files to load is located
  7569. * @param scene defines the current scene
  7570. * @param files defines the list of files to load (1 per face)
  7571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7572. * @param onLoad defines an optional callback raised when the texture is loaded
  7573. * @param onError defines an optional callback raised if there is an issue to load the texture
  7574. * @param format defines the format of the data
  7575. * @param forcedExtension defines the extension to use to pick the right loader
  7576. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7579. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7580. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7581. * @returns the cube texture as an InternalTexture
  7582. */
  7583. 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;
  7584. /**
  7585. * Creates a cube texture
  7586. * @param rootUrl defines the url where the files to load is located
  7587. * @param scene defines the current scene
  7588. * @param files defines the list of files to load (1 per face)
  7589. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7590. * @param onLoad defines an optional callback raised when the texture is loaded
  7591. * @param onError defines an optional callback raised if there is an issue to load the texture
  7592. * @param format defines the format of the data
  7593. * @param forcedExtension defines the extension to use to pick the right loader
  7594. * @returns the cube texture as an InternalTexture
  7595. */
  7596. 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;
  7597. /**
  7598. * Creates a cube texture
  7599. * @param rootUrl defines the url where the files to load is located
  7600. * @param scene defines the current scene
  7601. * @param files defines the list of files to load (1 per face)
  7602. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7603. * @param onLoad defines an optional callback raised when the texture is loaded
  7604. * @param onError defines an optional callback raised if there is an issue to load the texture
  7605. * @param format defines the format of the data
  7606. * @param forcedExtension defines the extension to use to pick the right loader
  7607. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @returns the cube texture as an InternalTexture
  7611. */
  7612. 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;
  7613. /** @hidden */
  7614. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7615. /** @hidden */
  7616. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7617. /** @hidden */
  7618. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7619. /** @hidden */
  7620. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7621. /**
  7622. * @hidden
  7623. */
  7624. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * Class for creating a cube texture
  7630. */
  7631. export class CubeTexture extends BaseTexture {
  7632. private _delayedOnLoad;
  7633. /**
  7634. * The url of the texture
  7635. */
  7636. url: string;
  7637. /**
  7638. * Gets or sets the center of the bounding box associated with the cube texture.
  7639. * It must define where the camera used to render the texture was set
  7640. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7641. */
  7642. boundingBoxPosition: Vector3;
  7643. private _boundingBoxSize;
  7644. /**
  7645. * Gets or sets the size of the bounding box associated with the cube texture
  7646. * When defined, the cubemap will switch to local mode
  7647. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7648. * @example https://www.babylonjs-playground.com/#RNASML
  7649. */
  7650. set boundingBoxSize(value: Vector3);
  7651. /**
  7652. * Returns the bounding box size
  7653. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7654. */
  7655. get boundingBoxSize(): Vector3;
  7656. protected _rotationY: number;
  7657. /**
  7658. * Sets texture matrix rotation angle around Y axis in radians.
  7659. */
  7660. set rotationY(value: number);
  7661. /**
  7662. * Gets texture matrix rotation angle around Y axis radians.
  7663. */
  7664. get rotationY(): number;
  7665. /**
  7666. * Are mip maps generated for this texture or not.
  7667. */
  7668. get noMipmap(): boolean;
  7669. private _noMipmap;
  7670. private _files;
  7671. protected _forcedExtension: Nullable<string>;
  7672. private _extensions;
  7673. private _textureMatrix;
  7674. private _format;
  7675. private _createPolynomials;
  7676. /** @hidden */
  7677. _prefiltered: boolean;
  7678. /**
  7679. * Creates a cube texture from an array of image urls
  7680. * @param files defines an array of image urls
  7681. * @param scene defines the hosting scene
  7682. * @param noMipmap specifies if mip maps are not used
  7683. * @returns a cube texture
  7684. */
  7685. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7686. /**
  7687. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7688. * @param url defines the url of the prefiltered texture
  7689. * @param scene defines the scene the texture is attached to
  7690. * @param forcedExtension defines the extension of the file if different from the url
  7691. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7692. * @return the prefiltered texture
  7693. */
  7694. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7695. /**
  7696. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7697. * as prefiltered data.
  7698. * @param rootUrl defines the url of the texture or the root name of the six images
  7699. * @param scene defines the scene the texture is attached to
  7700. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7701. * @param noMipmap defines if mipmaps should be created or not
  7702. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7703. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7704. * @param onError defines a callback triggered in case of error during load
  7705. * @param format defines the internal format to use for the texture once loaded
  7706. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7707. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7708. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7711. * @return the cube texture
  7712. */
  7713. 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);
  7714. /**
  7715. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7716. */
  7717. get isPrefiltered(): boolean;
  7718. /**
  7719. * Get the current class name of the texture useful for serialization or dynamic coding.
  7720. * @returns "CubeTexture"
  7721. */
  7722. getClassName(): string;
  7723. /**
  7724. * Update the url (and optional buffer) of this texture if url was null during construction.
  7725. * @param url the url of the texture
  7726. * @param forcedExtension defines the extension to use
  7727. * @param onLoad callback called when the texture is loaded (defaults to null)
  7728. */
  7729. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7730. /**
  7731. * Delays loading of the cube texture
  7732. * @param forcedExtension defines the extension to use
  7733. */
  7734. delayLoad(forcedExtension?: string): void;
  7735. /**
  7736. * Returns the reflection texture matrix
  7737. * @returns the reflection texture matrix
  7738. */
  7739. getReflectionTextureMatrix(): Matrix;
  7740. /**
  7741. * Sets the reflection texture matrix
  7742. * @param value Reflection texture matrix
  7743. */
  7744. setReflectionTextureMatrix(value: Matrix): void;
  7745. /**
  7746. * Parses text to create a cube texture
  7747. * @param parsedTexture define the serialized text to read from
  7748. * @param scene defines the hosting scene
  7749. * @param rootUrl defines the root url of the cube texture
  7750. * @returns a cube texture
  7751. */
  7752. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7753. /**
  7754. * Makes a clone, or deep copy, of the cube texture
  7755. * @returns a new cube texture
  7756. */
  7757. clone(): CubeTexture;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Manages the defines for the Material
  7763. */
  7764. export class MaterialDefines {
  7765. /** @hidden */
  7766. protected _keys: string[];
  7767. private _isDirty;
  7768. /** @hidden */
  7769. _renderId: number;
  7770. /** @hidden */
  7771. _areLightsDirty: boolean;
  7772. /** @hidden */
  7773. _areLightsDisposed: boolean;
  7774. /** @hidden */
  7775. _areAttributesDirty: boolean;
  7776. /** @hidden */
  7777. _areTexturesDirty: boolean;
  7778. /** @hidden */
  7779. _areFresnelDirty: boolean;
  7780. /** @hidden */
  7781. _areMiscDirty: boolean;
  7782. /** @hidden */
  7783. _areImageProcessingDirty: boolean;
  7784. /** @hidden */
  7785. _normals: boolean;
  7786. /** @hidden */
  7787. _uvs: boolean;
  7788. /** @hidden */
  7789. _needNormals: boolean;
  7790. /** @hidden */
  7791. _needUVs: boolean;
  7792. [id: string]: any;
  7793. /**
  7794. * Specifies if the material needs to be re-calculated
  7795. */
  7796. get isDirty(): boolean;
  7797. /**
  7798. * Marks the material to indicate that it has been re-calculated
  7799. */
  7800. markAsProcessed(): void;
  7801. /**
  7802. * Marks the material to indicate that it needs to be re-calculated
  7803. */
  7804. markAsUnprocessed(): void;
  7805. /**
  7806. * Marks the material to indicate all of its defines need to be re-calculated
  7807. */
  7808. markAllAsDirty(): void;
  7809. /**
  7810. * Marks the material to indicate that image processing needs to be re-calculated
  7811. */
  7812. markAsImageProcessingDirty(): void;
  7813. /**
  7814. * Marks the material to indicate the lights need to be re-calculated
  7815. * @param disposed Defines whether the light is dirty due to dispose or not
  7816. */
  7817. markAsLightDirty(disposed?: boolean): void;
  7818. /**
  7819. * Marks the attribute state as changed
  7820. */
  7821. markAsAttributesDirty(): void;
  7822. /**
  7823. * Marks the texture state as changed
  7824. */
  7825. markAsTexturesDirty(): void;
  7826. /**
  7827. * Marks the fresnel state as changed
  7828. */
  7829. markAsFresnelDirty(): void;
  7830. /**
  7831. * Marks the misc state as changed
  7832. */
  7833. markAsMiscDirty(): void;
  7834. /**
  7835. * Rebuilds the material defines
  7836. */
  7837. rebuild(): void;
  7838. /**
  7839. * Specifies if two material defines are equal
  7840. * @param other - A material define instance to compare to
  7841. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7842. */
  7843. isEqual(other: MaterialDefines): boolean;
  7844. /**
  7845. * Clones this instance's defines to another instance
  7846. * @param other - material defines to clone values to
  7847. */
  7848. cloneTo(other: MaterialDefines): void;
  7849. /**
  7850. * Resets the material define values
  7851. */
  7852. reset(): void;
  7853. /**
  7854. * Converts the material define values to a string
  7855. * @returns - String of material define information
  7856. */
  7857. toString(): string;
  7858. }
  7859. }
  7860. declare module BABYLON {
  7861. /**
  7862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7864. * 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;
  7865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7866. */
  7867. export class ColorCurves {
  7868. private _dirty;
  7869. private _tempColor;
  7870. private _globalCurve;
  7871. private _highlightsCurve;
  7872. private _midtonesCurve;
  7873. private _shadowsCurve;
  7874. private _positiveCurve;
  7875. private _negativeCurve;
  7876. private _globalHue;
  7877. private _globalDensity;
  7878. private _globalSaturation;
  7879. private _globalExposure;
  7880. /**
  7881. * Gets the global Hue value.
  7882. * 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).
  7883. */
  7884. get globalHue(): number;
  7885. /**
  7886. * Sets the global Hue value.
  7887. * 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).
  7888. */
  7889. set globalHue(value: number);
  7890. /**
  7891. * Gets the global Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. get globalDensity(): number;
  7896. /**
  7897. * Sets the global Density value.
  7898. * 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.
  7899. * Values less than zero provide a filter of opposite hue.
  7900. */
  7901. set globalDensity(value: number);
  7902. /**
  7903. * Gets the global Saturation value.
  7904. * 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.
  7905. */
  7906. get globalSaturation(): number;
  7907. /**
  7908. * Sets the global Saturation value.
  7909. * 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.
  7910. */
  7911. set globalSaturation(value: number);
  7912. /**
  7913. * Gets the global Exposure value.
  7914. * 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.
  7915. */
  7916. get globalExposure(): number;
  7917. /**
  7918. * Sets the global Exposure value.
  7919. * 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.
  7920. */
  7921. set globalExposure(value: number);
  7922. private _highlightsHue;
  7923. private _highlightsDensity;
  7924. private _highlightsSaturation;
  7925. private _highlightsExposure;
  7926. /**
  7927. * Gets the highlights Hue value.
  7928. * 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).
  7929. */
  7930. get highlightsHue(): number;
  7931. /**
  7932. * Sets the highlights Hue value.
  7933. * 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).
  7934. */
  7935. set highlightsHue(value: number);
  7936. /**
  7937. * Gets the highlights Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get highlightsDensity(): number;
  7942. /**
  7943. * Sets the highlights Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set highlightsDensity(value: number);
  7948. /**
  7949. * Gets the highlights Saturation value.
  7950. * 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.
  7951. */
  7952. get highlightsSaturation(): number;
  7953. /**
  7954. * Sets the highlights Saturation value.
  7955. * 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.
  7956. */
  7957. set highlightsSaturation(value: number);
  7958. /**
  7959. * Gets the highlights Exposure value.
  7960. * 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.
  7961. */
  7962. get highlightsExposure(): number;
  7963. /**
  7964. * Sets the highlights Exposure value.
  7965. * 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.
  7966. */
  7967. set highlightsExposure(value: number);
  7968. private _midtonesHue;
  7969. private _midtonesDensity;
  7970. private _midtonesSaturation;
  7971. private _midtonesExposure;
  7972. /**
  7973. * Gets the midtones Hue value.
  7974. * 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).
  7975. */
  7976. get midtonesHue(): number;
  7977. /**
  7978. * Sets the midtones Hue value.
  7979. * 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).
  7980. */
  7981. set midtonesHue(value: number);
  7982. /**
  7983. * Gets the midtones Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get midtonesDensity(): number;
  7988. /**
  7989. * Sets the midtones Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set midtonesDensity(value: number);
  7994. /**
  7995. * Gets the midtones Saturation value.
  7996. * 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.
  7997. */
  7998. get midtonesSaturation(): number;
  7999. /**
  8000. * Sets the midtones Saturation value.
  8001. * 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.
  8002. */
  8003. set midtonesSaturation(value: number);
  8004. /**
  8005. * Gets the midtones Exposure value.
  8006. * 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.
  8007. */
  8008. get midtonesExposure(): number;
  8009. /**
  8010. * Sets the midtones Exposure value.
  8011. * 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.
  8012. */
  8013. set midtonesExposure(value: number);
  8014. private _shadowsHue;
  8015. private _shadowsDensity;
  8016. private _shadowsSaturation;
  8017. private _shadowsExposure;
  8018. /**
  8019. * Gets the shadows Hue value.
  8020. * 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).
  8021. */
  8022. get shadowsHue(): number;
  8023. /**
  8024. * Sets the shadows Hue value.
  8025. * 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).
  8026. */
  8027. set shadowsHue(value: number);
  8028. /**
  8029. * Gets the shadows Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get shadowsDensity(): number;
  8034. /**
  8035. * Sets the shadows Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set shadowsDensity(value: number);
  8040. /**
  8041. * Gets the shadows Saturation value.
  8042. * 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.
  8043. */
  8044. get shadowsSaturation(): number;
  8045. /**
  8046. * Sets the shadows Saturation value.
  8047. * 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.
  8048. */
  8049. set shadowsSaturation(value: number);
  8050. /**
  8051. * Gets the shadows Exposure value.
  8052. * 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.
  8053. */
  8054. get shadowsExposure(): number;
  8055. /**
  8056. * Sets the shadows Exposure value.
  8057. * 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.
  8058. */
  8059. set shadowsExposure(value: number);
  8060. /**
  8061. * Returns the class name
  8062. * @returns The class name
  8063. */
  8064. getClassName(): string;
  8065. /**
  8066. * Binds the color curves to the shader.
  8067. * @param colorCurves The color curve to bind
  8068. * @param effect The effect to bind to
  8069. * @param positiveUniform The positive uniform shader parameter
  8070. * @param neutralUniform The neutral uniform shader parameter
  8071. * @param negativeUniform The negative uniform shader parameter
  8072. */
  8073. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8074. /**
  8075. * Prepare the list of uniforms associated with the ColorCurves effects.
  8076. * @param uniformsList The list of uniforms used in the effect
  8077. */
  8078. static PrepareUniforms(uniformsList: string[]): void;
  8079. /**
  8080. * Returns color grading data based on a hue, density, saturation and exposure value.
  8081. * @param filterHue The hue of the color filter.
  8082. * @param filterDensity The density of the color filter.
  8083. * @param saturation The saturation.
  8084. * @param exposure The exposure.
  8085. * @param result The result data container.
  8086. */
  8087. private getColorGradingDataToRef;
  8088. /**
  8089. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8090. * @param value The input slider value in range [-100,100].
  8091. * @returns Adjusted value.
  8092. */
  8093. private static applyColorGradingSliderNonlinear;
  8094. /**
  8095. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8096. * @param hue The hue (H) input.
  8097. * @param saturation The saturation (S) input.
  8098. * @param brightness The brightness (B) input.
  8099. * @result An RGBA color represented as Vector4.
  8100. */
  8101. private static fromHSBToRef;
  8102. /**
  8103. * Returns a value clamped between min and max
  8104. * @param value The value to clamp
  8105. * @param min The minimum of value
  8106. * @param max The maximum of value
  8107. * @returns The clamped value.
  8108. */
  8109. private static clamp;
  8110. /**
  8111. * Clones the current color curve instance.
  8112. * @return The cloned curves
  8113. */
  8114. clone(): ColorCurves;
  8115. /**
  8116. * Serializes the current color curve instance to a json representation.
  8117. * @return a JSON representation
  8118. */
  8119. serialize(): any;
  8120. /**
  8121. * Parses the color curve from a json representation.
  8122. * @param source the JSON source to parse
  8123. * @return The parsed curves
  8124. */
  8125. static Parse(source: any): ColorCurves;
  8126. }
  8127. }
  8128. declare module BABYLON {
  8129. /**
  8130. * Interface to follow in your material defines to integrate easily the
  8131. * Image proccessing functions.
  8132. * @hidden
  8133. */
  8134. export interface IImageProcessingConfigurationDefines {
  8135. IMAGEPROCESSING: boolean;
  8136. VIGNETTE: boolean;
  8137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8138. VIGNETTEBLENDMODEOPAQUE: boolean;
  8139. TONEMAPPING: boolean;
  8140. TONEMAPPING_ACES: boolean;
  8141. CONTRAST: boolean;
  8142. EXPOSURE: boolean;
  8143. COLORCURVES: boolean;
  8144. COLORGRADING: boolean;
  8145. COLORGRADING3D: boolean;
  8146. SAMPLER3DGREENDEPTH: boolean;
  8147. SAMPLER3DBGRMAP: boolean;
  8148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8149. }
  8150. /**
  8151. * @hidden
  8152. */
  8153. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8154. IMAGEPROCESSING: boolean;
  8155. VIGNETTE: boolean;
  8156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8157. VIGNETTEBLENDMODEOPAQUE: boolean;
  8158. TONEMAPPING: boolean;
  8159. TONEMAPPING_ACES: boolean;
  8160. CONTRAST: boolean;
  8161. COLORCURVES: boolean;
  8162. COLORGRADING: boolean;
  8163. COLORGRADING3D: boolean;
  8164. SAMPLER3DGREENDEPTH: boolean;
  8165. SAMPLER3DBGRMAP: boolean;
  8166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8167. EXPOSURE: boolean;
  8168. constructor();
  8169. }
  8170. /**
  8171. * This groups together the common properties used for image processing either in direct forward pass
  8172. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8173. * or not.
  8174. */
  8175. export class ImageProcessingConfiguration {
  8176. /**
  8177. * Default tone mapping applied in BabylonJS.
  8178. */
  8179. static readonly TONEMAPPING_STANDARD: number;
  8180. /**
  8181. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8182. * to other engines rendering to increase portability.
  8183. */
  8184. static readonly TONEMAPPING_ACES: number;
  8185. /**
  8186. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8187. */
  8188. colorCurves: Nullable<ColorCurves>;
  8189. private _colorCurvesEnabled;
  8190. /**
  8191. * Gets wether the color curves effect is enabled.
  8192. */
  8193. get colorCurvesEnabled(): boolean;
  8194. /**
  8195. * Sets wether the color curves effect is enabled.
  8196. */
  8197. set colorCurvesEnabled(value: boolean);
  8198. private _colorGradingTexture;
  8199. /**
  8200. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8201. */
  8202. get colorGradingTexture(): Nullable<BaseTexture>;
  8203. /**
  8204. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8205. */
  8206. set colorGradingTexture(value: Nullable<BaseTexture>);
  8207. private _colorGradingEnabled;
  8208. /**
  8209. * Gets wether the color grading effect is enabled.
  8210. */
  8211. get colorGradingEnabled(): boolean;
  8212. /**
  8213. * Sets wether the color grading effect is enabled.
  8214. */
  8215. set colorGradingEnabled(value: boolean);
  8216. private _colorGradingWithGreenDepth;
  8217. /**
  8218. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8219. */
  8220. get colorGradingWithGreenDepth(): boolean;
  8221. /**
  8222. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8223. */
  8224. set colorGradingWithGreenDepth(value: boolean);
  8225. private _colorGradingBGR;
  8226. /**
  8227. * Gets wether the color grading texture contains BGR values.
  8228. */
  8229. get colorGradingBGR(): boolean;
  8230. /**
  8231. * Sets wether the color grading texture contains BGR values.
  8232. */
  8233. set colorGradingBGR(value: boolean);
  8234. /** @hidden */
  8235. _exposure: number;
  8236. /**
  8237. * Gets the Exposure used in the effect.
  8238. */
  8239. get exposure(): number;
  8240. /**
  8241. * Sets the Exposure used in the effect.
  8242. */
  8243. set exposure(value: number);
  8244. private _toneMappingEnabled;
  8245. /**
  8246. * Gets wether the tone mapping effect is enabled.
  8247. */
  8248. get toneMappingEnabled(): boolean;
  8249. /**
  8250. * Sets wether the tone mapping effect is enabled.
  8251. */
  8252. set toneMappingEnabled(value: boolean);
  8253. private _toneMappingType;
  8254. /**
  8255. * Gets the type of tone mapping effect.
  8256. */
  8257. get toneMappingType(): number;
  8258. /**
  8259. * Sets the type of tone mapping effect used in BabylonJS.
  8260. */
  8261. set toneMappingType(value: number);
  8262. protected _contrast: number;
  8263. /**
  8264. * Gets the contrast used in the effect.
  8265. */
  8266. get contrast(): number;
  8267. /**
  8268. * Sets the contrast used in the effect.
  8269. */
  8270. set contrast(value: number);
  8271. /**
  8272. * Vignette stretch size.
  8273. */
  8274. vignetteStretch: number;
  8275. /**
  8276. * Vignette centre X Offset.
  8277. */
  8278. vignetteCentreX: number;
  8279. /**
  8280. * Vignette centre Y Offset.
  8281. */
  8282. vignetteCentreY: number;
  8283. /**
  8284. * Vignette weight or intensity of the vignette effect.
  8285. */
  8286. vignetteWeight: number;
  8287. /**
  8288. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8289. * if vignetteEnabled is set to true.
  8290. */
  8291. vignetteColor: Color4;
  8292. /**
  8293. * Camera field of view used by the Vignette effect.
  8294. */
  8295. vignetteCameraFov: number;
  8296. private _vignetteBlendMode;
  8297. /**
  8298. * Gets the vignette blend mode allowing different kind of effect.
  8299. */
  8300. get vignetteBlendMode(): number;
  8301. /**
  8302. * Sets the vignette blend mode allowing different kind of effect.
  8303. */
  8304. set vignetteBlendMode(value: number);
  8305. private _vignetteEnabled;
  8306. /**
  8307. * Gets wether the vignette effect is enabled.
  8308. */
  8309. get vignetteEnabled(): boolean;
  8310. /**
  8311. * Sets wether the vignette effect is enabled.
  8312. */
  8313. set vignetteEnabled(value: boolean);
  8314. private _applyByPostProcess;
  8315. /**
  8316. * Gets wether the image processing is applied through a post process or not.
  8317. */
  8318. get applyByPostProcess(): boolean;
  8319. /**
  8320. * Sets wether the image processing is applied through a post process or not.
  8321. */
  8322. set applyByPostProcess(value: boolean);
  8323. private _isEnabled;
  8324. /**
  8325. * Gets wether the image processing is enabled or not.
  8326. */
  8327. get isEnabled(): boolean;
  8328. /**
  8329. * Sets wether the image processing is enabled or not.
  8330. */
  8331. set isEnabled(value: boolean);
  8332. /**
  8333. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8334. */
  8335. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8336. /**
  8337. * Method called each time the image processing information changes requires to recompile the effect.
  8338. */
  8339. protected _updateParameters(): void;
  8340. /**
  8341. * Gets the current class name.
  8342. * @return "ImageProcessingConfiguration"
  8343. */
  8344. getClassName(): string;
  8345. /**
  8346. * Prepare the list of uniforms associated with the Image Processing effects.
  8347. * @param uniforms The list of uniforms used in the effect
  8348. * @param defines the list of defines currently in use
  8349. */
  8350. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8351. /**
  8352. * Prepare the list of samplers associated with the Image Processing effects.
  8353. * @param samplersList The list of uniforms used in the effect
  8354. * @param defines the list of defines currently in use
  8355. */
  8356. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8357. /**
  8358. * Prepare the list of defines associated to the shader.
  8359. * @param defines the list of defines to complete
  8360. * @param forPostProcess Define if we are currently in post process mode or not
  8361. */
  8362. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8363. /**
  8364. * Returns true if all the image processing information are ready.
  8365. * @returns True if ready, otherwise, false
  8366. */
  8367. isReady(): boolean;
  8368. /**
  8369. * Binds the image processing to the shader.
  8370. * @param effect The effect to bind to
  8371. * @param overrideAspectRatio Override the aspect ratio of the effect
  8372. */
  8373. bind(effect: Effect, overrideAspectRatio?: number): void;
  8374. /**
  8375. * Clones the current image processing instance.
  8376. * @return The cloned image processing
  8377. */
  8378. clone(): ImageProcessingConfiguration;
  8379. /**
  8380. * Serializes the current image processing instance to a json representation.
  8381. * @return a JSON representation
  8382. */
  8383. serialize(): any;
  8384. /**
  8385. * Parses the image processing from a json representation.
  8386. * @param source the JSON source to parse
  8387. * @return The parsed image processing
  8388. */
  8389. static Parse(source: any): ImageProcessingConfiguration;
  8390. private static _VIGNETTEMODE_MULTIPLY;
  8391. private static _VIGNETTEMODE_OPAQUE;
  8392. /**
  8393. * Used to apply the vignette as a mix with the pixel color.
  8394. */
  8395. static get VIGNETTEMODE_MULTIPLY(): number;
  8396. /**
  8397. * Used to apply the vignette as a replacement of the pixel color.
  8398. */
  8399. static get VIGNETTEMODE_OPAQUE(): number;
  8400. }
  8401. }
  8402. declare module BABYLON {
  8403. /** @hidden */
  8404. export var postprocessVertexShader: {
  8405. name: string;
  8406. shader: string;
  8407. };
  8408. }
  8409. declare module BABYLON {
  8410. interface ThinEngine {
  8411. /**
  8412. * Creates a new render target texture
  8413. * @param size defines the size of the texture
  8414. * @param options defines the options used to create the texture
  8415. * @returns a new render target texture stored in an InternalTexture
  8416. */
  8417. createRenderTargetTexture(size: number | {
  8418. width: number;
  8419. height: number;
  8420. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8421. /**
  8422. * Creates a depth stencil texture.
  8423. * This is only available in WebGL 2 or with the depth texture extension available.
  8424. * @param size The size of face edge in the texture.
  8425. * @param options The options defining the texture.
  8426. * @returns The texture
  8427. */
  8428. createDepthStencilTexture(size: number | {
  8429. width: number;
  8430. height: number;
  8431. }, options: DepthTextureCreationOptions): InternalTexture;
  8432. /** @hidden */
  8433. _createDepthStencilTexture(size: number | {
  8434. width: number;
  8435. height: number;
  8436. }, options: DepthTextureCreationOptions): InternalTexture;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /**
  8461. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8462. * This is the base of the follow, arc rotate cameras and Free camera
  8463. * @see http://doc.babylonjs.com/features/cameras
  8464. */
  8465. export class TargetCamera extends Camera {
  8466. private static _RigCamTransformMatrix;
  8467. private static _TargetTransformMatrix;
  8468. private static _TargetFocalPoint;
  8469. /**
  8470. * Define the current direction the camera is moving to
  8471. */
  8472. cameraDirection: Vector3;
  8473. /**
  8474. * Define the current rotation the camera is rotating to
  8475. */
  8476. cameraRotation: Vector2;
  8477. /**
  8478. * When set, the up vector of the camera will be updated by the rotation of the camera
  8479. */
  8480. updateUpVectorFromRotation: boolean;
  8481. private _tmpQuaternion;
  8482. /**
  8483. * Define the current rotation of the camera
  8484. */
  8485. rotation: Vector3;
  8486. /**
  8487. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8488. */
  8489. rotationQuaternion: Quaternion;
  8490. /**
  8491. * Define the current speed of the camera
  8492. */
  8493. speed: number;
  8494. /**
  8495. * Add constraint to the camera to prevent it to move freely in all directions and
  8496. * around all axis.
  8497. */
  8498. noRotationConstraint: boolean;
  8499. /**
  8500. * Define the current target of the camera as an object or a position.
  8501. */
  8502. lockedTarget: any;
  8503. /** @hidden */
  8504. _currentTarget: Vector3;
  8505. /** @hidden */
  8506. _initialFocalDistance: number;
  8507. /** @hidden */
  8508. _viewMatrix: Matrix;
  8509. /** @hidden */
  8510. _camMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraTransformMatrix: Matrix;
  8513. /** @hidden */
  8514. _cameraRotationMatrix: Matrix;
  8515. /** @hidden */
  8516. _referencePoint: Vector3;
  8517. /** @hidden */
  8518. _transformedReferencePoint: Vector3;
  8519. protected _globalCurrentTarget: Vector3;
  8520. protected _globalCurrentUpVector: Vector3;
  8521. /** @hidden */
  8522. _reset: () => void;
  8523. private _defaultUp;
  8524. /**
  8525. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8526. * This is the base of the follow, arc rotate cameras and Free camera
  8527. * @see http://doc.babylonjs.com/features/cameras
  8528. * @param name Defines the name of the camera in the scene
  8529. * @param position Defines the start position of the camera in the scene
  8530. * @param scene Defines the scene the camera belongs to
  8531. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8532. */
  8533. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8534. /**
  8535. * Gets the position in front of the camera at a given distance.
  8536. * @param distance The distance from the camera we want the position to be
  8537. * @returns the position
  8538. */
  8539. getFrontPosition(distance: number): Vector3;
  8540. /** @hidden */
  8541. _getLockedTargetPosition(): Nullable<Vector3>;
  8542. private _storedPosition;
  8543. private _storedRotation;
  8544. private _storedRotationQuaternion;
  8545. /**
  8546. * Store current camera state of the camera (fov, position, rotation, etc..)
  8547. * @returns the camera
  8548. */
  8549. storeState(): Camera;
  8550. /**
  8551. * Restored camera state. You must call storeState() first
  8552. * @returns whether it was successful or not
  8553. * @hidden
  8554. */
  8555. _restoreStateValues(): boolean;
  8556. /** @hidden */
  8557. _initCache(): void;
  8558. /** @hidden */
  8559. _updateCache(ignoreParentClass?: boolean): void;
  8560. /** @hidden */
  8561. _isSynchronizedViewMatrix(): boolean;
  8562. /** @hidden */
  8563. _computeLocalCameraSpeed(): number;
  8564. /**
  8565. * Defines the target the camera should look at.
  8566. * @param target Defines the new target as a Vector or a mesh
  8567. */
  8568. setTarget(target: Vector3): void;
  8569. /**
  8570. * Return the current target position of the camera. This value is expressed in local space.
  8571. * @returns the target position
  8572. */
  8573. getTarget(): Vector3;
  8574. /** @hidden */
  8575. _decideIfNeedsToMove(): boolean;
  8576. /** @hidden */
  8577. _updatePosition(): void;
  8578. /** @hidden */
  8579. _checkInputs(): void;
  8580. protected _updateCameraRotationMatrix(): void;
  8581. /**
  8582. * 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)
  8583. * @returns the current camera
  8584. */
  8585. private _rotateUpVectorWithCameraRotationMatrix;
  8586. private _cachedRotationZ;
  8587. private _cachedQuaternionRotationZ;
  8588. /** @hidden */
  8589. _getViewMatrix(): Matrix;
  8590. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8591. /**
  8592. * @hidden
  8593. */
  8594. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8595. /**
  8596. * @hidden
  8597. */
  8598. _updateRigCameras(): void;
  8599. private _getRigCamPositionAndTarget;
  8600. /**
  8601. * Gets the current object class name.
  8602. * @return the class name
  8603. */
  8604. getClassName(): string;
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /**
  8609. * Gather the list of keyboard event types as constants.
  8610. */
  8611. export class KeyboardEventTypes {
  8612. /**
  8613. * The keydown event is fired when a key becomes active (pressed).
  8614. */
  8615. static readonly KEYDOWN: number;
  8616. /**
  8617. * The keyup event is fired when a key has been released.
  8618. */
  8619. static readonly KEYUP: number;
  8620. }
  8621. /**
  8622. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8623. */
  8624. export class KeyboardInfo {
  8625. /**
  8626. * Defines the type of event (KeyboardEventTypes)
  8627. */
  8628. type: number;
  8629. /**
  8630. * Defines the related dom event
  8631. */
  8632. event: KeyboardEvent;
  8633. /**
  8634. * Instantiates a new keyboard info.
  8635. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8636. * @param type Defines the type of event (KeyboardEventTypes)
  8637. * @param event Defines the related dom event
  8638. */
  8639. constructor(
  8640. /**
  8641. * Defines the type of event (KeyboardEventTypes)
  8642. */
  8643. type: number,
  8644. /**
  8645. * Defines the related dom event
  8646. */
  8647. event: KeyboardEvent);
  8648. }
  8649. /**
  8650. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8651. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8652. */
  8653. export class KeyboardInfoPre extends KeyboardInfo {
  8654. /**
  8655. * Defines the type of event (KeyboardEventTypes)
  8656. */
  8657. type: number;
  8658. /**
  8659. * Defines the related dom event
  8660. */
  8661. event: KeyboardEvent;
  8662. /**
  8663. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8664. */
  8665. skipOnPointerObservable: boolean;
  8666. /**
  8667. * Instantiates a new keyboard pre info.
  8668. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8669. * @param type Defines the type of event (KeyboardEventTypes)
  8670. * @param event Defines the related dom event
  8671. */
  8672. constructor(
  8673. /**
  8674. * Defines the type of event (KeyboardEventTypes)
  8675. */
  8676. type: number,
  8677. /**
  8678. * Defines the related dom event
  8679. */
  8680. event: KeyboardEvent);
  8681. }
  8682. }
  8683. declare module BABYLON {
  8684. /**
  8685. * Manage the keyboard inputs to control the movement of a free camera.
  8686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8687. */
  8688. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: FreeCamera;
  8693. /**
  8694. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8695. */
  8696. keysUp: number[];
  8697. /**
  8698. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8699. */
  8700. keysDown: number[];
  8701. /**
  8702. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8703. */
  8704. keysLeft: number[];
  8705. /**
  8706. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8707. */
  8708. keysRight: number[];
  8709. private _keys;
  8710. private _onCanvasBlurObserver;
  8711. private _onKeyboardObserver;
  8712. private _engine;
  8713. private _scene;
  8714. /**
  8715. * Attach the input controls to a specific dom element to get the input from.
  8716. * @param element Defines the element the controls should be listened from
  8717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8720. /**
  8721. * Detach the current controls from the specified dom element.
  8722. * @param element Defines the element to stop listening the inputs from
  8723. */
  8724. detachControl(element: Nullable<HTMLElement>): void;
  8725. /**
  8726. * Update the current camera state depending on the inputs that have been used this frame.
  8727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8728. */
  8729. checkInputs(): void;
  8730. /**
  8731. * Gets the class name of the current intput.
  8732. * @returns the class name
  8733. */
  8734. getClassName(): string;
  8735. /** @hidden */
  8736. _onLostFocus(): void;
  8737. /**
  8738. * Get the friendly name associated with the input class.
  8739. * @returns the input friendly name
  8740. */
  8741. getSimpleName(): string;
  8742. }
  8743. }
  8744. declare module BABYLON {
  8745. /**
  8746. * Interface describing all the common properties and methods a shadow light needs to implement.
  8747. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8748. * as well as binding the different shadow properties to the effects.
  8749. */
  8750. export interface IShadowLight extends Light {
  8751. /**
  8752. * The light id in the scene (used in scene.findLighById for instance)
  8753. */
  8754. id: string;
  8755. /**
  8756. * The position the shdow will be casted from.
  8757. */
  8758. position: Vector3;
  8759. /**
  8760. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8761. */
  8762. direction: Vector3;
  8763. /**
  8764. * The transformed position. Position of the light in world space taking parenting in account.
  8765. */
  8766. transformedPosition: Vector3;
  8767. /**
  8768. * The transformed direction. Direction of the light in world space taking parenting in account.
  8769. */
  8770. transformedDirection: Vector3;
  8771. /**
  8772. * The friendly name of the light in the scene.
  8773. */
  8774. name: string;
  8775. /**
  8776. * Defines the shadow projection clipping minimum z value.
  8777. */
  8778. shadowMinZ: number;
  8779. /**
  8780. * Defines the shadow projection clipping maximum z value.
  8781. */
  8782. shadowMaxZ: number;
  8783. /**
  8784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8786. */
  8787. computeTransformedInformation(): boolean;
  8788. /**
  8789. * Gets the scene the light belongs to.
  8790. * @returns The scene
  8791. */
  8792. getScene(): Scene;
  8793. /**
  8794. * Callback defining a custom Projection Matrix Builder.
  8795. * This can be used to override the default projection matrix computation.
  8796. */
  8797. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8798. /**
  8799. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8800. * @param matrix The materix to updated with the projection information
  8801. * @param viewMatrix The transform matrix of the light
  8802. * @param renderList The list of mesh to render in the map
  8803. * @returns The current light
  8804. */
  8805. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8806. /**
  8807. * Gets the current depth scale used in ESM.
  8808. * @returns The scale
  8809. */
  8810. getDepthScale(): number;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /**
  8826. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8827. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8828. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8829. */
  8830. getShadowDirection(faceIndex?: number): Vector3;
  8831. /**
  8832. * Gets the minZ used for shadow according to both the scene and the light.
  8833. * @param activeCamera The camera we are returning the min for
  8834. * @returns the depth min z
  8835. */
  8836. getDepthMinZ(activeCamera: Camera): number;
  8837. /**
  8838. * Gets the maxZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the max for
  8840. * @returns the depth max z
  8841. */
  8842. getDepthMaxZ(activeCamera: Camera): number;
  8843. }
  8844. /**
  8845. * Base implementation IShadowLight
  8846. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8847. */
  8848. export abstract class ShadowLight extends Light implements IShadowLight {
  8849. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8850. protected _position: Vector3;
  8851. protected _setPosition(value: Vector3): void;
  8852. /**
  8853. * Sets the position the shadow will be casted from. Also use as the light position for both
  8854. * point and spot lights.
  8855. */
  8856. get position(): Vector3;
  8857. /**
  8858. * Sets the position the shadow will be casted from. Also use as the light position for both
  8859. * point and spot lights.
  8860. */
  8861. set position(value: Vector3);
  8862. protected _direction: Vector3;
  8863. protected _setDirection(value: Vector3): void;
  8864. /**
  8865. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8866. * Also use as the light direction on spot and directional lights.
  8867. */
  8868. get direction(): Vector3;
  8869. /**
  8870. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8871. * Also use as the light direction on spot and directional lights.
  8872. */
  8873. set direction(value: Vector3);
  8874. private _shadowMinZ;
  8875. /**
  8876. * Gets the shadow projection clipping minimum z value.
  8877. */
  8878. get shadowMinZ(): number;
  8879. /**
  8880. * Sets the shadow projection clipping minimum z value.
  8881. */
  8882. set shadowMinZ(value: number);
  8883. private _shadowMaxZ;
  8884. /**
  8885. * Sets the shadow projection clipping maximum z value.
  8886. */
  8887. get shadowMaxZ(): number;
  8888. /**
  8889. * Gets the shadow projection clipping maximum z value.
  8890. */
  8891. set shadowMaxZ(value: number);
  8892. /**
  8893. * Callback defining a custom Projection Matrix Builder.
  8894. * This can be used to override the default projection matrix computation.
  8895. */
  8896. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8897. /**
  8898. * The transformed position. Position of the light in world space taking parenting in account.
  8899. */
  8900. transformedPosition: Vector3;
  8901. /**
  8902. * The transformed direction. Direction of the light in world space taking parenting in account.
  8903. */
  8904. transformedDirection: Vector3;
  8905. private _needProjectionMatrixCompute;
  8906. /**
  8907. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8908. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8909. */
  8910. computeTransformedInformation(): boolean;
  8911. /**
  8912. * Return the depth scale used for the shadow map.
  8913. * @returns the depth scale.
  8914. */
  8915. getDepthScale(): number;
  8916. /**
  8917. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8918. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8919. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8920. */
  8921. getShadowDirection(faceIndex?: number): Vector3;
  8922. /**
  8923. * Returns the ShadowLight absolute position in the World.
  8924. * @returns the position vector in world space
  8925. */
  8926. getAbsolutePosition(): Vector3;
  8927. /**
  8928. * Sets the ShadowLight direction toward the passed target.
  8929. * @param target The point to target in local space
  8930. * @returns the updated ShadowLight direction
  8931. */
  8932. setDirectionToTarget(target: Vector3): Vector3;
  8933. /**
  8934. * Returns the light rotation in euler definition.
  8935. * @returns the x y z rotation in local space.
  8936. */
  8937. getRotation(): Vector3;
  8938. /**
  8939. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8940. * @returns true if a cube texture needs to be use
  8941. */
  8942. needCube(): boolean;
  8943. /**
  8944. * Detects if the projection matrix requires to be recomputed this frame.
  8945. * @returns true if it requires to be recomputed otherwise, false.
  8946. */
  8947. needProjectionMatrixCompute(): boolean;
  8948. /**
  8949. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8950. */
  8951. forceProjectionMatrixCompute(): void;
  8952. /** @hidden */
  8953. _initCache(): void;
  8954. /** @hidden */
  8955. _isSynchronized(): boolean;
  8956. /**
  8957. * Computes the world matrix of the node
  8958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8959. * @returns the world matrix
  8960. */
  8961. computeWorldMatrix(force?: boolean): Matrix;
  8962. /**
  8963. * Gets the minZ used for shadow according to both the scene and the light.
  8964. * @param activeCamera The camera we are returning the min for
  8965. * @returns the depth min z
  8966. */
  8967. getDepthMinZ(activeCamera: Camera): number;
  8968. /**
  8969. * Gets the maxZ used for shadow according to both the scene and the light.
  8970. * @param activeCamera The camera we are returning the max for
  8971. * @returns the depth max z
  8972. */
  8973. getDepthMaxZ(activeCamera: Camera): number;
  8974. /**
  8975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8976. * @param matrix The materix to updated with the projection information
  8977. * @param viewMatrix The transform matrix of the light
  8978. * @param renderList The list of mesh to render in the map
  8979. * @returns The current light
  8980. */
  8981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8987. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8988. */
  8989. export class EffectFallbacks implements IEffectFallbacks {
  8990. private _defines;
  8991. private _currentRank;
  8992. private _maxRank;
  8993. private _mesh;
  8994. /**
  8995. * Removes the fallback from the bound mesh.
  8996. */
  8997. unBindMesh(): void;
  8998. /**
  8999. * Adds a fallback on the specified property.
  9000. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9001. * @param define The name of the define in the shader
  9002. */
  9003. addFallback(rank: number, define: string): void;
  9004. /**
  9005. * Sets the mesh to use CPU skinning when needing to fallback.
  9006. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9007. * @param mesh The mesh to use the fallbacks.
  9008. */
  9009. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9010. /**
  9011. * Checks to see if more fallbacks are still availible.
  9012. */
  9013. get hasMoreFallbacks(): boolean;
  9014. /**
  9015. * Removes the defines that should be removed when falling back.
  9016. * @param currentDefines defines the current define statements for the shader.
  9017. * @param effect defines the current effect we try to compile
  9018. * @returns The resulting defines with defines of the current rank removed.
  9019. */
  9020. reduce(currentDefines: string, effect: Effect): string;
  9021. }
  9022. }
  9023. declare module BABYLON {
  9024. /**
  9025. * "Static Class" containing the most commonly used helper while dealing with material for
  9026. * rendering purpose.
  9027. *
  9028. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9029. *
  9030. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9031. */
  9032. export class MaterialHelper {
  9033. /**
  9034. * Bind the current view position to an effect.
  9035. * @param effect The effect to be bound
  9036. * @param scene The scene the eyes position is used from
  9037. */
  9038. static BindEyePosition(effect: Effect, scene: Scene): void;
  9039. /**
  9040. * Helps preparing the defines values about the UVs in used in the effect.
  9041. * UVs are shared as much as we can accross channels in the shaders.
  9042. * @param texture The texture we are preparing the UVs for
  9043. * @param defines The defines to update
  9044. * @param key The channel key "diffuse", "specular"... used in the shader
  9045. */
  9046. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9047. /**
  9048. * Binds a texture matrix value to its corrsponding uniform
  9049. * @param texture The texture to bind the matrix for
  9050. * @param uniformBuffer The uniform buffer receivin the data
  9051. * @param key The channel key "diffuse", "specular"... used in the shader
  9052. */
  9053. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9054. /**
  9055. * Gets the current status of the fog (should it be enabled?)
  9056. * @param mesh defines the mesh to evaluate for fog support
  9057. * @param scene defines the hosting scene
  9058. * @returns true if fog must be enabled
  9059. */
  9060. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9061. /**
  9062. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9063. * @param mesh defines the current mesh
  9064. * @param scene defines the current scene
  9065. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9066. * @param pointsCloud defines if point cloud rendering has to be turned on
  9067. * @param fogEnabled defines if fog has to be turned on
  9068. * @param alphaTest defines if alpha testing has to be turned on
  9069. * @param defines defines the current list of defines
  9070. */
  9071. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9072. /**
  9073. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9074. * @param scene defines the current scene
  9075. * @param engine defines the current engine
  9076. * @param defines specifies the list of active defines
  9077. * @param useInstances defines if instances have to be turned on
  9078. * @param useClipPlane defines if clip plane have to be turned on
  9079. */
  9080. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9081. /**
  9082. * Prepares the defines for bones
  9083. * @param mesh The mesh containing the geometry data we will draw
  9084. * @param defines The defines to update
  9085. */
  9086. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9087. /**
  9088. * Prepares the defines for morph targets
  9089. * @param mesh The mesh containing the geometry data we will draw
  9090. * @param defines The defines to update
  9091. */
  9092. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9093. /**
  9094. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9095. * @param mesh The mesh containing the geometry data we will draw
  9096. * @param defines The defines to update
  9097. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9098. * @param useBones Precise whether bones should be used or not (override mesh info)
  9099. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9100. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9101. * @returns false if defines are considered not dirty and have not been checked
  9102. */
  9103. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9104. /**
  9105. * Prepares the defines related to multiview
  9106. * @param scene The scene we are intending to draw
  9107. * @param defines The defines to update
  9108. */
  9109. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9110. /**
  9111. * Prepares the defines related to the light information passed in parameter
  9112. * @param scene The scene we are intending to draw
  9113. * @param mesh The mesh the effect is compiling for
  9114. * @param light The light the effect is compiling for
  9115. * @param lightIndex The index of the light
  9116. * @param defines The defines to update
  9117. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9118. * @param state Defines the current state regarding what is needed (normals, etc...)
  9119. */
  9120. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9121. needNormals: boolean;
  9122. needRebuild: boolean;
  9123. shadowEnabled: boolean;
  9124. specularEnabled: boolean;
  9125. lightmapMode: boolean;
  9126. }): void;
  9127. /**
  9128. * Prepares the defines related to the light information passed in parameter
  9129. * @param scene The scene we are intending to draw
  9130. * @param mesh The mesh the effect is compiling for
  9131. * @param defines The defines to update
  9132. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9133. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9134. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9135. * @returns true if normals will be required for the rest of the effect
  9136. */
  9137. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9138. /**
  9139. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9140. * @param lightIndex defines the light index
  9141. * @param uniformsList The uniform list
  9142. * @param samplersList The sampler list
  9143. * @param projectedLightTexture defines if projected texture must be used
  9144. * @param uniformBuffersList defines an optional list of uniform buffers
  9145. */
  9146. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect
  9149. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9150. * @param samplersList The sampler list
  9151. * @param defines The defines helping in the list generation
  9152. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9153. */
  9154. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9155. /**
  9156. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9157. * @param defines The defines to update while falling back
  9158. * @param fallbacks The authorized effect fallbacks
  9159. * @param maxSimultaneousLights The maximum number of lights allowed
  9160. * @param rank the current rank of the Effect
  9161. * @returns The newly affected rank
  9162. */
  9163. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9164. private static _TmpMorphInfluencers;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param influencers The number of influencers
  9170. */
  9171. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9172. /**
  9173. * Prepares the list of attributes required for morph targets according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the morph targets attributes for
  9176. * @param defines The current Defines of the effect
  9177. */
  9178. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9179. /**
  9180. * Prepares the list of attributes required for bones according to the effect defines.
  9181. * @param attribs The current list of supported attribs
  9182. * @param mesh The mesh to prepare the bones attributes for
  9183. * @param defines The current Defines of the effect
  9184. * @param fallbacks The current efffect fallback strategy
  9185. */
  9186. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9187. /**
  9188. * Check and prepare the list of attributes required for instances according to the effect defines.
  9189. * @param attribs The current list of supported attribs
  9190. * @param defines The current MaterialDefines of the effect
  9191. */
  9192. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9193. /**
  9194. * Add the list of attributes required for instances to the attribs array.
  9195. * @param attribs The current list of supported attribs
  9196. */
  9197. static PushAttributesForInstances(attribs: string[]): void;
  9198. /**
  9199. * Binds the light information to the effect.
  9200. * @param light The light containing the generator
  9201. * @param effect The effect we are binding the data to
  9202. * @param lightIndex The light index in the effect used to render
  9203. */
  9204. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9205. /**
  9206. * Binds the lights information from the scene to the effect for the given mesh.
  9207. * @param light Light to bind
  9208. * @param lightIndex Light index
  9209. * @param scene The scene where the light belongs to
  9210. * @param effect The effect we are binding the data to
  9211. * @param useSpecular Defines if specular is supported
  9212. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9213. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9214. */
  9215. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9216. /**
  9217. * Binds the lights information from the scene to the effect for the given mesh.
  9218. * @param scene The scene the lights belongs to
  9219. * @param mesh The mesh we are binding the information to render
  9220. * @param effect The effect we are binding the data to
  9221. * @param defines The generated defines for the effect
  9222. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9223. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9224. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9225. */
  9226. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9227. private static _tempFogColor;
  9228. /**
  9229. * Binds the fog information from the scene to the effect for the given mesh.
  9230. * @param scene The scene the lights belongs to
  9231. * @param mesh The mesh we are binding the information to render
  9232. * @param effect The effect we are binding the data to
  9233. * @param linearSpace Defines if the fog effect is applied in linear space
  9234. */
  9235. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9236. /**
  9237. * Binds the bones information from the mesh to the effect.
  9238. * @param mesh The mesh we are binding the information to render
  9239. * @param effect The effect we are binding the data to
  9240. */
  9241. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9242. /**
  9243. * Binds the morph targets information from the mesh to the effect.
  9244. * @param abstractMesh The mesh we are binding the information to render
  9245. * @param effect The effect we are binding the data to
  9246. */
  9247. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9248. /**
  9249. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9250. * @param defines The generated defines used in the effect
  9251. * @param effect The effect we are binding the data to
  9252. * @param scene The scene we are willing to render with logarithmic scale for
  9253. */
  9254. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9255. /**
  9256. * Binds the clip plane information from the scene to the effect.
  9257. * @param scene The scene the clip plane information are extracted from
  9258. * @param effect The effect we are binding the data to
  9259. */
  9260. static BindClipPlane(effect: Effect, scene: Scene): void;
  9261. }
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var packingFunctions: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var shadowMapPixelShader: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var bonesDeclaration: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var morphTargetsVertexGlobalDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var morphTargetsVertexDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var instancesDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var helperFunctions: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var morphTargetsVertex: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var instancesVertex: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var bonesVertex: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var shadowMapVertexShader: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var depthBoxBlurPixelShader: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /**
  9349. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9350. */
  9351. export interface ICustomShaderOptions {
  9352. /**
  9353. * Gets or sets the custom shader name to use
  9354. */
  9355. shaderName: string;
  9356. /**
  9357. * The list of attribute names used in the shader
  9358. */
  9359. attributes?: string[];
  9360. /**
  9361. * The list of unifrom names used in the shader
  9362. */
  9363. uniforms?: string[];
  9364. /**
  9365. * The list of sampler names used in the shader
  9366. */
  9367. samplers?: string[];
  9368. /**
  9369. * The list of defines used in the shader
  9370. */
  9371. defines?: string[];
  9372. }
  9373. /**
  9374. * Interface to implement to create a shadow generator compatible with BJS.
  9375. */
  9376. export interface IShadowGenerator {
  9377. /**
  9378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9379. * @returns The render target texture if present otherwise, null
  9380. */
  9381. getShadowMap(): Nullable<RenderTargetTexture>;
  9382. /**
  9383. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9384. * @returns The render target texture if the shadow map is present otherwise, null
  9385. */
  9386. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9387. /**
  9388. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9389. * @param subMesh The submesh we want to render in the shadow map
  9390. * @param useInstances Defines wether will draw in the map using instances
  9391. * @returns true if ready otherwise, false
  9392. */
  9393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9394. /**
  9395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9396. * @param defines Defines of the material we want to update
  9397. * @param lightIndex Index of the light in the enabled light list of the material
  9398. */
  9399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9400. /**
  9401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9402. * defined in the generator but impacting the effect).
  9403. * It implies the unifroms available on the materials are the standard BJS ones.
  9404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9405. * @param effect The effect we are binfing the information for
  9406. */
  9407. bindShadowLight(lightIndex: string, effect: Effect): void;
  9408. /**
  9409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9410. * (eq to shadow prjection matrix * light transform matrix)
  9411. * @returns The transform matrix used to create the shadow map
  9412. */
  9413. getTransformMatrix(): Matrix;
  9414. /**
  9415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9416. * Cube and 2D textures for instance.
  9417. */
  9418. recreateShadowMap(): void;
  9419. /**
  9420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9421. * @param onCompiled Callback triggered at the and of the effects compilation
  9422. * @param options Sets of optional options forcing the compilation with different modes
  9423. */
  9424. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9425. useInstances: boolean;
  9426. }>): void;
  9427. /**
  9428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9429. * @param options Sets of optional options forcing the compilation with different modes
  9430. * @returns A promise that resolves when the compilation completes
  9431. */
  9432. forceCompilationAsync(options?: Partial<{
  9433. useInstances: boolean;
  9434. }>): Promise<void>;
  9435. /**
  9436. * Serializes the shadow generator setup to a json object.
  9437. * @returns The serialized JSON object
  9438. */
  9439. serialize(): any;
  9440. /**
  9441. * Disposes the Shadow map and related Textures and effects.
  9442. */
  9443. dispose(): void;
  9444. }
  9445. /**
  9446. * Default implementation IShadowGenerator.
  9447. * This is the main object responsible of generating shadows in the framework.
  9448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9449. */
  9450. export class ShadowGenerator implements IShadowGenerator {
  9451. /**
  9452. * Shadow generator mode None: no filtering applied.
  9453. */
  9454. static readonly FILTER_NONE: number;
  9455. /**
  9456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9458. */
  9459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9460. /**
  9461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9463. */
  9464. static readonly FILTER_POISSONSAMPLING: number;
  9465. /**
  9466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9478. * edge artifacts on steep falloff.
  9479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9480. */
  9481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9482. /**
  9483. * Shadow generator mode PCF: Percentage Closer Filtering
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9486. */
  9487. static readonly FILTER_PCF: number;
  9488. /**
  9489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9491. * Contact Hardening
  9492. */
  9493. static readonly FILTER_PCSS: number;
  9494. /**
  9495. * Reserved for PCF and PCSS
  9496. * Highest Quality.
  9497. *
  9498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9499. *
  9500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9501. */
  9502. static readonly QUALITY_HIGH: number;
  9503. /**
  9504. * Reserved for PCF and PCSS
  9505. * Good tradeoff for quality/perf cross devices
  9506. *
  9507. * Execute PCF on a 3*3 kernel.
  9508. *
  9509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9510. */
  9511. static readonly QUALITY_MEDIUM: number;
  9512. /**
  9513. * Reserved for PCF and PCSS
  9514. * The lowest quality but the fastest.
  9515. *
  9516. * Execute PCF on a 1*1 kernel.
  9517. *
  9518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9519. */
  9520. static readonly QUALITY_LOW: number;
  9521. /** Gets or sets the custom shader name to use */
  9522. customShaderOptions: ICustomShaderOptions;
  9523. /**
  9524. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9525. */
  9526. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9527. /**
  9528. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9529. */
  9530. onAfterShadowMapRenderObservable: Observable<Effect>;
  9531. /**
  9532. * Observable triggered before a mesh is rendered in the shadow map.
  9533. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9534. */
  9535. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9536. /**
  9537. * Observable triggered after a mesh is rendered in the shadow map.
  9538. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9539. */
  9540. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9541. private _bias;
  9542. /**
  9543. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9544. */
  9545. get bias(): number;
  9546. /**
  9547. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9548. */
  9549. set bias(bias: number);
  9550. private _normalBias;
  9551. /**
  9552. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9553. */
  9554. get normalBias(): number;
  9555. /**
  9556. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9557. */
  9558. set normalBias(normalBias: number);
  9559. private _blurBoxOffset;
  9560. /**
  9561. * Gets the blur box offset: offset applied during the blur pass.
  9562. * Only useful if useKernelBlur = false
  9563. */
  9564. get blurBoxOffset(): number;
  9565. /**
  9566. * Sets the blur box offset: offset applied during the blur pass.
  9567. * Only useful if useKernelBlur = false
  9568. */
  9569. set blurBoxOffset(value: number);
  9570. private _blurScale;
  9571. /**
  9572. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9573. * 2 means half of the size.
  9574. */
  9575. get blurScale(): number;
  9576. /**
  9577. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9578. * 2 means half of the size.
  9579. */
  9580. set blurScale(value: number);
  9581. private _blurKernel;
  9582. /**
  9583. * Gets the blur kernel: kernel size of the blur pass.
  9584. * Only useful if useKernelBlur = true
  9585. */
  9586. get blurKernel(): number;
  9587. /**
  9588. * Sets the blur kernel: kernel size of the blur pass.
  9589. * Only useful if useKernelBlur = true
  9590. */
  9591. set blurKernel(value: number);
  9592. private _useKernelBlur;
  9593. /**
  9594. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9596. */
  9597. get useKernelBlur(): boolean;
  9598. /**
  9599. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9600. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9601. */
  9602. set useKernelBlur(value: boolean);
  9603. private _depthScale;
  9604. /**
  9605. * Gets the depth scale used in ESM mode.
  9606. */
  9607. get depthScale(): number;
  9608. /**
  9609. * Sets the depth scale used in ESM mode.
  9610. * This can override the scale stored on the light.
  9611. */
  9612. set depthScale(value: number);
  9613. private _filter;
  9614. /**
  9615. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9616. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9617. */
  9618. get filter(): number;
  9619. /**
  9620. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9621. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9622. */
  9623. set filter(value: number);
  9624. /**
  9625. * Gets if the current filter is set to Poisson Sampling.
  9626. */
  9627. get usePoissonSampling(): boolean;
  9628. /**
  9629. * Sets the current filter to Poisson Sampling.
  9630. */
  9631. set usePoissonSampling(value: boolean);
  9632. /**
  9633. * Gets if the current filter is set to ESM.
  9634. */
  9635. get useExponentialShadowMap(): boolean;
  9636. /**
  9637. * Sets the current filter is to ESM.
  9638. */
  9639. set useExponentialShadowMap(value: boolean);
  9640. /**
  9641. * Gets if the current filter is set to filtered ESM.
  9642. */
  9643. get useBlurExponentialShadowMap(): boolean;
  9644. /**
  9645. * Gets if the current filter is set to filtered ESM.
  9646. */
  9647. set useBlurExponentialShadowMap(value: boolean);
  9648. /**
  9649. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9650. * exponential to prevent steep falloff artifacts).
  9651. */
  9652. get useCloseExponentialShadowMap(): boolean;
  9653. /**
  9654. * Sets the current filter to "close ESM" (using the inverse of the
  9655. * exponential to prevent steep falloff artifacts).
  9656. */
  9657. set useCloseExponentialShadowMap(value: boolean);
  9658. /**
  9659. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9660. * exponential to prevent steep falloff artifacts).
  9661. */
  9662. get useBlurCloseExponentialShadowMap(): boolean;
  9663. /**
  9664. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9665. * exponential to prevent steep falloff artifacts).
  9666. */
  9667. set useBlurCloseExponentialShadowMap(value: boolean);
  9668. /**
  9669. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9670. */
  9671. get usePercentageCloserFiltering(): boolean;
  9672. /**
  9673. * Sets the current filter to "PCF" (percentage closer filtering).
  9674. */
  9675. set usePercentageCloserFiltering(value: boolean);
  9676. private _filteringQuality;
  9677. /**
  9678. * Gets the PCF or PCSS Quality.
  9679. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9680. */
  9681. get filteringQuality(): number;
  9682. /**
  9683. * Sets the PCF or PCSS Quality.
  9684. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9685. */
  9686. set filteringQuality(filteringQuality: number);
  9687. /**
  9688. * Gets if the current filter is set to "PCSS" (contact hardening).
  9689. */
  9690. get useContactHardeningShadow(): boolean;
  9691. /**
  9692. * Sets the current filter to "PCSS" (contact hardening).
  9693. */
  9694. set useContactHardeningShadow(value: boolean);
  9695. private _contactHardeningLightSizeUVRatio;
  9696. /**
  9697. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9698. * Using a ratio helps keeping shape stability independently of the map size.
  9699. *
  9700. * It does not account for the light projection as it was having too much
  9701. * instability during the light setup or during light position changes.
  9702. *
  9703. * Only valid if useContactHardeningShadow is true.
  9704. */
  9705. get contactHardeningLightSizeUVRatio(): number;
  9706. /**
  9707. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9708. * Using a ratio helps keeping shape stability independently of the map size.
  9709. *
  9710. * It does not account for the light projection as it was having too much
  9711. * instability during the light setup or during light position changes.
  9712. *
  9713. * Only valid if useContactHardeningShadow is true.
  9714. */
  9715. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9716. private _darkness;
  9717. /** Gets or sets the actual darkness of a shadow */
  9718. get darkness(): number;
  9719. set darkness(value: number);
  9720. /**
  9721. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9722. * 0 means strongest and 1 would means no shadow.
  9723. * @returns the darkness.
  9724. */
  9725. getDarkness(): number;
  9726. /**
  9727. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9728. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9729. * @returns the shadow generator allowing fluent coding.
  9730. */
  9731. setDarkness(darkness: number): ShadowGenerator;
  9732. private _transparencyShadow;
  9733. /** Gets or sets the ability to have transparent shadow */
  9734. get transparencyShadow(): boolean;
  9735. set transparencyShadow(value: boolean);
  9736. /**
  9737. * Sets the ability to have transparent shadow (boolean).
  9738. * @param transparent True if transparent else False
  9739. * @returns the shadow generator allowing fluent coding
  9740. */
  9741. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9742. private _shadowMap;
  9743. private _shadowMap2;
  9744. /**
  9745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9746. * @returns The render target texture if present otherwise, null
  9747. */
  9748. getShadowMap(): Nullable<RenderTargetTexture>;
  9749. /**
  9750. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9751. * @returns The render target texture if the shadow map is present otherwise, null
  9752. */
  9753. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9754. /**
  9755. * Gets the class name of that object
  9756. * @returns "ShadowGenerator"
  9757. */
  9758. getClassName(): string;
  9759. /**
  9760. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9761. * @param mesh Mesh to add
  9762. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9763. * @returns the Shadow Generator itself
  9764. */
  9765. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9766. /**
  9767. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9768. * @param mesh Mesh to remove
  9769. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9770. * @returns the Shadow Generator itself
  9771. */
  9772. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9773. /**
  9774. * Controls the extent to which the shadows fade out at the edge of the frustum
  9775. * Used only by directionals and spots
  9776. */
  9777. frustumEdgeFalloff: number;
  9778. private _light;
  9779. /**
  9780. * Returns the associated light object.
  9781. * @returns the light generating the shadow
  9782. */
  9783. getLight(): IShadowLight;
  9784. /**
  9785. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9786. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9787. * It might on the other hand introduce peter panning.
  9788. */
  9789. forceBackFacesOnly: boolean;
  9790. private _scene;
  9791. private _lightDirection;
  9792. private _effect;
  9793. private _viewMatrix;
  9794. private _projectionMatrix;
  9795. private _transformMatrix;
  9796. private _cachedPosition;
  9797. private _cachedDirection;
  9798. private _cachedDefines;
  9799. private _currentRenderID;
  9800. private _boxBlurPostprocess;
  9801. private _kernelBlurXPostprocess;
  9802. private _kernelBlurYPostprocess;
  9803. private _blurPostProcesses;
  9804. private _mapSize;
  9805. private _currentFaceIndex;
  9806. private _currentFaceIndexCache;
  9807. private _textureType;
  9808. private _defaultTextureMatrix;
  9809. private _storedUniqueId;
  9810. /** @hidden */
  9811. static _SceneComponentInitialization: (scene: Scene) => void;
  9812. /**
  9813. * Creates a ShadowGenerator object.
  9814. * A ShadowGenerator is the required tool to use the shadows.
  9815. * Each light casting shadows needs to use its own ShadowGenerator.
  9816. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9817. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9818. * @param light The light object generating the shadows.
  9819. * @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.
  9820. */
  9821. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9822. private _initializeGenerator;
  9823. private _initializeShadowMap;
  9824. private _initializeBlurRTTAndPostProcesses;
  9825. private _renderForShadowMap;
  9826. private _renderSubMeshForShadowMap;
  9827. private _applyFilterValues;
  9828. /**
  9829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9830. * @param onCompiled Callback triggered at the and of the effects compilation
  9831. * @param options Sets of optional options forcing the compilation with different modes
  9832. */
  9833. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9834. useInstances: boolean;
  9835. }>): void;
  9836. /**
  9837. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9838. * @param options Sets of optional options forcing the compilation with different modes
  9839. * @returns A promise that resolves when the compilation completes
  9840. */
  9841. forceCompilationAsync(options?: Partial<{
  9842. useInstances: boolean;
  9843. }>): Promise<void>;
  9844. /**
  9845. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9846. * @param subMesh The submesh we want to render in the shadow map
  9847. * @param useInstances Defines wether will draw in the map using instances
  9848. * @returns true if ready otherwise, false
  9849. */
  9850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9851. /**
  9852. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9853. * @param defines Defines of the material we want to update
  9854. * @param lightIndex Index of the light in the enabled light list of the material
  9855. */
  9856. prepareDefines(defines: any, lightIndex: number): void;
  9857. /**
  9858. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9859. * defined in the generator but impacting the effect).
  9860. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9861. * @param effect The effect we are binfing the information for
  9862. */
  9863. bindShadowLight(lightIndex: string, effect: Effect): void;
  9864. /**
  9865. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9866. * (eq to shadow prjection matrix * light transform matrix)
  9867. * @returns The transform matrix used to create the shadow map
  9868. */
  9869. getTransformMatrix(): Matrix;
  9870. /**
  9871. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9872. * Cube and 2D textures for instance.
  9873. */
  9874. recreateShadowMap(): void;
  9875. private _disposeBlurPostProcesses;
  9876. private _disposeRTTandPostProcesses;
  9877. /**
  9878. * Disposes the ShadowGenerator.
  9879. * Returns nothing.
  9880. */
  9881. dispose(): void;
  9882. /**
  9883. * Serializes the shadow generator setup to a json object.
  9884. * @returns The serialized JSON object
  9885. */
  9886. serialize(): any;
  9887. /**
  9888. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9889. * @param parsedShadowGenerator The JSON object to parse
  9890. * @param scene The scene to create the shadow map for
  9891. * @returns The parsed shadow generator
  9892. */
  9893. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9894. }
  9895. }
  9896. declare module BABYLON {
  9897. /**
  9898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9900. * 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.
  9901. */
  9902. export abstract class Light extends Node {
  9903. /**
  9904. * Falloff Default: light is falling off following the material specification:
  9905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9906. */
  9907. static readonly FALLOFF_DEFAULT: number;
  9908. /**
  9909. * Falloff Physical: light is falling off following the inverse squared distance law.
  9910. */
  9911. static readonly FALLOFF_PHYSICAL: number;
  9912. /**
  9913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9914. * to enhance interoperability with other engines.
  9915. */
  9916. static readonly FALLOFF_GLTF: number;
  9917. /**
  9918. * Falloff Standard: light is falling off like in the standard material
  9919. * to enhance interoperability with other materials.
  9920. */
  9921. static readonly FALLOFF_STANDARD: number;
  9922. /**
  9923. * If every light affecting the material is in this lightmapMode,
  9924. * material.lightmapTexture adds or multiplies
  9925. * (depends on material.useLightmapAsShadowmap)
  9926. * after every other light calculations.
  9927. */
  9928. static readonly LIGHTMAP_DEFAULT: number;
  9929. /**
  9930. * material.lightmapTexture as only diffuse lighting from this light
  9931. * adds only specular lighting from this light
  9932. * adds dynamic shadows
  9933. */
  9934. static readonly LIGHTMAP_SPECULAR: number;
  9935. /**
  9936. * material.lightmapTexture as only lighting
  9937. * no light calculation from this light
  9938. * only adds dynamic shadows from this light
  9939. */
  9940. static readonly LIGHTMAP_SHADOWSONLY: number;
  9941. /**
  9942. * Each light type uses the default quantity according to its type:
  9943. * point/spot lights use luminous intensity
  9944. * directional lights use illuminance
  9945. */
  9946. static readonly INTENSITYMODE_AUTOMATIC: number;
  9947. /**
  9948. * lumen (lm)
  9949. */
  9950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9951. /**
  9952. * candela (lm/sr)
  9953. */
  9954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9955. /**
  9956. * lux (lm/m^2)
  9957. */
  9958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9959. /**
  9960. * nit (cd/m^2)
  9961. */
  9962. static readonly INTENSITYMODE_LUMINANCE: number;
  9963. /**
  9964. * Light type const id of the point light.
  9965. */
  9966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9967. /**
  9968. * Light type const id of the directional light.
  9969. */
  9970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9971. /**
  9972. * Light type const id of the spot light.
  9973. */
  9974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9975. /**
  9976. * Light type const id of the hemispheric light.
  9977. */
  9978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9979. /**
  9980. * Diffuse gives the basic color to an object.
  9981. */
  9982. diffuse: Color3;
  9983. /**
  9984. * Specular produces a highlight color on an object.
  9985. * Note: This is note affecting PBR materials.
  9986. */
  9987. specular: Color3;
  9988. /**
  9989. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9990. * falling off base on range or angle.
  9991. * This can be set to any values in Light.FALLOFF_x.
  9992. *
  9993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9994. * other types of materials.
  9995. */
  9996. falloffType: number;
  9997. /**
  9998. * Strength of the light.
  9999. * Note: By default it is define in the framework own unit.
  10000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10001. */
  10002. intensity: number;
  10003. private _range;
  10004. protected _inverseSquaredRange: number;
  10005. /**
  10006. * Defines how far from the source the light is impacting in scene units.
  10007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10008. */
  10009. get range(): number;
  10010. /**
  10011. * Defines how far from the source the light is impacting in scene units.
  10012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10013. */
  10014. set range(value: number);
  10015. /**
  10016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10017. * of light.
  10018. */
  10019. private _photometricScale;
  10020. private _intensityMode;
  10021. /**
  10022. * Gets the photometric scale used to interpret the intensity.
  10023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10024. */
  10025. get intensityMode(): number;
  10026. /**
  10027. * Sets the photometric scale used to interpret the intensity.
  10028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10029. */
  10030. set intensityMode(value: number);
  10031. private _radius;
  10032. /**
  10033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10034. */
  10035. get radius(): number;
  10036. /**
  10037. * sets the light radius used by PBR Materials to simulate soft area lights.
  10038. */
  10039. set radius(value: number);
  10040. private _renderPriority;
  10041. /**
  10042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10043. * exceeding the number allowed of the materials.
  10044. */
  10045. renderPriority: number;
  10046. private _shadowEnabled;
  10047. /**
  10048. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10049. * the current shadow generator.
  10050. */
  10051. get shadowEnabled(): boolean;
  10052. /**
  10053. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10054. * the current shadow generator.
  10055. */
  10056. set shadowEnabled(value: boolean);
  10057. private _includedOnlyMeshes;
  10058. /**
  10059. * Gets the only meshes impacted by this light.
  10060. */
  10061. get includedOnlyMeshes(): AbstractMesh[];
  10062. /**
  10063. * Sets the only meshes impacted by this light.
  10064. */
  10065. set includedOnlyMeshes(value: AbstractMesh[]);
  10066. private _excludedMeshes;
  10067. /**
  10068. * Gets the meshes not impacted by this light.
  10069. */
  10070. get excludedMeshes(): AbstractMesh[];
  10071. /**
  10072. * Sets the meshes not impacted by this light.
  10073. */
  10074. set excludedMeshes(value: AbstractMesh[]);
  10075. private _excludeWithLayerMask;
  10076. /**
  10077. * Gets the layer id use to find what meshes are not impacted by the light.
  10078. * Inactive if 0
  10079. */
  10080. get excludeWithLayerMask(): number;
  10081. /**
  10082. * Sets the layer id use to find what meshes are not impacted by the light.
  10083. * Inactive if 0
  10084. */
  10085. set excludeWithLayerMask(value: number);
  10086. private _includeOnlyWithLayerMask;
  10087. /**
  10088. * Gets the layer id use to find what meshes are impacted by the light.
  10089. * Inactive if 0
  10090. */
  10091. get includeOnlyWithLayerMask(): number;
  10092. /**
  10093. * Sets the layer id use to find what meshes are impacted by the light.
  10094. * Inactive if 0
  10095. */
  10096. set includeOnlyWithLayerMask(value: number);
  10097. private _lightmapMode;
  10098. /**
  10099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10100. */
  10101. get lightmapMode(): number;
  10102. /**
  10103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10104. */
  10105. set lightmapMode(value: number);
  10106. /**
  10107. * Shadow generator associted to the light.
  10108. * @hidden Internal use only.
  10109. */
  10110. _shadowGenerator: Nullable<IShadowGenerator>;
  10111. /**
  10112. * @hidden Internal use only.
  10113. */
  10114. _excludedMeshesIds: string[];
  10115. /**
  10116. * @hidden Internal use only.
  10117. */
  10118. _includedOnlyMeshesIds: string[];
  10119. /**
  10120. * The current light unifom buffer.
  10121. * @hidden Internal use only.
  10122. */
  10123. _uniformBuffer: UniformBuffer;
  10124. /** @hidden */
  10125. _renderId: number;
  10126. /**
  10127. * Creates a Light object in the scene.
  10128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10129. * @param name The firendly name of the light
  10130. * @param scene The scene the light belongs too
  10131. */
  10132. constructor(name: string, scene: Scene);
  10133. protected abstract _buildUniformLayout(): void;
  10134. /**
  10135. * Sets the passed Effect "effect" with the Light information.
  10136. * @param effect The effect to update
  10137. * @param lightIndex The index of the light in the effect to update
  10138. * @returns The light
  10139. */
  10140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10141. /**
  10142. * Sets the passed Effect "effect" with the Light textures.
  10143. * @param effect The effect to update
  10144. * @param lightIndex The index of the light in the effect to update
  10145. * @returns The light
  10146. */
  10147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10148. /**
  10149. * Binds the lights information from the scene to the effect for the given mesh.
  10150. * @param lightIndex Light index
  10151. * @param scene The scene where the light belongs to
  10152. * @param effect The effect we are binding the data to
  10153. * @param useSpecular Defines if specular is supported
  10154. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10156. */
  10157. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10158. /**
  10159. * Sets the passed Effect "effect" with the Light information.
  10160. * @param effect The effect to update
  10161. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10162. * @returns The light
  10163. */
  10164. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10165. /**
  10166. * Returns the string "Light".
  10167. * @returns the class name
  10168. */
  10169. getClassName(): string;
  10170. /** @hidden */
  10171. readonly _isLight: boolean;
  10172. /**
  10173. * Converts the light information to a readable string for debug purpose.
  10174. * @param fullDetails Supports for multiple levels of logging within scene loading
  10175. * @returns the human readable light info
  10176. */
  10177. toString(fullDetails?: boolean): string;
  10178. /** @hidden */
  10179. protected _syncParentEnabledState(): void;
  10180. /**
  10181. * Set the enabled state of this node.
  10182. * @param value - the new enabled state
  10183. */
  10184. setEnabled(value: boolean): void;
  10185. /**
  10186. * Returns the Light associated shadow generator if any.
  10187. * @return the associated shadow generator.
  10188. */
  10189. getShadowGenerator(): Nullable<IShadowGenerator>;
  10190. /**
  10191. * Returns a Vector3, the absolute light position in the World.
  10192. * @returns the world space position of the light
  10193. */
  10194. getAbsolutePosition(): Vector3;
  10195. /**
  10196. * Specifies if the light will affect the passed mesh.
  10197. * @param mesh The mesh to test against the light
  10198. * @return true the mesh is affected otherwise, false.
  10199. */
  10200. canAffectMesh(mesh: AbstractMesh): boolean;
  10201. /**
  10202. * Sort function to order lights for rendering.
  10203. * @param a First Light object to compare to second.
  10204. * @param b Second Light object to compare first.
  10205. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10206. */
  10207. static CompareLightsPriority(a: Light, b: Light): number;
  10208. /**
  10209. * Releases resources associated with this node.
  10210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10212. */
  10213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10214. /**
  10215. * Returns the light type ID (integer).
  10216. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10217. */
  10218. getTypeID(): number;
  10219. /**
  10220. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10221. * @returns the scaled intensity in intensity mode unit
  10222. */
  10223. getScaledIntensity(): number;
  10224. /**
  10225. * Returns a new Light object, named "name", from the current one.
  10226. * @param name The name of the cloned light
  10227. * @returns the new created light
  10228. */
  10229. clone(name: string): Nullable<Light>;
  10230. /**
  10231. * Serializes the current light into a Serialization object.
  10232. * @returns the serialized object.
  10233. */
  10234. serialize(): any;
  10235. /**
  10236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10237. * This new light is named "name" and added to the passed scene.
  10238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10239. * @param name The friendly name of the light
  10240. * @param scene The scene the new light will belong to
  10241. * @returns the constructor function
  10242. */
  10243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10244. /**
  10245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10246. * @param parsedLight The JSON representation of the light
  10247. * @param scene The scene to create the parsed light in
  10248. * @returns the created light after parsing
  10249. */
  10250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10251. private _hookArrayForExcluded;
  10252. private _hookArrayForIncludedOnly;
  10253. private _resyncMeshes;
  10254. /**
  10255. * Forces the meshes to update their light related information in their rendering used effects
  10256. * @hidden Internal Use Only
  10257. */
  10258. _markMeshesAsLightDirty(): void;
  10259. /**
  10260. * Recomputes the cached photometric scale if needed.
  10261. */
  10262. private _computePhotometricScale;
  10263. /**
  10264. * Returns the Photometric Scale according to the light type and intensity mode.
  10265. */
  10266. private _getPhotometricScale;
  10267. /**
  10268. * Reorder the light in the scene according to their defined priority.
  10269. * @hidden Internal Use Only
  10270. */
  10271. _reorderLightsInScene(): void;
  10272. /**
  10273. * Prepares the list of defines specific to the light type.
  10274. * @param defines the list of defines
  10275. * @param lightIndex defines the index of the light for the effect
  10276. */
  10277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Interface used to define Action
  10283. */
  10284. export interface IAction {
  10285. /**
  10286. * Trigger for the action
  10287. */
  10288. trigger: number;
  10289. /** Options of the trigger */
  10290. triggerOptions: any;
  10291. /**
  10292. * Gets the trigger parameters
  10293. * @returns the trigger parameters
  10294. */
  10295. getTriggerParameter(): any;
  10296. /**
  10297. * Internal only - executes current action event
  10298. * @hidden
  10299. */
  10300. _executeCurrent(evt?: ActionEvent): void;
  10301. /**
  10302. * Serialize placeholder for child classes
  10303. * @param parent of child
  10304. * @returns the serialized object
  10305. */
  10306. serialize(parent: any): any;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. _prepare(): void;
  10312. /**
  10313. * Internal only - manager for action
  10314. * @hidden
  10315. */
  10316. _actionManager: AbstractActionManager;
  10317. /**
  10318. * Adds action to chain of actions, may be a DoNothingAction
  10319. * @param action defines the next action to execute
  10320. * @returns The action passed in
  10321. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10322. */
  10323. then(action: IAction): IAction;
  10324. }
  10325. /**
  10326. * The action to be carried out following a trigger
  10327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10328. */
  10329. export class Action implements IAction {
  10330. /** the trigger, with or without parameters, for the action */
  10331. triggerOptions: any;
  10332. /**
  10333. * Trigger for the action
  10334. */
  10335. trigger: number;
  10336. /**
  10337. * Internal only - manager for action
  10338. * @hidden
  10339. */
  10340. _actionManager: ActionManager;
  10341. private _nextActiveAction;
  10342. private _child;
  10343. private _condition?;
  10344. private _triggerParameter;
  10345. /**
  10346. * An event triggered prior to action being executed.
  10347. */
  10348. onBeforeExecuteObservable: Observable<Action>;
  10349. /**
  10350. * Creates a new Action
  10351. * @param triggerOptions the trigger, with or without parameters, for the action
  10352. * @param condition an optional determinant of action
  10353. */
  10354. constructor(
  10355. /** the trigger, with or without parameters, for the action */
  10356. triggerOptions: any, condition?: Condition);
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _prepare(): void;
  10362. /**
  10363. * Gets the trigger parameters
  10364. * @returns the trigger parameters
  10365. */
  10366. getTriggerParameter(): any;
  10367. /**
  10368. * Internal only - executes current action event
  10369. * @hidden
  10370. */
  10371. _executeCurrent(evt?: ActionEvent): void;
  10372. /**
  10373. * Execute placeholder for child classes
  10374. * @param evt optional action event
  10375. */
  10376. execute(evt?: ActionEvent): void;
  10377. /**
  10378. * Skips to next active action
  10379. */
  10380. skipToNextActiveAction(): void;
  10381. /**
  10382. * Adds action to chain of actions, may be a DoNothingAction
  10383. * @param action defines the next action to execute
  10384. * @returns The action passed in
  10385. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10386. */
  10387. then(action: Action): Action;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getProperty(propertyPath: string): string;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _getEffectiveTarget(target: any, propertyPath: string): any;
  10398. /**
  10399. * Serialize placeholder for child classes
  10400. * @param parent of child
  10401. * @returns the serialized object
  10402. */
  10403. serialize(parent: any): any;
  10404. /**
  10405. * Internal only called by serialize
  10406. * @hidden
  10407. */
  10408. protected _serialize(serializedAction: any, parent?: any): any;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. static _SerializeValueAsString: (value: any) => string;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. static _GetTargetProperty: (target: Node | Scene) => {
  10419. name: string;
  10420. targetType: string;
  10421. value: string;
  10422. };
  10423. }
  10424. }
  10425. declare module BABYLON {
  10426. /**
  10427. * A Condition applied to an Action
  10428. */
  10429. export class Condition {
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. _evaluationId: number;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _currentResult: boolean;
  10445. /**
  10446. * Creates a new Condition
  10447. * @param actionManager the manager of the action the condition is applied to
  10448. */
  10449. constructor(actionManager: ActionManager);
  10450. /**
  10451. * Check if the current condition is valid
  10452. * @returns a boolean
  10453. */
  10454. isValid(): boolean;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @returns the serialized object
  10468. */
  10469. serialize(): any;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. protected _serialize(serializedCondition: any): any;
  10475. }
  10476. /**
  10477. * Defines specific conditional operators as extensions of Condition
  10478. */
  10479. export class ValueCondition extends Condition {
  10480. /** path to specify the property of the target the conditional operator uses */
  10481. propertyPath: string;
  10482. /** the value compared by the conditional operator against the current value of the property */
  10483. value: any;
  10484. /** the conditional operator, default ValueCondition.IsEqual */
  10485. operator: number;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. private static _IsEqual;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private static _IsDifferent;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private static _IsGreater;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private static _IsLesser;
  10506. /**
  10507. * returns the number for IsEqual
  10508. */
  10509. static get IsEqual(): number;
  10510. /**
  10511. * Returns the number for IsDifferent
  10512. */
  10513. static get IsDifferent(): number;
  10514. /**
  10515. * Returns the number for IsGreater
  10516. */
  10517. static get IsGreater(): number;
  10518. /**
  10519. * Returns the number for IsLesser
  10520. */
  10521. static get IsLesser(): number;
  10522. /**
  10523. * Internal only The action manager for the condition
  10524. * @hidden
  10525. */
  10526. _actionManager: ActionManager;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private _target;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private _effectiveTarget;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _property;
  10542. /**
  10543. * Creates a new ValueCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target for the action
  10546. * @param propertyPath path to specify the property of the target the conditional operator uses
  10547. * @param value the value compared by the conditional operator against the current value of the property
  10548. * @param operator the conditional operator, default ValueCondition.IsEqual
  10549. */
  10550. constructor(actionManager: ActionManager, target: any,
  10551. /** path to specify the property of the target the conditional operator uses */
  10552. propertyPath: string,
  10553. /** the value compared by the conditional operator against the current value of the property */
  10554. value: any,
  10555. /** the conditional operator, default ValueCondition.IsEqual */
  10556. operator?: number);
  10557. /**
  10558. * Compares the given value with the property value for the specified conditional operator
  10559. * @returns the result of the comparison
  10560. */
  10561. isValid(): boolean;
  10562. /**
  10563. * Serialize the ValueCondition into a JSON compatible object
  10564. * @returns serialization object
  10565. */
  10566. serialize(): any;
  10567. /**
  10568. * Gets the name of the conditional operator for the ValueCondition
  10569. * @param operator the conditional operator
  10570. * @returns the name
  10571. */
  10572. static GetOperatorName(operator: number): string;
  10573. }
  10574. /**
  10575. * Defines a predicate condition as an extension of Condition
  10576. */
  10577. export class PredicateCondition extends Condition {
  10578. /** defines the predicate function used to validate the condition */
  10579. predicate: () => boolean;
  10580. /**
  10581. * Internal only - manager for action
  10582. * @hidden
  10583. */
  10584. _actionManager: ActionManager;
  10585. /**
  10586. * Creates a new PredicateCondition
  10587. * @param actionManager manager for the action the condition applies to
  10588. * @param predicate defines the predicate function used to validate the condition
  10589. */
  10590. constructor(actionManager: ActionManager,
  10591. /** defines the predicate function used to validate the condition */
  10592. predicate: () => boolean);
  10593. /**
  10594. * @returns the validity of the predicate condition
  10595. */
  10596. isValid(): boolean;
  10597. }
  10598. /**
  10599. * Defines a state condition as an extension of Condition
  10600. */
  10601. export class StateCondition extends Condition {
  10602. /** Value to compare with target state */
  10603. value: string;
  10604. /**
  10605. * Internal only - manager for action
  10606. * @hidden
  10607. */
  10608. _actionManager: ActionManager;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. private _target;
  10614. /**
  10615. * Creates a new StateCondition
  10616. * @param actionManager manager for the action the condition applies to
  10617. * @param target of the condition
  10618. * @param value to compare with target state
  10619. */
  10620. constructor(actionManager: ActionManager, target: any,
  10621. /** Value to compare with target state */
  10622. value: string);
  10623. /**
  10624. * Gets a boolean indicating if the current condition is met
  10625. * @returns the validity of the state
  10626. */
  10627. isValid(): boolean;
  10628. /**
  10629. * Serialize the StateCondition into a JSON compatible object
  10630. * @returns serialization object
  10631. */
  10632. serialize(): any;
  10633. }
  10634. }
  10635. declare module BABYLON {
  10636. /**
  10637. * This defines an action responsible to toggle a boolean once triggered.
  10638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class SwitchBooleanAction extends Action {
  10641. /**
  10642. * The path to the boolean property in the target object
  10643. */
  10644. propertyPath: string;
  10645. private _target;
  10646. private _effectiveTarget;
  10647. private _property;
  10648. /**
  10649. * Instantiate the action
  10650. * @param triggerOptions defines the trigger options
  10651. * @param target defines the object containing the boolean
  10652. * @param propertyPath defines the path to the boolean property in the target object
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action toggle the boolean value.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to set a the state field of the target
  10671. * to a desired value once triggered.
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10673. */
  10674. export class SetStateAction extends Action {
  10675. /**
  10676. * The value to store in the state field.
  10677. */
  10678. value: string;
  10679. private _target;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param target defines the object containing the state property
  10684. * @param value defines the value to store in the state field
  10685. * @param condition defines the trigger related conditions
  10686. */
  10687. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10688. /**
  10689. * Execute the action and store the value on the target state property.
  10690. */
  10691. execute(): void;
  10692. /**
  10693. * Serializes the actions and its related information.
  10694. * @param parent defines the object to serialize in
  10695. * @returns the serialized object
  10696. */
  10697. serialize(parent: any): any;
  10698. }
  10699. /**
  10700. * This defines an action responsible to set a property of the target
  10701. * to a desired value once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class SetValueAction extends Action {
  10705. /**
  10706. * The path of the property to set in the target.
  10707. */
  10708. propertyPath: string;
  10709. /**
  10710. * The value to set in the property
  10711. */
  10712. value: any;
  10713. private _target;
  10714. private _effectiveTarget;
  10715. private _property;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the object containing the property
  10720. * @param propertyPath defines the path of the property to set in the target
  10721. * @param value defines the value to set in the property
  10722. * @param condition defines the trigger related conditions
  10723. */
  10724. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10725. /** @hidden */
  10726. _prepare(): void;
  10727. /**
  10728. * Execute the action and set the targetted property to the desired value.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to increment the target value
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class IncrementValueAction extends Action {
  10744. /**
  10745. * The path of the property to increment in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value we should increment the property by.
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to increment in the target
  10760. * @param value defines the value value we should increment the property by
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and increment the target of the value amount.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to start an animation once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class PlayAnimationAction extends Action {
  10782. /**
  10783. * Where the animation should start (animation frame)
  10784. */
  10785. from: number;
  10786. /**
  10787. * Where the animation should stop (animation frame)
  10788. */
  10789. to: number;
  10790. /**
  10791. * Define if the animation should loop or stop after the first play.
  10792. */
  10793. loop?: boolean;
  10794. private _target;
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param target defines the target animation or animation name
  10799. * @param from defines from where the animation should start (animation frame)
  10800. * @param end defines where the animation should stop (animation frame)
  10801. * @param loop defines if the animation should loop or stop after the first play
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10805. /** @hidden */
  10806. _prepare(): void;
  10807. /**
  10808. * Execute the action and play the animation.
  10809. */
  10810. execute(): void;
  10811. /**
  10812. * Serializes the actions and its related information.
  10813. * @param parent defines the object to serialize in
  10814. * @returns the serialized object
  10815. */
  10816. serialize(parent: any): any;
  10817. }
  10818. /**
  10819. * This defines an action responsible to stop an animation once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class StopAnimationAction extends Action {
  10823. private _target;
  10824. /**
  10825. * Instantiate the action
  10826. * @param triggerOptions defines the trigger options
  10827. * @param target defines the target animation or animation name
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and stop the animation.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. /**
  10845. * This defines an action responsible that does nothing once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class DoNothingAction extends Action {
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param condition defines the trigger related conditions
  10853. */
  10854. constructor(triggerOptions?: any, condition?: Condition);
  10855. /**
  10856. * Execute the action and do nothing.
  10857. */
  10858. execute(): void;
  10859. /**
  10860. * Serializes the actions and its related information.
  10861. * @param parent defines the object to serialize in
  10862. * @returns the serialized object
  10863. */
  10864. serialize(parent: any): any;
  10865. }
  10866. /**
  10867. * This defines an action responsible to trigger several actions once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class CombineAction extends Action {
  10871. /**
  10872. * The list of aggregated animations to run.
  10873. */
  10874. children: Action[];
  10875. /**
  10876. * Instantiate the action
  10877. * @param triggerOptions defines the trigger options
  10878. * @param children defines the list of aggregated animations to run
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10882. /** @hidden */
  10883. _prepare(): void;
  10884. /**
  10885. * Execute the action and executes all the aggregated actions.
  10886. */
  10887. execute(evt: ActionEvent): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to run code (external event) once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class ExecuteCodeAction extends Action {
  10900. /**
  10901. * The callback function to run.
  10902. */
  10903. func: (evt: ActionEvent) => void;
  10904. /**
  10905. * Instantiate the action
  10906. * @param triggerOptions defines the trigger options
  10907. * @param func defines the callback function to run
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10911. /**
  10912. * Execute the action and run the attached code.
  10913. */
  10914. execute(evt: ActionEvent): void;
  10915. }
  10916. /**
  10917. * This defines an action responsible to set the parent property of the target once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class SetParentAction extends Action {
  10921. private _parent;
  10922. private _target;
  10923. /**
  10924. * Instantiate the action
  10925. * @param triggerOptions defines the trigger options
  10926. * @param target defines the target containing the parent property
  10927. * @param parent defines from where the animation should start (animation frame)
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10931. /** @hidden */
  10932. _prepare(): void;
  10933. /**
  10934. * Execute the action and set the parent property.
  10935. */
  10936. execute(): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. }
  10945. declare module BABYLON {
  10946. /**
  10947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class ActionManager extends AbstractActionManager {
  10952. /**
  10953. * Nothing
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10955. */
  10956. static readonly NothingTrigger: number;
  10957. /**
  10958. * On pick
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10960. */
  10961. static readonly OnPickTrigger: number;
  10962. /**
  10963. * On left pick
  10964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10965. */
  10966. static readonly OnLeftPickTrigger: number;
  10967. /**
  10968. * On right pick
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10970. */
  10971. static readonly OnRightPickTrigger: number;
  10972. /**
  10973. * On center pick
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10975. */
  10976. static readonly OnCenterPickTrigger: number;
  10977. /**
  10978. * On pick down
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly OnPickDownTrigger: number;
  10982. /**
  10983. * On double pick
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly OnDoublePickTrigger: number;
  10987. /**
  10988. * On pick up
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnPickUpTrigger: number;
  10992. /**
  10993. * On pick out.
  10994. * This trigger will only be raised if you also declared a OnPickDown
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10996. */
  10997. static readonly OnPickOutTrigger: number;
  10998. /**
  10999. * On long press
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11001. */
  11002. static readonly OnLongPressTrigger: number;
  11003. /**
  11004. * On pointer over
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly OnPointerOverTrigger: number;
  11008. /**
  11009. * On pointer out
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPointerOutTrigger: number;
  11013. /**
  11014. * On every frame
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnEveryFrameTrigger: number;
  11018. /**
  11019. * On intersection enter
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnIntersectionEnterTrigger: number;
  11023. /**
  11024. * On intersection exit
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnIntersectionExitTrigger: number;
  11028. /**
  11029. * On key down
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnKeyDownTrigger: number;
  11033. /**
  11034. * On key up
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnKeyUpTrigger: number;
  11038. private _scene;
  11039. /**
  11040. * Creates a new action manager
  11041. * @param scene defines the hosting scene
  11042. */
  11043. constructor(scene: Scene);
  11044. /**
  11045. * Releases all associated resources
  11046. */
  11047. dispose(): void;
  11048. /**
  11049. * Gets hosting scene
  11050. * @returns the hosting scene
  11051. */
  11052. getScene(): Scene;
  11053. /**
  11054. * Does this action manager handles actions of any of the given triggers
  11055. * @param triggers defines the triggers to be tested
  11056. * @return a boolean indicating whether one (or more) of the triggers is handled
  11057. */
  11058. hasSpecificTriggers(triggers: number[]): boolean;
  11059. /**
  11060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11061. * speed.
  11062. * @param triggerA defines the trigger to be tested
  11063. * @param triggerB defines the trigger to be tested
  11064. * @return a boolean indicating whether one (or more) of the triggers is handled
  11065. */
  11066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11067. /**
  11068. * Does this action manager handles actions of a given trigger
  11069. * @param trigger defines the trigger to be tested
  11070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11071. * @return whether the trigger is handled
  11072. */
  11073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11074. /**
  11075. * Does this action manager has pointer triggers
  11076. */
  11077. get hasPointerTriggers(): boolean;
  11078. /**
  11079. * Does this action manager has pick triggers
  11080. */
  11081. get hasPickTriggers(): boolean;
  11082. /**
  11083. * Registers an action to this action manager
  11084. * @param action defines the action to be registered
  11085. * @return the action amended (prepared) after registration
  11086. */
  11087. registerAction(action: IAction): Nullable<IAction>;
  11088. /**
  11089. * Unregisters an action to this action manager
  11090. * @param action defines the action to be unregistered
  11091. * @return a boolean indicating whether the action has been unregistered
  11092. */
  11093. unregisterAction(action: IAction): Boolean;
  11094. /**
  11095. * Process a specific trigger
  11096. * @param trigger defines the trigger to process
  11097. * @param evt defines the event details to be processed
  11098. */
  11099. processTrigger(trigger: number, evt?: IActionEvent): void;
  11100. /** @hidden */
  11101. _getEffectiveTarget(target: any, propertyPath: string): any;
  11102. /** @hidden */
  11103. _getProperty(propertyPath: string): string;
  11104. /**
  11105. * Serialize this manager to a JSON object
  11106. * @param name defines the property name to store this manager
  11107. * @returns a JSON representation of this manager
  11108. */
  11109. serialize(name: string): any;
  11110. /**
  11111. * Creates a new ActionManager from a JSON data
  11112. * @param parsedActions defines the JSON data to read from
  11113. * @param object defines the hosting mesh
  11114. * @param scene defines the hosting scene
  11115. */
  11116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11117. /**
  11118. * Get a trigger name by index
  11119. * @param trigger defines the trigger index
  11120. * @returns a trigger name
  11121. */
  11122. static GetTriggerName(trigger: number): string;
  11123. }
  11124. }
  11125. declare module BABYLON {
  11126. /**
  11127. * Class representing a ray with position and direction
  11128. */
  11129. export class Ray {
  11130. /** origin point */
  11131. origin: Vector3;
  11132. /** direction */
  11133. direction: Vector3;
  11134. /** length of the ray */
  11135. length: number;
  11136. private static readonly TmpVector3;
  11137. private _tmpRay;
  11138. /**
  11139. * Creates a new ray
  11140. * @param origin origin point
  11141. * @param direction direction
  11142. * @param length length of the ray
  11143. */
  11144. constructor(
  11145. /** origin point */
  11146. origin: Vector3,
  11147. /** direction */
  11148. direction: Vector3,
  11149. /** length of the ray */
  11150. length?: number);
  11151. /**
  11152. * Checks if the ray intersects a box
  11153. * @param minimum bound of the box
  11154. * @param maximum bound of the box
  11155. * @param intersectionTreshold extra extend to be added to the box in all direction
  11156. * @returns if the box was hit
  11157. */
  11158. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11159. /**
  11160. * Checks if the ray intersects a box
  11161. * @param box the bounding box to check
  11162. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11163. * @returns if the box was hit
  11164. */
  11165. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11166. /**
  11167. * If the ray hits a sphere
  11168. * @param sphere the bounding sphere to check
  11169. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11170. * @returns true if it hits the sphere
  11171. */
  11172. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11173. /**
  11174. * If the ray hits a triange
  11175. * @param vertex0 triangle vertex
  11176. * @param vertex1 triangle vertex
  11177. * @param vertex2 triangle vertex
  11178. * @returns intersection information if hit
  11179. */
  11180. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11181. /**
  11182. * Checks if ray intersects a plane
  11183. * @param plane the plane to check
  11184. * @returns the distance away it was hit
  11185. */
  11186. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11187. /**
  11188. * Calculate the intercept of a ray on a given axis
  11189. * @param axis to check 'x' | 'y' | 'z'
  11190. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11191. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11192. */
  11193. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11194. /**
  11195. * Checks if ray intersects a mesh
  11196. * @param mesh the mesh to check
  11197. * @param fastCheck if only the bounding box should checked
  11198. * @returns picking info of the intersecton
  11199. */
  11200. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11201. /**
  11202. * Checks if ray intersects a mesh
  11203. * @param meshes the meshes to check
  11204. * @param fastCheck if only the bounding box should checked
  11205. * @param results array to store result in
  11206. * @returns Array of picking infos
  11207. */
  11208. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11209. private _comparePickingInfo;
  11210. private static smallnum;
  11211. private static rayl;
  11212. /**
  11213. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11214. * @param sega the first point of the segment to test the intersection against
  11215. * @param segb the second point of the segment to test the intersection against
  11216. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11217. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11218. */
  11219. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11220. /**
  11221. * Update the ray from viewport position
  11222. * @param x position
  11223. * @param y y position
  11224. * @param viewportWidth viewport width
  11225. * @param viewportHeight viewport height
  11226. * @param world world matrix
  11227. * @param view view matrix
  11228. * @param projection projection matrix
  11229. * @returns this ray updated
  11230. */
  11231. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11232. /**
  11233. * Creates a ray with origin and direction of 0,0,0
  11234. * @returns the new ray
  11235. */
  11236. static Zero(): Ray;
  11237. /**
  11238. * Creates a new ray from screen space and viewport
  11239. * @param x position
  11240. * @param y y position
  11241. * @param viewportWidth viewport width
  11242. * @param viewportHeight viewport height
  11243. * @param world world matrix
  11244. * @param view view matrix
  11245. * @param projection projection matrix
  11246. * @returns new ray
  11247. */
  11248. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11249. /**
  11250. * 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
  11251. * transformed to the given world matrix.
  11252. * @param origin The origin point
  11253. * @param end The end point
  11254. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11255. * @returns the new ray
  11256. */
  11257. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11258. /**
  11259. * Transforms a ray by a matrix
  11260. * @param ray ray to transform
  11261. * @param matrix matrix to apply
  11262. * @returns the resulting new ray
  11263. */
  11264. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11265. /**
  11266. * Transforms a ray by a matrix
  11267. * @param ray ray to transform
  11268. * @param matrix matrix to apply
  11269. * @param result ray to store result in
  11270. */
  11271. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11272. /**
  11273. * Unproject a ray from screen space to object space
  11274. * @param sourceX defines the screen space x coordinate to use
  11275. * @param sourceY defines the screen space y coordinate to use
  11276. * @param viewportWidth defines the current width of the viewport
  11277. * @param viewportHeight defines the current height of the viewport
  11278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11279. * @param view defines the view matrix to use
  11280. * @param projection defines the projection matrix to use
  11281. */
  11282. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11283. }
  11284. /**
  11285. * Type used to define predicate used to select faces when a mesh intersection is detected
  11286. */
  11287. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11288. interface Scene {
  11289. /** @hidden */
  11290. _tempPickingRay: Nullable<Ray>;
  11291. /** @hidden */
  11292. _cachedRayForTransform: Ray;
  11293. /** @hidden */
  11294. _pickWithRayInverseMatrix: Matrix;
  11295. /** @hidden */
  11296. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11297. /** @hidden */
  11298. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11299. }
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Groups all the scene component constants in one place to ease maintenance.
  11304. * @hidden
  11305. */
  11306. export class SceneComponentConstants {
  11307. static readonly NAME_EFFECTLAYER: string;
  11308. static readonly NAME_LAYER: string;
  11309. static readonly NAME_LENSFLARESYSTEM: string;
  11310. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11311. static readonly NAME_PARTICLESYSTEM: string;
  11312. static readonly NAME_GAMEPAD: string;
  11313. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11314. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11315. static readonly NAME_DEPTHRENDERER: string;
  11316. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11317. static readonly NAME_SPRITE: string;
  11318. static readonly NAME_OUTLINERENDERER: string;
  11319. static readonly NAME_PROCEDURALTEXTURE: string;
  11320. static readonly NAME_SHADOWGENERATOR: string;
  11321. static readonly NAME_OCTREE: string;
  11322. static readonly NAME_PHYSICSENGINE: string;
  11323. static readonly NAME_AUDIO: string;
  11324. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11325. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11326. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11327. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11328. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11329. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11330. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11331. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11332. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11333. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11334. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11335. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11336. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11337. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11338. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11339. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11340. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11341. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11342. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11343. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11344. static readonly STEP_AFTERRENDER_AUDIO: number;
  11345. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11346. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11347. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11348. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11349. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11350. static readonly STEP_POINTERMOVE_SPRITE: number;
  11351. static readonly STEP_POINTERDOWN_SPRITE: number;
  11352. static readonly STEP_POINTERUP_SPRITE: number;
  11353. }
  11354. /**
  11355. * This represents a scene component.
  11356. *
  11357. * This is used to decouple the dependency the scene is having on the different workloads like
  11358. * layers, post processes...
  11359. */
  11360. export interface ISceneComponent {
  11361. /**
  11362. * The name of the component. Each component must have a unique name.
  11363. */
  11364. name: string;
  11365. /**
  11366. * The scene the component belongs to.
  11367. */
  11368. scene: Scene;
  11369. /**
  11370. * Register the component to one instance of a scene.
  11371. */
  11372. register(): void;
  11373. /**
  11374. * Rebuilds the elements related to this component in case of
  11375. * context lost for instance.
  11376. */
  11377. rebuild(): void;
  11378. /**
  11379. * Disposes the component and the associated ressources.
  11380. */
  11381. dispose(): void;
  11382. }
  11383. /**
  11384. * This represents a SERIALIZABLE scene component.
  11385. *
  11386. * This extends Scene Component to add Serialization methods on top.
  11387. */
  11388. export interface ISceneSerializableComponent extends ISceneComponent {
  11389. /**
  11390. * Adds all the elements from the container to the scene
  11391. * @param container the container holding the elements
  11392. */
  11393. addFromContainer(container: AbstractScene): void;
  11394. /**
  11395. * Removes all the elements in the container from the scene
  11396. * @param container contains the elements to remove
  11397. * @param dispose if the removed element should be disposed (default: false)
  11398. */
  11399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11400. /**
  11401. * Serializes the component data to the specified json object
  11402. * @param serializationObject The object to serialize to
  11403. */
  11404. serialize(serializationObject: any): void;
  11405. }
  11406. /**
  11407. * Strong typing of a Mesh related stage step action
  11408. */
  11409. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11410. /**
  11411. * Strong typing of a Evaluate Sub Mesh related stage step action
  11412. */
  11413. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11414. /**
  11415. * Strong typing of a Active Mesh related stage step action
  11416. */
  11417. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11418. /**
  11419. * Strong typing of a Camera related stage step action
  11420. */
  11421. export type CameraStageAction = (camera: Camera) => void;
  11422. /**
  11423. * Strong typing of a Camera Frame buffer related stage step action
  11424. */
  11425. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11426. /**
  11427. * Strong typing of a Render Target related stage step action
  11428. */
  11429. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11430. /**
  11431. * Strong typing of a RenderingGroup related stage step action
  11432. */
  11433. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11434. /**
  11435. * Strong typing of a Mesh Render related stage step action
  11436. */
  11437. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11438. /**
  11439. * Strong typing of a simple stage step action
  11440. */
  11441. export type SimpleStageAction = () => void;
  11442. /**
  11443. * Strong typing of a render target action.
  11444. */
  11445. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11446. /**
  11447. * Strong typing of a pointer move action.
  11448. */
  11449. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11450. /**
  11451. * Strong typing of a pointer up/down action.
  11452. */
  11453. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11454. /**
  11455. * Representation of a stage in the scene (Basically a list of ordered steps)
  11456. * @hidden
  11457. */
  11458. export class Stage<T extends Function> extends Array<{
  11459. index: number;
  11460. component: ISceneComponent;
  11461. action: T;
  11462. }> {
  11463. /**
  11464. * Hide ctor from the rest of the world.
  11465. * @param items The items to add.
  11466. */
  11467. private constructor();
  11468. /**
  11469. * Creates a new Stage.
  11470. * @returns A new instance of a Stage
  11471. */
  11472. static Create<T extends Function>(): Stage<T>;
  11473. /**
  11474. * Registers a step in an ordered way in the targeted stage.
  11475. * @param index Defines the position to register the step in
  11476. * @param component Defines the component attached to the step
  11477. * @param action Defines the action to launch during the step
  11478. */
  11479. registerStep(index: number, component: ISceneComponent, action: T): void;
  11480. /**
  11481. * Clears all the steps from the stage.
  11482. */
  11483. clear(): void;
  11484. }
  11485. }
  11486. declare module BABYLON {
  11487. interface Scene {
  11488. /** @hidden */
  11489. _pointerOverSprite: Nullable<Sprite>;
  11490. /** @hidden */
  11491. _pickedDownSprite: Nullable<Sprite>;
  11492. /** @hidden */
  11493. _tempSpritePickingRay: Nullable<Ray>;
  11494. /**
  11495. * All of the sprite managers added to this scene
  11496. * @see http://doc.babylonjs.com/babylon101/sprites
  11497. */
  11498. spriteManagers: Array<ISpriteManager>;
  11499. /**
  11500. * An event triggered when sprites rendering is about to start
  11501. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11502. */
  11503. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11504. /**
  11505. * An event triggered when sprites rendering is done
  11506. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11507. */
  11508. onAfterSpritesRenderingObservable: Observable<Scene>;
  11509. /** @hidden */
  11510. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11511. /** Launch a ray to try to pick a sprite in the scene
  11512. * @param x position on screen
  11513. * @param y position on screen
  11514. * @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
  11515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11516. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11517. * @returns a PickingInfo
  11518. */
  11519. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11520. /** Use the given ray to pick a sprite in the scene
  11521. * @param ray The ray (in world space) to use to pick meshes
  11522. * @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
  11523. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11524. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11525. * @returns a PickingInfo
  11526. */
  11527. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11528. /** @hidden */
  11529. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11530. /** Launch a ray to try to pick sprites in the scene
  11531. * @param x position on screen
  11532. * @param y position on screen
  11533. * @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
  11534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11535. * @returns a PickingInfo array
  11536. */
  11537. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11538. /** Use the given ray to pick sprites in the scene
  11539. * @param ray The ray (in world space) to use to pick meshes
  11540. * @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
  11541. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11542. * @returns a PickingInfo array
  11543. */
  11544. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11545. /**
  11546. * Force the sprite under the pointer
  11547. * @param sprite defines the sprite to use
  11548. */
  11549. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11550. /**
  11551. * Gets the sprite under the pointer
  11552. * @returns a Sprite or null if no sprite is under the pointer
  11553. */
  11554. getPointerOverSprite(): Nullable<Sprite>;
  11555. }
  11556. /**
  11557. * Defines the sprite scene component responsible to manage sprites
  11558. * in a given scene.
  11559. */
  11560. export class SpriteSceneComponent implements ISceneComponent {
  11561. /**
  11562. * The component name helpfull to identify the component in the list of scene components.
  11563. */
  11564. readonly name: string;
  11565. /**
  11566. * The scene the component belongs to.
  11567. */
  11568. scene: Scene;
  11569. /** @hidden */
  11570. private _spritePredicate;
  11571. /**
  11572. * Creates a new instance of the component for the given scene
  11573. * @param scene Defines the scene to register the component in
  11574. */
  11575. constructor(scene: Scene);
  11576. /**
  11577. * Registers the component in a given scene
  11578. */
  11579. register(): void;
  11580. /**
  11581. * Rebuilds the elements related to this component in case of
  11582. * context lost for instance.
  11583. */
  11584. rebuild(): void;
  11585. /**
  11586. * Disposes the component and the associated ressources.
  11587. */
  11588. dispose(): void;
  11589. private _pickSpriteButKeepRay;
  11590. private _pointerMove;
  11591. private _pointerDown;
  11592. private _pointerUp;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /** @hidden */
  11597. export var fogFragmentDeclaration: {
  11598. name: string;
  11599. shader: string;
  11600. };
  11601. }
  11602. declare module BABYLON {
  11603. /** @hidden */
  11604. export var fogFragment: {
  11605. name: string;
  11606. shader: string;
  11607. };
  11608. }
  11609. declare module BABYLON {
  11610. /** @hidden */
  11611. export var spritesPixelShader: {
  11612. name: string;
  11613. shader: string;
  11614. };
  11615. }
  11616. declare module BABYLON {
  11617. /** @hidden */
  11618. export var fogVertexDeclaration: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module BABYLON {
  11624. /** @hidden */
  11625. export var spritesVertexShader: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11633. */
  11634. export interface ISpriteManager extends IDisposable {
  11635. /**
  11636. * Restricts the camera to viewing objects with the same layerMask.
  11637. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11638. */
  11639. layerMask: number;
  11640. /**
  11641. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11642. */
  11643. isPickable: boolean;
  11644. /**
  11645. * Specifies the rendering group id for this mesh (0 by default)
  11646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11647. */
  11648. renderingGroupId: number;
  11649. /**
  11650. * Defines the list of sprites managed by the manager.
  11651. */
  11652. sprites: Array<Sprite>;
  11653. /**
  11654. * Tests the intersection of a sprite with a specific ray.
  11655. * @param ray The ray we are sending to test the collision
  11656. * @param camera The camera space we are sending rays in
  11657. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11658. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11659. * @returns picking info or null.
  11660. */
  11661. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11662. /**
  11663. * Intersects the sprites with a ray
  11664. * @param ray defines the ray to intersect with
  11665. * @param camera defines the current active camera
  11666. * @param predicate defines a predicate used to select candidate sprites
  11667. * @returns null if no hit or a PickingInfo array
  11668. */
  11669. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11670. /**
  11671. * Renders the list of sprites on screen.
  11672. */
  11673. render(): void;
  11674. }
  11675. /**
  11676. * Class used to manage multiple sprites on the same spritesheet
  11677. * @see http://doc.babylonjs.com/babylon101/sprites
  11678. */
  11679. export class SpriteManager implements ISpriteManager {
  11680. /** defines the manager's name */
  11681. name: string;
  11682. /** Gets the list of sprites */
  11683. sprites: Sprite[];
  11684. /** Gets or sets the rendering group id (0 by default) */
  11685. renderingGroupId: number;
  11686. /** Gets or sets camera layer mask */
  11687. layerMask: number;
  11688. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11689. fogEnabled: boolean;
  11690. /** Gets or sets a boolean indicating if the sprites are pickable */
  11691. isPickable: boolean;
  11692. /** Defines the default width of a cell in the spritesheet */
  11693. cellWidth: number;
  11694. /** Defines the default height of a cell in the spritesheet */
  11695. cellHeight: number;
  11696. /** Associative array from JSON sprite data file */
  11697. private _cellData;
  11698. /** Array of sprite names from JSON sprite data file */
  11699. private _spriteMap;
  11700. /** True when packed cell data from JSON file is ready*/
  11701. private _packedAndReady;
  11702. /**
  11703. * An event triggered when the manager is disposed.
  11704. */
  11705. onDisposeObservable: Observable<SpriteManager>;
  11706. private _onDisposeObserver;
  11707. /**
  11708. * Callback called when the manager is disposed
  11709. */
  11710. set onDispose(callback: () => void);
  11711. private _capacity;
  11712. private _fromPacked;
  11713. private _spriteTexture;
  11714. private _epsilon;
  11715. private _scene;
  11716. private _vertexData;
  11717. private _buffer;
  11718. private _vertexBuffers;
  11719. private _indexBuffer;
  11720. private _effectBase;
  11721. private _effectFog;
  11722. /**
  11723. * Gets or sets the spritesheet texture
  11724. */
  11725. get texture(): Texture;
  11726. set texture(value: Texture);
  11727. /**
  11728. * Creates a new sprite manager
  11729. * @param name defines the manager's name
  11730. * @param imgUrl defines the sprite sheet url
  11731. * @param capacity defines the maximum allowed number of sprites
  11732. * @param cellSize defines the size of a sprite cell
  11733. * @param scene defines the hosting scene
  11734. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11735. * @param samplingMode defines the smapling mode to use with spritesheet
  11736. * @param fromPacked set to false; do not alter
  11737. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11738. */
  11739. constructor(
  11740. /** defines the manager's name */
  11741. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11742. private _makePacked;
  11743. private _appendSpriteVertex;
  11744. /**
  11745. * Intersects the sprites with a ray
  11746. * @param ray defines the ray to intersect with
  11747. * @param camera defines the current active camera
  11748. * @param predicate defines a predicate used to select candidate sprites
  11749. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11750. * @returns null if no hit or a PickingInfo
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Intersects the sprites with a ray
  11755. * @param ray defines the ray to intersect with
  11756. * @param camera defines the current active camera
  11757. * @param predicate defines a predicate used to select candidate sprites
  11758. * @returns null if no hit or a PickingInfo array
  11759. */
  11760. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11761. /**
  11762. * Render all child sprites
  11763. */
  11764. render(): void;
  11765. /**
  11766. * Release associated resources
  11767. */
  11768. dispose(): void;
  11769. }
  11770. }
  11771. declare module BABYLON {
  11772. /**
  11773. * Class used to represent a sprite
  11774. * @see http://doc.babylonjs.com/babylon101/sprites
  11775. */
  11776. export class Sprite {
  11777. /** defines the name */
  11778. name: string;
  11779. /** Gets or sets the current world position */
  11780. position: Vector3;
  11781. /** Gets or sets the main color */
  11782. color: Color4;
  11783. /** Gets or sets the width */
  11784. width: number;
  11785. /** Gets or sets the height */
  11786. height: number;
  11787. /** Gets or sets rotation angle */
  11788. angle: number;
  11789. /** Gets or sets the cell index in the sprite sheet */
  11790. cellIndex: number;
  11791. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11792. cellRef: string;
  11793. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11794. invertU: number;
  11795. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11796. invertV: number;
  11797. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11798. disposeWhenFinishedAnimating: boolean;
  11799. /** Gets the list of attached animations */
  11800. animations: Animation[];
  11801. /** Gets or sets a boolean indicating if the sprite can be picked */
  11802. isPickable: boolean;
  11803. /**
  11804. * Gets or sets the associated action manager
  11805. */
  11806. actionManager: Nullable<ActionManager>;
  11807. private _animationStarted;
  11808. private _loopAnimation;
  11809. private _fromIndex;
  11810. private _toIndex;
  11811. private _delay;
  11812. private _direction;
  11813. private _manager;
  11814. private _time;
  11815. private _onAnimationEnd;
  11816. /**
  11817. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11818. */
  11819. isVisible: boolean;
  11820. /**
  11821. * Gets or sets the sprite size
  11822. */
  11823. get size(): number;
  11824. set size(value: number);
  11825. /**
  11826. * Creates a new Sprite
  11827. * @param name defines the name
  11828. * @param manager defines the manager
  11829. */
  11830. constructor(
  11831. /** defines the name */
  11832. name: string, manager: ISpriteManager);
  11833. /**
  11834. * Starts an animation
  11835. * @param from defines the initial key
  11836. * @param to defines the end key
  11837. * @param loop defines if the animation must loop
  11838. * @param delay defines the start delay (in ms)
  11839. * @param onAnimationEnd defines a callback to call when animation ends
  11840. */
  11841. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11842. /** Stops current animation (if any) */
  11843. stopAnimation(): void;
  11844. /** @hidden */
  11845. _animate(deltaTime: number): void;
  11846. /** Release associated resources */
  11847. dispose(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Information about the result of picking within a scene
  11853. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11854. */
  11855. export class PickingInfo {
  11856. /** @hidden */
  11857. _pickingUnavailable: boolean;
  11858. /**
  11859. * If the pick collided with an object
  11860. */
  11861. hit: boolean;
  11862. /**
  11863. * Distance away where the pick collided
  11864. */
  11865. distance: number;
  11866. /**
  11867. * The location of pick collision
  11868. */
  11869. pickedPoint: Nullable<Vector3>;
  11870. /**
  11871. * The mesh corresponding the the pick collision
  11872. */
  11873. pickedMesh: Nullable<AbstractMesh>;
  11874. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11875. bu: number;
  11876. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11877. bv: number;
  11878. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11879. faceId: number;
  11880. /** Id of the the submesh that was picked */
  11881. subMeshId: number;
  11882. /** If a sprite was picked, this will be the sprite the pick collided with */
  11883. pickedSprite: Nullable<Sprite>;
  11884. /**
  11885. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11886. */
  11887. originMesh: Nullable<AbstractMesh>;
  11888. /**
  11889. * The ray that was used to perform the picking.
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Gets the normal correspodning to the face the pick collided with
  11894. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11895. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11896. * @returns The normal correspodning to the face the pick collided with
  11897. */
  11898. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11899. /**
  11900. * Gets the texture coordinates of where the pick occured
  11901. * @returns the vector containing the coordnates of the texture
  11902. */
  11903. getTextureCoordinates(): Nullable<Vector2>;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Gather the list of pointer event types as constants.
  11909. */
  11910. export class PointerEventTypes {
  11911. /**
  11912. * 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.
  11913. */
  11914. static readonly POINTERDOWN: number;
  11915. /**
  11916. * The pointerup event is fired when a pointer is no longer active.
  11917. */
  11918. static readonly POINTERUP: number;
  11919. /**
  11920. * The pointermove event is fired when a pointer changes coordinates.
  11921. */
  11922. static readonly POINTERMOVE: number;
  11923. /**
  11924. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11925. */
  11926. static readonly POINTERWHEEL: number;
  11927. /**
  11928. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11929. */
  11930. static readonly POINTERPICK: number;
  11931. /**
  11932. * The pointertap event is fired when a the object has been touched and released without drag.
  11933. */
  11934. static readonly POINTERTAP: number;
  11935. /**
  11936. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11937. */
  11938. static readonly POINTERDOUBLETAP: number;
  11939. }
  11940. /**
  11941. * Base class of pointer info types.
  11942. */
  11943. export class PointerInfoBase {
  11944. /**
  11945. * Defines the type of event (PointerEventTypes)
  11946. */
  11947. type: number;
  11948. /**
  11949. * Defines the related dom event
  11950. */
  11951. event: PointerEvent | MouseWheelEvent;
  11952. /**
  11953. * Instantiates the base class of pointers info.
  11954. * @param type Defines the type of event (PointerEventTypes)
  11955. * @param event Defines the related dom event
  11956. */
  11957. constructor(
  11958. /**
  11959. * Defines the type of event (PointerEventTypes)
  11960. */
  11961. type: number,
  11962. /**
  11963. * Defines the related dom event
  11964. */
  11965. event: PointerEvent | MouseWheelEvent);
  11966. }
  11967. /**
  11968. * This class is used to store pointer related info for the onPrePointerObservable event.
  11969. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11970. */
  11971. export class PointerInfoPre extends PointerInfoBase {
  11972. /**
  11973. * Ray from a pointer if availible (eg. 6dof controller)
  11974. */
  11975. ray: Nullable<Ray>;
  11976. /**
  11977. * Defines the local position of the pointer on the canvas.
  11978. */
  11979. localPosition: Vector2;
  11980. /**
  11981. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11982. */
  11983. skipOnPointerObservable: boolean;
  11984. /**
  11985. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11986. * @param type Defines the type of event (PointerEventTypes)
  11987. * @param event Defines the related dom event
  11988. * @param localX Defines the local x coordinates of the pointer when the event occured
  11989. * @param localY Defines the local y coordinates of the pointer when the event occured
  11990. */
  11991. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11992. }
  11993. /**
  11994. * This type contains all the data related to a pointer event in Babylon.js.
  11995. * 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.
  11996. */
  11997. export class PointerInfo extends PointerInfoBase {
  11998. /**
  11999. * Defines the picking info associated to the info (if any)\
  12000. */
  12001. pickInfo: Nullable<PickingInfo>;
  12002. /**
  12003. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12004. * @param type Defines the type of event (PointerEventTypes)
  12005. * @param event Defines the related dom event
  12006. * @param pickInfo Defines the picking info associated to the info (if any)\
  12007. */
  12008. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12009. /**
  12010. * Defines the picking info associated to the info (if any)\
  12011. */
  12012. pickInfo: Nullable<PickingInfo>);
  12013. }
  12014. /**
  12015. * Data relating to a touch event on the screen.
  12016. */
  12017. export interface PointerTouch {
  12018. /**
  12019. * X coordinate of touch.
  12020. */
  12021. x: number;
  12022. /**
  12023. * Y coordinate of touch.
  12024. */
  12025. y: number;
  12026. /**
  12027. * Id of touch. Unique for each finger.
  12028. */
  12029. pointerId: number;
  12030. /**
  12031. * Event type passed from DOM.
  12032. */
  12033. type: any;
  12034. }
  12035. }
  12036. declare module BABYLON {
  12037. /**
  12038. * Manage the mouse inputs to control the movement of a free camera.
  12039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12040. */
  12041. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12042. /**
  12043. * Define if touch is enabled in the mouse input
  12044. */
  12045. touchEnabled: boolean;
  12046. /**
  12047. * Defines the camera the input is attached to.
  12048. */
  12049. camera: FreeCamera;
  12050. /**
  12051. * Defines the buttons associated with the input to handle camera move.
  12052. */
  12053. buttons: number[];
  12054. /**
  12055. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12056. */
  12057. angularSensibility: number;
  12058. private _pointerInput;
  12059. private _onMouseMove;
  12060. private _observer;
  12061. private previousPosition;
  12062. /**
  12063. * Observable for when a pointer move event occurs containing the move offset
  12064. */
  12065. onPointerMovedObservable: Observable<{
  12066. offsetX: number;
  12067. offsetY: number;
  12068. }>;
  12069. /**
  12070. * @hidden
  12071. * If the camera should be rotated automatically based on pointer movement
  12072. */
  12073. _allowCameraRotation: boolean;
  12074. /**
  12075. * Manage the mouse inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. * @param touchEnabled Defines if touch is enabled or not
  12078. */
  12079. constructor(
  12080. /**
  12081. * Define if touch is enabled in the mouse input
  12082. */
  12083. touchEnabled?: boolean);
  12084. /**
  12085. * Attach the input controls to a specific dom element to get the input from.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Called on JS contextmenu event.
  12092. * Override this method to provide functionality.
  12093. */
  12094. protected onContextMenu(evt: PointerEvent): void;
  12095. /**
  12096. * Detach the current controls from the specified dom element.
  12097. * @param element Defines the element to stop listening the inputs from
  12098. */
  12099. detachControl(element: Nullable<HTMLElement>): void;
  12100. /**
  12101. * Gets the class name of the current intput.
  12102. * @returns the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Get the friendly name associated with the input class.
  12107. * @returns the input friendly name
  12108. */
  12109. getSimpleName(): string;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. /**
  12114. * Manage the touch inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. */
  12117. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12118. /**
  12119. * Defines the camera the input is attached to.
  12120. */
  12121. camera: FreeCamera;
  12122. /**
  12123. * Defines the touch sensibility for rotation.
  12124. * The higher the faster.
  12125. */
  12126. touchAngularSensibility: number;
  12127. /**
  12128. * Defines the touch sensibility for move.
  12129. * The higher the faster.
  12130. */
  12131. touchMoveSensibility: number;
  12132. private _offsetX;
  12133. private _offsetY;
  12134. private _pointerPressed;
  12135. private _pointerInput;
  12136. private _observer;
  12137. private _onLostFocus;
  12138. /**
  12139. * Attach the input controls to a specific dom element to get the input from.
  12140. * @param element Defines the element the controls should be listened from
  12141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12142. */
  12143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12144. /**
  12145. * Detach the current controls from the specified dom element.
  12146. * @param element Defines the element to stop listening the inputs from
  12147. */
  12148. detachControl(element: Nullable<HTMLElement>): void;
  12149. /**
  12150. * Update the current camera state depending on the inputs that have been used this frame.
  12151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12152. */
  12153. checkInputs(): void;
  12154. /**
  12155. * Gets the class name of the current intput.
  12156. * @returns the class name
  12157. */
  12158. getClassName(): string;
  12159. /**
  12160. * Get the friendly name associated with the input class.
  12161. * @returns the input friendly name
  12162. */
  12163. getSimpleName(): string;
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Default Inputs manager for the FreeCamera.
  12169. * It groups all the default supported inputs for ease of use.
  12170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12171. */
  12172. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12173. /**
  12174. * @hidden
  12175. */
  12176. _mouseInput: Nullable<FreeCameraMouseInput>;
  12177. /**
  12178. * Instantiates a new FreeCameraInputsManager.
  12179. * @param camera Defines the camera the inputs belong to
  12180. */
  12181. constructor(camera: FreeCamera);
  12182. /**
  12183. * Add keyboard input support to the input manager.
  12184. * @returns the current input manager
  12185. */
  12186. addKeyboard(): FreeCameraInputsManager;
  12187. /**
  12188. * Add mouse input support to the input manager.
  12189. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12190. * @returns the current input manager
  12191. */
  12192. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12193. /**
  12194. * Removes the mouse input support from the manager
  12195. * @returns the current input manager
  12196. */
  12197. removeMouse(): FreeCameraInputsManager;
  12198. /**
  12199. * Add touch input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addTouch(): FreeCameraInputsManager;
  12203. /**
  12204. * Remove all attached input methods from a camera
  12205. */
  12206. clear(): void;
  12207. }
  12208. }
  12209. declare module BABYLON {
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. get angularSensibility(): number;
  12245. /**
  12246. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12247. * Higher values reduce sensitivity.
  12248. */
  12249. set angularSensibility(value: number);
  12250. /**
  12251. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12252. */
  12253. get keysUp(): number[];
  12254. set keysUp(value: number[]);
  12255. /**
  12256. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12257. */
  12258. get keysDown(): number[];
  12259. set keysDown(value: number[]);
  12260. /**
  12261. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12262. */
  12263. get keysLeft(): number[];
  12264. set keysLeft(value: number[]);
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12267. */
  12268. get keysRight(): number[];
  12269. set keysRight(value: number[]);
  12270. /**
  12271. * Event raised when the camera collide with a mesh in the scene.
  12272. */
  12273. onCollide: (collidedMesh: AbstractMesh) => void;
  12274. private _collider;
  12275. private _needMoveForGravity;
  12276. private _oldPosition;
  12277. private _diffPosition;
  12278. private _newPosition;
  12279. /** @hidden */
  12280. _localDirection: Vector3;
  12281. /** @hidden */
  12282. _transformedDirection: Vector3;
  12283. /**
  12284. * Instantiates a Free Camera.
  12285. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12286. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12288. * @param name Define the name of the camera in the scene
  12289. * @param position Define the start position of the camera in the scene
  12290. * @param scene Define the scene the camera belongs to
  12291. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12292. */
  12293. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12294. /**
  12295. * Attached controls to the current camera.
  12296. * @param element Defines the element the controls should be listened from
  12297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12298. */
  12299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12300. /**
  12301. * Detach the current controls from the camera.
  12302. * The camera will stop reacting to inputs.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. detachControl(element: HTMLElement): void;
  12306. private _collisionMask;
  12307. /**
  12308. * Define a collision mask to limit the list of object the camera can collide with
  12309. */
  12310. get collisionMask(): number;
  12311. set collisionMask(mask: number);
  12312. /** @hidden */
  12313. _collideWithWorld(displacement: Vector3): void;
  12314. private _onCollisionPositionChange;
  12315. /** @hidden */
  12316. _checkInputs(): void;
  12317. /** @hidden */
  12318. _decideIfNeedsToMove(): boolean;
  12319. /** @hidden */
  12320. _updatePosition(): void;
  12321. /**
  12322. * Destroy the camera and release the current resources hold by it.
  12323. */
  12324. dispose(): void;
  12325. /**
  12326. * Gets the current object class name.
  12327. * @return the class name
  12328. */
  12329. getClassName(): string;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. /**
  12334. * Represents a gamepad control stick position
  12335. */
  12336. export class StickValues {
  12337. /**
  12338. * The x component of the control stick
  12339. */
  12340. x: number;
  12341. /**
  12342. * The y component of the control stick
  12343. */
  12344. y: number;
  12345. /**
  12346. * Initializes the gamepad x and y control stick values
  12347. * @param x The x component of the gamepad control stick value
  12348. * @param y The y component of the gamepad control stick value
  12349. */
  12350. constructor(
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number,
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number);
  12359. }
  12360. /**
  12361. * An interface which manages callbacks for gamepad button changes
  12362. */
  12363. export interface GamepadButtonChanges {
  12364. /**
  12365. * Called when a gamepad has been changed
  12366. */
  12367. changed: boolean;
  12368. /**
  12369. * Called when a gamepad press event has been triggered
  12370. */
  12371. pressChanged: boolean;
  12372. /**
  12373. * Called when a touch event has been triggered
  12374. */
  12375. touchChanged: boolean;
  12376. /**
  12377. * Called when a value has changed
  12378. */
  12379. valueChanged: boolean;
  12380. }
  12381. /**
  12382. * Represents a gamepad
  12383. */
  12384. export class Gamepad {
  12385. /**
  12386. * The id of the gamepad
  12387. */
  12388. id: string;
  12389. /**
  12390. * The index of the gamepad
  12391. */
  12392. index: number;
  12393. /**
  12394. * The browser gamepad
  12395. */
  12396. browserGamepad: any;
  12397. /**
  12398. * Specifies what type of gamepad this represents
  12399. */
  12400. type: number;
  12401. private _leftStick;
  12402. private _rightStick;
  12403. /** @hidden */
  12404. _isConnected: boolean;
  12405. private _leftStickAxisX;
  12406. private _leftStickAxisY;
  12407. private _rightStickAxisX;
  12408. private _rightStickAxisY;
  12409. /**
  12410. * Triggered when the left control stick has been changed
  12411. */
  12412. private _onleftstickchanged;
  12413. /**
  12414. * Triggered when the right control stick has been changed
  12415. */
  12416. private _onrightstickchanged;
  12417. /**
  12418. * Represents a gamepad controller
  12419. */
  12420. static GAMEPAD: number;
  12421. /**
  12422. * Represents a generic controller
  12423. */
  12424. static GENERIC: number;
  12425. /**
  12426. * Represents an XBox controller
  12427. */
  12428. static XBOX: number;
  12429. /**
  12430. * Represents a pose-enabled controller
  12431. */
  12432. static POSE_ENABLED: number;
  12433. /**
  12434. * Represents an Dual Shock controller
  12435. */
  12436. static DUALSHOCK: number;
  12437. /**
  12438. * Specifies whether the left control stick should be Y-inverted
  12439. */
  12440. protected _invertLeftStickY: boolean;
  12441. /**
  12442. * Specifies if the gamepad has been connected
  12443. */
  12444. get isConnected(): boolean;
  12445. /**
  12446. * Initializes the gamepad
  12447. * @param id The id of the gamepad
  12448. * @param index The index of the gamepad
  12449. * @param browserGamepad The browser gamepad
  12450. * @param leftStickX The x component of the left joystick
  12451. * @param leftStickY The y component of the left joystick
  12452. * @param rightStickX The x component of the right joystick
  12453. * @param rightStickY The y component of the right joystick
  12454. */
  12455. constructor(
  12456. /**
  12457. * The id of the gamepad
  12458. */
  12459. id: string,
  12460. /**
  12461. * The index of the gamepad
  12462. */
  12463. index: number,
  12464. /**
  12465. * The browser gamepad
  12466. */
  12467. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12468. /**
  12469. * Callback triggered when the left joystick has changed
  12470. * @param callback
  12471. */
  12472. onleftstickchanged(callback: (values: StickValues) => void): void;
  12473. /**
  12474. * Callback triggered when the right joystick has changed
  12475. * @param callback
  12476. */
  12477. onrightstickchanged(callback: (values: StickValues) => void): void;
  12478. /**
  12479. * Gets the left joystick
  12480. */
  12481. get leftStick(): StickValues;
  12482. /**
  12483. * Sets the left joystick values
  12484. */
  12485. set leftStick(newValues: StickValues);
  12486. /**
  12487. * Gets the right joystick
  12488. */
  12489. get rightStick(): StickValues;
  12490. /**
  12491. * Sets the right joystick value
  12492. */
  12493. set rightStick(newValues: StickValues);
  12494. /**
  12495. * Updates the gamepad joystick positions
  12496. */
  12497. update(): void;
  12498. /**
  12499. * Disposes the gamepad
  12500. */
  12501. dispose(): void;
  12502. }
  12503. /**
  12504. * Represents a generic gamepad
  12505. */
  12506. export class GenericPad extends Gamepad {
  12507. private _buttons;
  12508. private _onbuttondown;
  12509. private _onbuttonup;
  12510. /**
  12511. * Observable triggered when a button has been pressed
  12512. */
  12513. onButtonDownObservable: Observable<number>;
  12514. /**
  12515. * Observable triggered when a button has been released
  12516. */
  12517. onButtonUpObservable: Observable<number>;
  12518. /**
  12519. * Callback triggered when a button has been pressed
  12520. * @param callback Called when a button has been pressed
  12521. */
  12522. onbuttondown(callback: (buttonPressed: number) => void): void;
  12523. /**
  12524. * Callback triggered when a button has been released
  12525. * @param callback Called when a button has been released
  12526. */
  12527. onbuttonup(callback: (buttonReleased: number) => void): void;
  12528. /**
  12529. * Initializes the generic gamepad
  12530. * @param id The id of the generic gamepad
  12531. * @param index The index of the generic gamepad
  12532. * @param browserGamepad The browser gamepad
  12533. */
  12534. constructor(id: string, index: number, browserGamepad: any);
  12535. private _setButtonValue;
  12536. /**
  12537. * Updates the generic gamepad
  12538. */
  12539. update(): void;
  12540. /**
  12541. * Disposes the generic gamepad
  12542. */
  12543. dispose(): void;
  12544. }
  12545. }
  12546. declare module BABYLON {
  12547. interface Engine {
  12548. /**
  12549. * Creates a raw texture
  12550. * @param data defines the data to store in the texture
  12551. * @param width defines the width of the texture
  12552. * @param height defines the height of the texture
  12553. * @param format defines the format of the data
  12554. * @param generateMipMaps defines if the engine should generate the mip levels
  12555. * @param invertY defines if data must be stored with Y axis inverted
  12556. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12557. * @param compression defines the compression used (null by default)
  12558. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12559. * @returns the raw texture inside an InternalTexture
  12560. */
  12561. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12562. /**
  12563. * Update a raw texture
  12564. * @param texture defines the texture to update
  12565. * @param data defines the data to store in the texture
  12566. * @param format defines the format of the data
  12567. * @param invertY defines if data must be stored with Y axis inverted
  12568. */
  12569. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12570. /**
  12571. * Update a raw texture
  12572. * @param texture defines the texture to update
  12573. * @param data defines the data to store in the texture
  12574. * @param format defines the format of the data
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12578. */
  12579. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12580. /**
  12581. * Creates a new raw cube texture
  12582. * @param data defines the array of data to use to create each face
  12583. * @param size defines the size of the textures
  12584. * @param format defines the format of the data
  12585. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12586. * @param generateMipMaps defines if the engine should generate the mip levels
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12589. * @param compression defines the compression used (null by default)
  12590. * @returns the cube texture as an InternalTexture
  12591. */
  12592. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12593. /**
  12594. * Update a raw cube texture
  12595. * @param texture defines the texture to udpdate
  12596. * @param data defines the data to store
  12597. * @param format defines the data format
  12598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. */
  12601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12602. /**
  12603. * Update a raw cube texture
  12604. * @param texture defines the texture to udpdate
  12605. * @param data defines the data to store
  12606. * @param format defines the data format
  12607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12608. * @param invertY defines if data must be stored with Y axis inverted
  12609. * @param compression defines the compression used (null by default)
  12610. */
  12611. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12612. /**
  12613. * Update a raw cube texture
  12614. * @param texture defines the texture to udpdate
  12615. * @param data defines the data to store
  12616. * @param format defines the data format
  12617. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param level defines which level of the texture to update
  12621. */
  12622. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12623. /**
  12624. * Creates a new raw cube texture from a specified url
  12625. * @param url defines the url where the data is located
  12626. * @param scene defines the current scene
  12627. * @param size defines the size of the textures
  12628. * @param format defines the format of the data
  12629. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12630. * @param noMipmap defines if the engine should avoid generating the mip levels
  12631. * @param callback defines a callback used to extract texture data from loaded data
  12632. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12633. * @param onLoad defines a callback called when texture is loaded
  12634. * @param onError defines a callback called if there is an error
  12635. * @returns the cube texture as an InternalTexture
  12636. */
  12637. 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;
  12638. /**
  12639. * Creates a new raw cube texture from a specified url
  12640. * @param url defines the url where the data is located
  12641. * @param scene defines the current scene
  12642. * @param size defines the size of the textures
  12643. * @param format defines the format of the data
  12644. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12645. * @param noMipmap defines if the engine should avoid generating the mip levels
  12646. * @param callback defines a callback used to extract texture data from loaded data
  12647. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12648. * @param onLoad defines a callback called when texture is loaded
  12649. * @param onError defines a callback called if there is an error
  12650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @returns the cube texture as an InternalTexture
  12653. */
  12654. 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;
  12655. /**
  12656. * Creates a new raw 3D texture
  12657. * @param data defines the data used to create the texture
  12658. * @param width defines the width of the texture
  12659. * @param height defines the height of the texture
  12660. * @param depth defines the depth of the texture
  12661. * @param format defines the format of the texture
  12662. * @param generateMipMaps defines if the engine must generate mip levels
  12663. * @param invertY defines if data must be stored with Y axis inverted
  12664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12665. * @param compression defines the compressed used (can be null)
  12666. * @param textureType defines the compressed used (can be null)
  12667. * @returns a new raw 3D texture (stored in an InternalTexture)
  12668. */
  12669. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12670. /**
  12671. * Update a raw 3D texture
  12672. * @param texture defines the texture to update
  12673. * @param data defines the data to store
  12674. * @param format defines the data format
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. */
  12677. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12678. /**
  12679. * Update a raw 3D texture
  12680. * @param texture defines the texture to update
  12681. * @param data defines the data to store
  12682. * @param format defines the data format
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. * @param compression defines the used compression (can be null)
  12685. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12686. */
  12687. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12688. /**
  12689. * Creates a new raw 2D array texture
  12690. * @param data defines the data used to create the texture
  12691. * @param width defines the width of the texture
  12692. * @param height defines the height of the texture
  12693. * @param depth defines the number of layers of the texture
  12694. * @param format defines the format of the texture
  12695. * @param generateMipMaps defines if the engine must generate mip levels
  12696. * @param invertY defines if data must be stored with Y axis inverted
  12697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12698. * @param compression defines the compressed used (can be null)
  12699. * @param textureType defines the compressed used (can be null)
  12700. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12701. */
  12702. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12703. /**
  12704. * Update a raw 2D array texture
  12705. * @param texture defines the texture to update
  12706. * @param data defines the data to store
  12707. * @param format defines the data format
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. */
  12710. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12711. /**
  12712. * Update a raw 2D array texture
  12713. * @param texture defines the texture to update
  12714. * @param data defines the data to store
  12715. * @param format defines the data format
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the used compression (can be null)
  12718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12719. */
  12720. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12721. }
  12722. }
  12723. declare module BABYLON {
  12724. /**
  12725. * Raw texture can help creating a texture directly from an array of data.
  12726. * This can be super useful if you either get the data from an uncompressed source or
  12727. * if you wish to create your texture pixel by pixel.
  12728. */
  12729. export class RawTexture extends Texture {
  12730. /**
  12731. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12732. */
  12733. format: number;
  12734. private _engine;
  12735. /**
  12736. * Instantiates a new RawTexture.
  12737. * Raw texture can help creating a texture directly from an array of data.
  12738. * This can be super useful if you either get the data from an uncompressed source or
  12739. * if you wish to create your texture pixel by pixel.
  12740. * @param data define the array of data to use to create the texture
  12741. * @param width define the width of the texture
  12742. * @param height define the height of the texture
  12743. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12744. * @param scene define the scene the texture belongs to
  12745. * @param generateMipMaps define whether mip maps should be generated or not
  12746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12748. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12749. */
  12750. constructor(data: ArrayBufferView, width: number, height: number,
  12751. /**
  12752. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12753. */
  12754. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12755. /**
  12756. * Updates the texture underlying data.
  12757. * @param data Define the new data of the texture
  12758. */
  12759. update(data: ArrayBufferView): void;
  12760. /**
  12761. * Creates a luminance texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @returns the luminance texture
  12770. */
  12771. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12772. /**
  12773. * Creates a luminance alpha texture from some data.
  12774. * @param data Define the texture data
  12775. * @param width Define the width of the texture
  12776. * @param height Define the height of the texture
  12777. * @param scene Define the scene the texture belongs to
  12778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12781. * @returns the luminance alpha texture
  12782. */
  12783. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12784. /**
  12785. * Creates an alpha texture from some data.
  12786. * @param data Define the texture data
  12787. * @param width Define the width of the texture
  12788. * @param height Define the height of the texture
  12789. * @param scene Define the scene the texture belongs to
  12790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12793. * @returns the alpha texture
  12794. */
  12795. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12796. /**
  12797. * Creates a RGB texture from some data.
  12798. * @param data Define the texture data
  12799. * @param width Define the width of the texture
  12800. * @param height Define the height of the texture
  12801. * @param scene Define the scene the texture belongs to
  12802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12805. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12806. * @returns the RGB alpha texture
  12807. */
  12808. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12809. /**
  12810. * Creates a RGBA texture from some data.
  12811. * @param data Define the texture data
  12812. * @param width Define the width of the texture
  12813. * @param height Define the height of the texture
  12814. * @param scene Define the scene the texture belongs to
  12815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12819. * @returns the RGBA texture
  12820. */
  12821. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12822. /**
  12823. * Creates a R texture from some data.
  12824. * @param data Define the texture data
  12825. * @param width Define the width of the texture
  12826. * @param height Define the height of the texture
  12827. * @param scene Define the scene the texture belongs to
  12828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12831. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12832. * @returns the R texture
  12833. */
  12834. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12835. }
  12836. }
  12837. declare module BABYLON {
  12838. /**
  12839. * Interface for the size containing width and height
  12840. */
  12841. export interface ISize {
  12842. /**
  12843. * Width
  12844. */
  12845. width: number;
  12846. /**
  12847. * Heighht
  12848. */
  12849. height: number;
  12850. }
  12851. /**
  12852. * Size containing widht and height
  12853. */
  12854. export class Size implements ISize {
  12855. /**
  12856. * Width
  12857. */
  12858. width: number;
  12859. /**
  12860. * Height
  12861. */
  12862. height: number;
  12863. /**
  12864. * Creates a Size object from the given width and height (floats).
  12865. * @param width width of the new size
  12866. * @param height height of the new size
  12867. */
  12868. constructor(width: number, height: number);
  12869. /**
  12870. * Returns a string with the Size width and height
  12871. * @returns a string with the Size width and height
  12872. */
  12873. toString(): string;
  12874. /**
  12875. * "Size"
  12876. * @returns the string "Size"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * Returns the Size hash code.
  12881. * @returns a hash code for a unique width and height
  12882. */
  12883. getHashCode(): number;
  12884. /**
  12885. * Updates the current size from the given one.
  12886. * @param src the given size
  12887. */
  12888. copyFrom(src: Size): void;
  12889. /**
  12890. * Updates in place the current Size from the given floats.
  12891. * @param width width of the new size
  12892. * @param height height of the new size
  12893. * @returns the updated Size.
  12894. */
  12895. copyFromFloats(width: number, height: number): Size;
  12896. /**
  12897. * Updates in place the current Size from the given floats.
  12898. * @param width width to set
  12899. * @param height height to set
  12900. * @returns the updated Size.
  12901. */
  12902. set(width: number, height: number): Size;
  12903. /**
  12904. * Multiplies the width and height by numbers
  12905. * @param w factor to multiple the width by
  12906. * @param h factor to multiple the height by
  12907. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12908. */
  12909. multiplyByFloats(w: number, h: number): Size;
  12910. /**
  12911. * Clones the size
  12912. * @returns a new Size copied from the given one.
  12913. */
  12914. clone(): Size;
  12915. /**
  12916. * True if the current Size and the given one width and height are strictly equal.
  12917. * @param other the other size to compare against
  12918. * @returns True if the current Size and the given one width and height are strictly equal.
  12919. */
  12920. equals(other: Size): boolean;
  12921. /**
  12922. * The surface of the Size : width * height (float).
  12923. */
  12924. get surface(): number;
  12925. /**
  12926. * Create a new size of zero
  12927. * @returns a new Size set to (0.0, 0.0)
  12928. */
  12929. static Zero(): Size;
  12930. /**
  12931. * Sums the width and height of two sizes
  12932. * @param otherSize size to add to this size
  12933. * @returns a new Size set as the addition result of the current Size and the given one.
  12934. */
  12935. add(otherSize: Size): Size;
  12936. /**
  12937. * Subtracts the width and height of two
  12938. * @param otherSize size to subtract to this size
  12939. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12940. */
  12941. subtract(otherSize: Size): Size;
  12942. /**
  12943. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12944. * @param start starting size to lerp between
  12945. * @param end end size to lerp between
  12946. * @param amount amount to lerp between the start and end values
  12947. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12948. */
  12949. static Lerp(start: Size, end: Size, amount: number): Size;
  12950. }
  12951. }
  12952. declare module BABYLON {
  12953. /**
  12954. * Defines a runtime animation
  12955. */
  12956. export class RuntimeAnimation {
  12957. private _events;
  12958. /**
  12959. * The current frame of the runtime animation
  12960. */
  12961. private _currentFrame;
  12962. /**
  12963. * The animation used by the runtime animation
  12964. */
  12965. private _animation;
  12966. /**
  12967. * The target of the runtime animation
  12968. */
  12969. private _target;
  12970. /**
  12971. * The initiating animatable
  12972. */
  12973. private _host;
  12974. /**
  12975. * The original value of the runtime animation
  12976. */
  12977. private _originalValue;
  12978. /**
  12979. * The original blend value of the runtime animation
  12980. */
  12981. private _originalBlendValue;
  12982. /**
  12983. * The offsets cache of the runtime animation
  12984. */
  12985. private _offsetsCache;
  12986. /**
  12987. * The high limits cache of the runtime animation
  12988. */
  12989. private _highLimitsCache;
  12990. /**
  12991. * Specifies if the runtime animation has been stopped
  12992. */
  12993. private _stopped;
  12994. /**
  12995. * The blending factor of the runtime animation
  12996. */
  12997. private _blendingFactor;
  12998. /**
  12999. * The BabylonJS scene
  13000. */
  13001. private _scene;
  13002. /**
  13003. * The current value of the runtime animation
  13004. */
  13005. private _currentValue;
  13006. /** @hidden */
  13007. _animationState: _IAnimationState;
  13008. /**
  13009. * The active target of the runtime animation
  13010. */
  13011. private _activeTargets;
  13012. private _currentActiveTarget;
  13013. private _directTarget;
  13014. /**
  13015. * The target path of the runtime animation
  13016. */
  13017. private _targetPath;
  13018. /**
  13019. * The weight of the runtime animation
  13020. */
  13021. private _weight;
  13022. /**
  13023. * The ratio offset of the runtime animation
  13024. */
  13025. private _ratioOffset;
  13026. /**
  13027. * The previous delay of the runtime animation
  13028. */
  13029. private _previousDelay;
  13030. /**
  13031. * The previous ratio of the runtime animation
  13032. */
  13033. private _previousRatio;
  13034. private _enableBlending;
  13035. private _keys;
  13036. private _minFrame;
  13037. private _maxFrame;
  13038. private _minValue;
  13039. private _maxValue;
  13040. private _targetIsArray;
  13041. /**
  13042. * Gets the current frame of the runtime animation
  13043. */
  13044. get currentFrame(): number;
  13045. /**
  13046. * Gets the weight of the runtime animation
  13047. */
  13048. get weight(): number;
  13049. /**
  13050. * Gets the current value of the runtime animation
  13051. */
  13052. get currentValue(): any;
  13053. /**
  13054. * Gets the target path of the runtime animation
  13055. */
  13056. get targetPath(): string;
  13057. /**
  13058. * Gets the actual target of the runtime animation
  13059. */
  13060. get target(): any;
  13061. /** @hidden */
  13062. _onLoop: () => void;
  13063. /**
  13064. * Create a new RuntimeAnimation object
  13065. * @param target defines the target of the animation
  13066. * @param animation defines the source animation object
  13067. * @param scene defines the hosting scene
  13068. * @param host defines the initiating Animatable
  13069. */
  13070. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13071. private _preparePath;
  13072. /**
  13073. * Gets the animation from the runtime animation
  13074. */
  13075. get animation(): Animation;
  13076. /**
  13077. * Resets the runtime animation to the beginning
  13078. * @param restoreOriginal defines whether to restore the target property to the original value
  13079. */
  13080. reset(restoreOriginal?: boolean): void;
  13081. /**
  13082. * Specifies if the runtime animation is stopped
  13083. * @returns Boolean specifying if the runtime animation is stopped
  13084. */
  13085. isStopped(): boolean;
  13086. /**
  13087. * Disposes of the runtime animation
  13088. */
  13089. dispose(): void;
  13090. /**
  13091. * Apply the interpolated value to the target
  13092. * @param currentValue defines the value computed by the animation
  13093. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13094. */
  13095. setValue(currentValue: any, weight: number): void;
  13096. private _getOriginalValues;
  13097. private _setValue;
  13098. /**
  13099. * Gets the loop pmode of the runtime animation
  13100. * @returns Loop Mode
  13101. */
  13102. private _getCorrectLoopMode;
  13103. /**
  13104. * Move the current animation to a given frame
  13105. * @param frame defines the frame to move to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * @hidden Internal use only
  13110. */
  13111. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13112. /**
  13113. * Execute the current animation
  13114. * @param delay defines the delay to add to the current frame
  13115. * @param from defines the lower bound of the animation range
  13116. * @param to defines the upper bound of the animation range
  13117. * @param loop defines if the current animation must loop
  13118. * @param speedRatio defines the current speed ratio
  13119. * @param weight defines the weight of the animation (default is -1 so no weight)
  13120. * @param onLoop optional callback called when animation loops
  13121. * @returns a boolean indicating if the animation is running
  13122. */
  13123. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13124. }
  13125. }
  13126. declare module BABYLON {
  13127. /**
  13128. * Class used to store an actual running animation
  13129. */
  13130. export class Animatable {
  13131. /** defines the target object */
  13132. target: any;
  13133. /** defines the starting frame number (default is 0) */
  13134. fromFrame: number;
  13135. /** defines the ending frame number (default is 100) */
  13136. toFrame: number;
  13137. /** defines if the animation must loop (default is false) */
  13138. loopAnimation: boolean;
  13139. /** defines a callback to call when animation ends if it is not looping */
  13140. onAnimationEnd?: (() => void) | null | undefined;
  13141. /** defines a callback to call when animation loops */
  13142. onAnimationLoop?: (() => void) | null | undefined;
  13143. private _localDelayOffset;
  13144. private _pausedDelay;
  13145. private _runtimeAnimations;
  13146. private _paused;
  13147. private _scene;
  13148. private _speedRatio;
  13149. private _weight;
  13150. private _syncRoot;
  13151. /**
  13152. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13153. * This will only apply for non looping animation (default is true)
  13154. */
  13155. disposeOnEnd: boolean;
  13156. /**
  13157. * Gets a boolean indicating if the animation has started
  13158. */
  13159. animationStarted: boolean;
  13160. /**
  13161. * Observer raised when the animation ends
  13162. */
  13163. onAnimationEndObservable: Observable<Animatable>;
  13164. /**
  13165. * Observer raised when the animation loops
  13166. */
  13167. onAnimationLoopObservable: Observable<Animatable>;
  13168. /**
  13169. * Gets the root Animatable used to synchronize and normalize animations
  13170. */
  13171. get syncRoot(): Nullable<Animatable>;
  13172. /**
  13173. * Gets the current frame of the first RuntimeAnimation
  13174. * Used to synchronize Animatables
  13175. */
  13176. get masterFrame(): number;
  13177. /**
  13178. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13179. */
  13180. get weight(): number;
  13181. set weight(value: number);
  13182. /**
  13183. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13184. */
  13185. get speedRatio(): number;
  13186. set speedRatio(value: number);
  13187. /**
  13188. * Creates a new Animatable
  13189. * @param scene defines the hosting scene
  13190. * @param target defines the target object
  13191. * @param fromFrame defines the starting frame number (default is 0)
  13192. * @param toFrame defines the ending frame number (default is 100)
  13193. * @param loopAnimation defines if the animation must loop (default is false)
  13194. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13195. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13196. * @param animations defines a group of animation to add to the new Animatable
  13197. * @param onAnimationLoop defines a callback to call when animation loops
  13198. */
  13199. constructor(scene: Scene,
  13200. /** defines the target object */
  13201. target: any,
  13202. /** defines the starting frame number (default is 0) */
  13203. fromFrame?: number,
  13204. /** defines the ending frame number (default is 100) */
  13205. toFrame?: number,
  13206. /** defines if the animation must loop (default is false) */
  13207. loopAnimation?: boolean, speedRatio?: number,
  13208. /** defines a callback to call when animation ends if it is not looping */
  13209. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13210. /** defines a callback to call when animation loops */
  13211. onAnimationLoop?: (() => void) | null | undefined);
  13212. /**
  13213. * Synchronize and normalize current Animatable with a source Animatable
  13214. * This is useful when using animation weights and when animations are not of the same length
  13215. * @param root defines the root Animatable to synchronize with
  13216. * @returns the current Animatable
  13217. */
  13218. syncWith(root: Animatable): Animatable;
  13219. /**
  13220. * Gets the list of runtime animations
  13221. * @returns an array of RuntimeAnimation
  13222. */
  13223. getAnimations(): RuntimeAnimation[];
  13224. /**
  13225. * Adds more animations to the current animatable
  13226. * @param target defines the target of the animations
  13227. * @param animations defines the new animations to add
  13228. */
  13229. appendAnimations(target: any, animations: Animation[]): void;
  13230. /**
  13231. * Gets the source animation for a specific property
  13232. * @param property defines the propertyu to look for
  13233. * @returns null or the source animation for the given property
  13234. */
  13235. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13236. /**
  13237. * Gets the runtime animation for a specific property
  13238. * @param property defines the propertyu to look for
  13239. * @returns null or the runtime animation for the given property
  13240. */
  13241. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13242. /**
  13243. * Resets the animatable to its original state
  13244. */
  13245. reset(): void;
  13246. /**
  13247. * Allows the animatable to blend with current running animations
  13248. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13249. * @param blendingSpeed defines the blending speed to use
  13250. */
  13251. enableBlending(blendingSpeed: number): void;
  13252. /**
  13253. * Disable animation blending
  13254. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13255. */
  13256. disableBlending(): void;
  13257. /**
  13258. * Jump directly to a given frame
  13259. * @param frame defines the frame to jump to
  13260. */
  13261. goToFrame(frame: number): void;
  13262. /**
  13263. * Pause the animation
  13264. */
  13265. pause(): void;
  13266. /**
  13267. * Restart the animation
  13268. */
  13269. restart(): void;
  13270. private _raiseOnAnimationEnd;
  13271. /**
  13272. * Stop and delete the current animation
  13273. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13274. * @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)
  13275. */
  13276. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13277. /**
  13278. * Wait asynchronously for the animation to end
  13279. * @returns a promise which will be fullfilled when the animation ends
  13280. */
  13281. waitAsync(): Promise<Animatable>;
  13282. /** @hidden */
  13283. _animate(delay: number): boolean;
  13284. }
  13285. interface Scene {
  13286. /** @hidden */
  13287. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13288. /** @hidden */
  13289. _processLateAnimationBindingsForMatrices(holder: {
  13290. totalWeight: number;
  13291. animations: RuntimeAnimation[];
  13292. originalValue: Matrix;
  13293. }): any;
  13294. /** @hidden */
  13295. _processLateAnimationBindingsForQuaternions(holder: {
  13296. totalWeight: number;
  13297. animations: RuntimeAnimation[];
  13298. originalValue: Quaternion;
  13299. }, refQuaternion: Quaternion): Quaternion;
  13300. /** @hidden */
  13301. _processLateAnimationBindings(): void;
  13302. /**
  13303. * Will start the animation sequence of a given target
  13304. * @param target defines the target
  13305. * @param from defines from which frame should animation start
  13306. * @param to defines until which frame should animation run.
  13307. * @param weight defines the weight to apply to the animation (1.0 by default)
  13308. * @param loop defines if the animation loops
  13309. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13310. * @param onAnimationEnd defines the function to be executed when the animation ends
  13311. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13312. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13313. * @param onAnimationLoop defines the callback to call when an animation loops
  13314. * @returns the animatable object created for this animation
  13315. */
  13316. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13317. /**
  13318. * Will start the animation sequence of a given target
  13319. * @param target defines the target
  13320. * @param from defines from which frame should animation start
  13321. * @param to defines until which frame should animation run.
  13322. * @param loop defines if the animation loops
  13323. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13324. * @param onAnimationEnd defines the function to be executed when the animation ends
  13325. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13326. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13327. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13328. * @param onAnimationLoop defines the callback to call when an animation loops
  13329. * @returns the animatable object created for this animation
  13330. */
  13331. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13332. /**
  13333. * Will start the animation sequence of a given target and its hierarchy
  13334. * @param target defines the target
  13335. * @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.
  13336. * @param from defines from which frame should animation start
  13337. * @param to defines until which frame should animation run.
  13338. * @param loop defines if the animation loops
  13339. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13340. * @param onAnimationEnd defines the function to be executed when the animation ends
  13341. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13342. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13343. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13344. * @param onAnimationLoop defines the callback to call when an animation loops
  13345. * @returns the list of created animatables
  13346. */
  13347. 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[];
  13348. /**
  13349. * Begin a new animation on a given node
  13350. * @param target defines the target where the animation will take place
  13351. * @param animations defines the list of animations to start
  13352. * @param from defines the initial value
  13353. * @param to defines the final value
  13354. * @param loop defines if you want animation to loop (off by default)
  13355. * @param speedRatio defines the speed ratio to apply to all animations
  13356. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13357. * @param onAnimationLoop defines the callback to call when an animation loops
  13358. * @returns the list of created animatables
  13359. */
  13360. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13361. /**
  13362. * Begin a new animation on a given node and its hierarchy
  13363. * @param target defines the root node where the animation will take place
  13364. * @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.
  13365. * @param animations defines the list of animations to start
  13366. * @param from defines the initial value
  13367. * @param to defines the final value
  13368. * @param loop defines if you want animation to loop (off by default)
  13369. * @param speedRatio defines the speed ratio to apply to all animations
  13370. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13371. * @param onAnimationLoop defines the callback to call when an animation loops
  13372. * @returns the list of animatables created for all nodes
  13373. */
  13374. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13375. /**
  13376. * Gets the animatable associated with a specific target
  13377. * @param target defines the target of the animatable
  13378. * @returns the required animatable if found
  13379. */
  13380. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13381. /**
  13382. * Gets all animatables associated with a given target
  13383. * @param target defines the target to look animatables for
  13384. * @returns an array of Animatables
  13385. */
  13386. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13387. /**
  13388. * Stops and removes all animations that have been applied to the scene
  13389. */
  13390. stopAllAnimations(): void;
  13391. /**
  13392. * Gets the current delta time used by animation engine
  13393. */
  13394. deltaTime: number;
  13395. }
  13396. interface Bone {
  13397. /**
  13398. * Copy an animation range from another bone
  13399. * @param source defines the source bone
  13400. * @param rangeName defines the range name to copy
  13401. * @param frameOffset defines the frame offset
  13402. * @param rescaleAsRequired defines if rescaling must be applied if required
  13403. * @param skelDimensionsRatio defines the scaling ratio
  13404. * @returns true if operation was successful
  13405. */
  13406. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * Class used to override all child animations of a given target
  13412. */
  13413. export class AnimationPropertiesOverride {
  13414. /**
  13415. * Gets or sets a value indicating if animation blending must be used
  13416. */
  13417. enableBlending: boolean;
  13418. /**
  13419. * Gets or sets the blending speed to use when enableBlending is true
  13420. */
  13421. blendingSpeed: number;
  13422. /**
  13423. * Gets or sets the default loop mode to use
  13424. */
  13425. loopMode: number;
  13426. }
  13427. }
  13428. declare module BABYLON {
  13429. /**
  13430. * Class used to handle skinning animations
  13431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13432. */
  13433. export class Skeleton implements IAnimatable {
  13434. /** defines the skeleton name */
  13435. name: string;
  13436. /** defines the skeleton Id */
  13437. id: string;
  13438. /**
  13439. * Defines the list of child bones
  13440. */
  13441. bones: Bone[];
  13442. /**
  13443. * Defines an estimate of the dimension of the skeleton at rest
  13444. */
  13445. dimensionsAtRest: Vector3;
  13446. /**
  13447. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13448. */
  13449. needInitialSkinMatrix: boolean;
  13450. /**
  13451. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13452. */
  13453. overrideMesh: Nullable<AbstractMesh>;
  13454. /**
  13455. * Gets the list of animations attached to this skeleton
  13456. */
  13457. animations: Array<Animation>;
  13458. private _scene;
  13459. private _isDirty;
  13460. private _transformMatrices;
  13461. private _transformMatrixTexture;
  13462. private _meshesWithPoseMatrix;
  13463. private _animatables;
  13464. private _identity;
  13465. private _synchronizedWithMesh;
  13466. private _ranges;
  13467. private _lastAbsoluteTransformsUpdateId;
  13468. private _canUseTextureForBones;
  13469. private _uniqueId;
  13470. /** @hidden */
  13471. _numBonesWithLinkedTransformNode: number;
  13472. /** @hidden */
  13473. _hasWaitingData: Nullable<boolean>;
  13474. /**
  13475. * Specifies if the skeleton should be serialized
  13476. */
  13477. doNotSerialize: boolean;
  13478. private _useTextureToStoreBoneMatrices;
  13479. /**
  13480. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13481. * Please note that this option is not available if the hardware does not support it
  13482. */
  13483. get useTextureToStoreBoneMatrices(): boolean;
  13484. set useTextureToStoreBoneMatrices(value: boolean);
  13485. private _animationPropertiesOverride;
  13486. /**
  13487. * Gets or sets the animation properties override
  13488. */
  13489. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13490. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13491. /**
  13492. * List of inspectable custom properties (used by the Inspector)
  13493. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13494. */
  13495. inspectableCustomProperties: IInspectable[];
  13496. /**
  13497. * An observable triggered before computing the skeleton's matrices
  13498. */
  13499. onBeforeComputeObservable: Observable<Skeleton>;
  13500. /**
  13501. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13502. */
  13503. get isUsingTextureForMatrices(): boolean;
  13504. /**
  13505. * Gets the unique ID of this skeleton
  13506. */
  13507. get uniqueId(): number;
  13508. /**
  13509. * Creates a new skeleton
  13510. * @param name defines the skeleton name
  13511. * @param id defines the skeleton Id
  13512. * @param scene defines the hosting scene
  13513. */
  13514. constructor(
  13515. /** defines the skeleton name */
  13516. name: string,
  13517. /** defines the skeleton Id */
  13518. id: string, scene: Scene);
  13519. /**
  13520. * Gets the current object class name.
  13521. * @return the class name
  13522. */
  13523. getClassName(): string;
  13524. /**
  13525. * Returns an array containing the root bones
  13526. * @returns an array containing the root bones
  13527. */
  13528. getChildren(): Array<Bone>;
  13529. /**
  13530. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13531. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13532. * @returns a Float32Array containing matrices data
  13533. */
  13534. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13535. /**
  13536. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13537. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13538. * @returns a raw texture containing the data
  13539. */
  13540. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13541. /**
  13542. * Gets the current hosting scene
  13543. * @returns a scene object
  13544. */
  13545. getScene(): Scene;
  13546. /**
  13547. * Gets a string representing the current skeleton data
  13548. * @param fullDetails defines a boolean indicating if we want a verbose version
  13549. * @returns a string representing the current skeleton data
  13550. */
  13551. toString(fullDetails?: boolean): string;
  13552. /**
  13553. * Get bone's index searching by name
  13554. * @param name defines bone's name to search for
  13555. * @return the indice of the bone. Returns -1 if not found
  13556. */
  13557. getBoneIndexByName(name: string): number;
  13558. /**
  13559. * Creater a new animation range
  13560. * @param name defines the name of the range
  13561. * @param from defines the start key
  13562. * @param to defines the end key
  13563. */
  13564. createAnimationRange(name: string, from: number, to: number): void;
  13565. /**
  13566. * Delete a specific animation range
  13567. * @param name defines the name of the range
  13568. * @param deleteFrames defines if frames must be removed as well
  13569. */
  13570. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13571. /**
  13572. * Gets a specific animation range
  13573. * @param name defines the name of the range to look for
  13574. * @returns the requested animation range or null if not found
  13575. */
  13576. getAnimationRange(name: string): Nullable<AnimationRange>;
  13577. /**
  13578. * Gets the list of all animation ranges defined on this skeleton
  13579. * @returns an array
  13580. */
  13581. getAnimationRanges(): Nullable<AnimationRange>[];
  13582. /**
  13583. * Copy animation range from a source skeleton.
  13584. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13585. * @param source defines the source skeleton
  13586. * @param name defines the name of the range to copy
  13587. * @param rescaleAsRequired defines if rescaling must be applied if required
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13591. /**
  13592. * Forces the skeleton to go to rest pose
  13593. */
  13594. returnToRest(): void;
  13595. private _getHighestAnimationFrame;
  13596. /**
  13597. * Begin a specific animation range
  13598. * @param name defines the name of the range to start
  13599. * @param loop defines if looping must be turned on (false by default)
  13600. * @param speedRatio defines the speed ratio to apply (1 by default)
  13601. * @param onAnimationEnd defines a callback which will be called when animation will end
  13602. * @returns a new animatable
  13603. */
  13604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13605. /** @hidden */
  13606. _markAsDirty(): void;
  13607. /** @hidden */
  13608. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13609. /** @hidden */
  13610. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13611. private _computeTransformMatrices;
  13612. /**
  13613. * Build all resources required to render a skeleton
  13614. */
  13615. prepare(): void;
  13616. /**
  13617. * Gets the list of animatables currently running for this skeleton
  13618. * @returns an array of animatables
  13619. */
  13620. getAnimatables(): IAnimatable[];
  13621. /**
  13622. * Clone the current skeleton
  13623. * @param name defines the name of the new skeleton
  13624. * @param id defines the id of the new skeleton
  13625. * @returns the new skeleton
  13626. */
  13627. clone(name: string, id?: string): Skeleton;
  13628. /**
  13629. * Enable animation blending for this skeleton
  13630. * @param blendingSpeed defines the blending speed to apply
  13631. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13632. */
  13633. enableBlending(blendingSpeed?: number): void;
  13634. /**
  13635. * Releases all resources associated with the current skeleton
  13636. */
  13637. dispose(): void;
  13638. /**
  13639. * Serialize the skeleton in a JSON object
  13640. * @returns a JSON object
  13641. */
  13642. serialize(): any;
  13643. /**
  13644. * Creates a new skeleton from serialized data
  13645. * @param parsedSkeleton defines the serialized data
  13646. * @param scene defines the hosting scene
  13647. * @returns a new skeleton
  13648. */
  13649. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13650. /**
  13651. * Compute all node absolute transforms
  13652. * @param forceUpdate defines if computation must be done even if cache is up to date
  13653. */
  13654. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13655. /**
  13656. * Gets the root pose matrix
  13657. * @returns a matrix
  13658. */
  13659. getPoseMatrix(): Nullable<Matrix>;
  13660. /**
  13661. * Sorts bones per internal index
  13662. */
  13663. sortBones(): void;
  13664. private _sortBones;
  13665. }
  13666. }
  13667. declare module BABYLON {
  13668. /**
  13669. * Class used to store bone information
  13670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13671. */
  13672. export class Bone extends Node {
  13673. /**
  13674. * defines the bone name
  13675. */
  13676. name: string;
  13677. private static _tmpVecs;
  13678. private static _tmpQuat;
  13679. private static _tmpMats;
  13680. /**
  13681. * Gets the list of child bones
  13682. */
  13683. children: Bone[];
  13684. /** Gets the animations associated with this bone */
  13685. animations: Animation[];
  13686. /**
  13687. * Gets or sets bone length
  13688. */
  13689. length: number;
  13690. /**
  13691. * @hidden Internal only
  13692. * Set this value to map this bone to a different index in the transform matrices
  13693. * Set this value to -1 to exclude the bone from the transform matrices
  13694. */
  13695. _index: Nullable<number>;
  13696. private _skeleton;
  13697. private _localMatrix;
  13698. private _restPose;
  13699. private _baseMatrix;
  13700. private _absoluteTransform;
  13701. private _invertedAbsoluteTransform;
  13702. private _parent;
  13703. private _scalingDeterminant;
  13704. private _worldTransform;
  13705. private _localScaling;
  13706. private _localRotation;
  13707. private _localPosition;
  13708. private _needToDecompose;
  13709. private _needToCompose;
  13710. /** @hidden */
  13711. _linkedTransformNode: Nullable<TransformNode>;
  13712. /** @hidden */
  13713. _waitingTransformNodeId: Nullable<string>;
  13714. /** @hidden */
  13715. get _matrix(): Matrix;
  13716. /** @hidden */
  13717. set _matrix(value: Matrix);
  13718. /**
  13719. * Create a new bone
  13720. * @param name defines the bone name
  13721. * @param skeleton defines the parent skeleton
  13722. * @param parentBone defines the parent (can be null if the bone is the root)
  13723. * @param localMatrix defines the local matrix
  13724. * @param restPose defines the rest pose matrix
  13725. * @param baseMatrix defines the base matrix
  13726. * @param index defines index of the bone in the hiearchy
  13727. */
  13728. constructor(
  13729. /**
  13730. * defines the bone name
  13731. */
  13732. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13733. /**
  13734. * Gets the current object class name.
  13735. * @return the class name
  13736. */
  13737. getClassName(): string;
  13738. /**
  13739. * Gets the parent skeleton
  13740. * @returns a skeleton
  13741. */
  13742. getSkeleton(): Skeleton;
  13743. /**
  13744. * Gets parent bone
  13745. * @returns a bone or null if the bone is the root of the bone hierarchy
  13746. */
  13747. getParent(): Nullable<Bone>;
  13748. /**
  13749. * Returns an array containing the root bones
  13750. * @returns an array containing the root bones
  13751. */
  13752. getChildren(): Array<Bone>;
  13753. /**
  13754. * Gets the node index in matrix array generated for rendering
  13755. * @returns the node index
  13756. */
  13757. getIndex(): number;
  13758. /**
  13759. * Sets the parent bone
  13760. * @param parent defines the parent (can be null if the bone is the root)
  13761. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13762. */
  13763. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13764. /**
  13765. * Gets the local matrix
  13766. * @returns a matrix
  13767. */
  13768. getLocalMatrix(): Matrix;
  13769. /**
  13770. * Gets the base matrix (initial matrix which remains unchanged)
  13771. * @returns a matrix
  13772. */
  13773. getBaseMatrix(): Matrix;
  13774. /**
  13775. * Gets the rest pose matrix
  13776. * @returns a matrix
  13777. */
  13778. getRestPose(): Matrix;
  13779. /**
  13780. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13781. */
  13782. getWorldMatrix(): Matrix;
  13783. /**
  13784. * Sets the local matrix to rest pose matrix
  13785. */
  13786. returnToRest(): void;
  13787. /**
  13788. * Gets the inverse of the absolute transform matrix.
  13789. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13790. * @returns a matrix
  13791. */
  13792. getInvertedAbsoluteTransform(): Matrix;
  13793. /**
  13794. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13795. * @returns a matrix
  13796. */
  13797. getAbsoluteTransform(): Matrix;
  13798. /**
  13799. * Links with the given transform node.
  13800. * The local matrix of this bone is copied from the transform node every frame.
  13801. * @param transformNode defines the transform node to link to
  13802. */
  13803. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13804. /**
  13805. * Gets the node used to drive the bone's transformation
  13806. * @returns a transform node or null
  13807. */
  13808. getTransformNode(): Nullable<TransformNode>;
  13809. /** Gets or sets current position (in local space) */
  13810. get position(): Vector3;
  13811. set position(newPosition: Vector3);
  13812. /** Gets or sets current rotation (in local space) */
  13813. get rotation(): Vector3;
  13814. set rotation(newRotation: Vector3);
  13815. /** Gets or sets current rotation quaternion (in local space) */
  13816. get rotationQuaternion(): Quaternion;
  13817. set rotationQuaternion(newRotation: Quaternion);
  13818. /** Gets or sets current scaling (in local space) */
  13819. get scaling(): Vector3;
  13820. set scaling(newScaling: Vector3);
  13821. /**
  13822. * Gets the animation properties override
  13823. */
  13824. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13825. private _decompose;
  13826. private _compose;
  13827. /**
  13828. * Update the base and local matrices
  13829. * @param matrix defines the new base or local matrix
  13830. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13831. * @param updateLocalMatrix defines if the local matrix should be updated
  13832. */
  13833. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13834. /** @hidden */
  13835. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13836. /**
  13837. * Flag the bone as dirty (Forcing it to update everything)
  13838. */
  13839. markAsDirty(): void;
  13840. /** @hidden */
  13841. _markAsDirtyAndCompose(): void;
  13842. private _markAsDirtyAndDecompose;
  13843. /**
  13844. * Translate the bone in local or world space
  13845. * @param vec The amount to translate the bone
  13846. * @param space The space that the translation is in
  13847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13848. */
  13849. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13850. /**
  13851. * Set the postion of the bone in local or world space
  13852. * @param position The position to set the bone
  13853. * @param space The space that the position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. */
  13856. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13857. /**
  13858. * Set the absolute position of the bone (world space)
  13859. * @param position The position to set the bone
  13860. * @param mesh The mesh that this bone is attached to
  13861. */
  13862. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13863. /**
  13864. * Scale the bone on the x, y and z axes (in local space)
  13865. * @param x The amount to scale the bone on the x axis
  13866. * @param y The amount to scale the bone on the y axis
  13867. * @param z The amount to scale the bone on the z axis
  13868. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13869. */
  13870. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13871. /**
  13872. * Set the bone scaling in local space
  13873. * @param scale defines the scaling vector
  13874. */
  13875. setScale(scale: Vector3): void;
  13876. /**
  13877. * Gets the current scaling in local space
  13878. * @returns the current scaling vector
  13879. */
  13880. getScale(): Vector3;
  13881. /**
  13882. * Gets the current scaling in local space and stores it in a target vector
  13883. * @param result defines the target vector
  13884. */
  13885. getScaleToRef(result: Vector3): void;
  13886. /**
  13887. * Set the yaw, pitch, and roll of the bone in local or world space
  13888. * @param yaw The rotation of the bone on the y axis
  13889. * @param pitch The rotation of the bone on the x axis
  13890. * @param roll The rotation of the bone on the z axis
  13891. * @param space The space that the axes of rotation are in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13895. /**
  13896. * Add a rotation to the bone on an axis in local or world space
  13897. * @param axis The axis to rotate the bone on
  13898. * @param amount The amount to rotate the bone
  13899. * @param space The space that the axis is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. */
  13902. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Set the rotation of the bone to a particular axis angle in local or world space
  13905. * @param axis The axis to rotate the bone on
  13906. * @param angle The angle that the bone should be rotated to
  13907. * @param space The space that the axis is in
  13908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13909. */
  13910. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13911. /**
  13912. * Set the euler rotation of the bone in local of world space
  13913. * @param rotation The euler rotation that the bone should be set to
  13914. * @param space The space that the rotation is in
  13915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13916. */
  13917. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13918. /**
  13919. * Set the quaternion rotation of the bone in local of world space
  13920. * @param quat The quaternion rotation that the bone should be set to
  13921. * @param space The space that the rotation is in
  13922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13923. */
  13924. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13925. /**
  13926. * Set the rotation matrix of the bone in local of world space
  13927. * @param rotMat The rotation matrix that the bone should be set to
  13928. * @param space The space that the rotation is in
  13929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13930. */
  13931. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13932. private _rotateWithMatrix;
  13933. private _getNegativeRotationToRef;
  13934. /**
  13935. * Get the position of the bone in local or world space
  13936. * @param space The space that the returned position is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. * @returns The position of the bone
  13939. */
  13940. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13941. /**
  13942. * Copy the position of the bone to a vector3 in local or world space
  13943. * @param space The space that the returned position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @param result The vector3 to copy the position to
  13946. */
  13947. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13948. /**
  13949. * Get the absolute position of the bone (world space)
  13950. * @param mesh The mesh that this bone is attached to
  13951. * @returns The absolute position of the bone
  13952. */
  13953. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13954. /**
  13955. * Copy the absolute position of the bone (world space) to the result param
  13956. * @param mesh The mesh that this bone is attached to
  13957. * @param result The vector3 to copy the absolute position to
  13958. */
  13959. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13960. /**
  13961. * Compute the absolute transforms of this bone and its children
  13962. */
  13963. computeAbsoluteTransforms(): void;
  13964. /**
  13965. * Get the world direction from an axis that is in the local space of the bone
  13966. * @param localAxis The local direction that is used to compute the world direction
  13967. * @param mesh The mesh that this bone is attached to
  13968. * @returns The world direction
  13969. */
  13970. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13971. /**
  13972. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13973. * @param localAxis The local direction that is used to compute the world direction
  13974. * @param mesh The mesh that this bone is attached to
  13975. * @param result The vector3 that the world direction will be copied to
  13976. */
  13977. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13978. /**
  13979. * Get the euler rotation of the bone in local or world space
  13980. * @param space The space that the rotation should be in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. * @returns The euler rotation
  13983. */
  13984. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13985. /**
  13986. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13987. * @param space The space that the rotation should be in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. * @param result The vector3 that the rotation should be copied to
  13990. */
  13991. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13992. /**
  13993. * Get the quaternion rotation of the bone in either local or world space
  13994. * @param space The space that the rotation should be in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. * @returns The quaternion rotation
  13997. */
  13998. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13999. /**
  14000. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14001. * @param space The space that the rotation should be in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. * @param result The quaternion that the rotation should be copied to
  14004. */
  14005. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14006. /**
  14007. * Get the rotation matrix of the bone in local or world space
  14008. * @param space The space that the rotation should be in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. * @returns The rotation matrix
  14011. */
  14012. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14013. /**
  14014. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @param result The quaternion that the rotation should be copied to
  14018. */
  14019. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14020. /**
  14021. * Get the world position of a point that is in the local space of the bone
  14022. * @param position The local position
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The world position
  14025. */
  14026. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14029. * @param position The local position
  14030. * @param mesh The mesh that this bone is attached to
  14031. * @param result The vector3 that the world position should be copied to
  14032. */
  14033. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14034. /**
  14035. * Get the local position of a point that is in world space
  14036. * @param position The world position
  14037. * @param mesh The mesh that this bone is attached to
  14038. * @returns The local position
  14039. */
  14040. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14041. /**
  14042. * Get the local position of a point that is in world space and copy it to the result param
  14043. * @param position The world position
  14044. * @param mesh The mesh that this bone is attached to
  14045. * @param result The vector3 that the local position should be copied to
  14046. */
  14047. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14048. }
  14049. }
  14050. declare module BABYLON {
  14051. /**
  14052. * 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.
  14053. * @see https://doc.babylonjs.com/how_to/transformnode
  14054. */
  14055. export class TransformNode extends Node {
  14056. /**
  14057. * Object will not rotate to face the camera
  14058. */
  14059. static BILLBOARDMODE_NONE: number;
  14060. /**
  14061. * Object will rotate to face the camera but only on the x axis
  14062. */
  14063. static BILLBOARDMODE_X: number;
  14064. /**
  14065. * Object will rotate to face the camera but only on the y axis
  14066. */
  14067. static BILLBOARDMODE_Y: number;
  14068. /**
  14069. * Object will rotate to face the camera but only on the z axis
  14070. */
  14071. static BILLBOARDMODE_Z: number;
  14072. /**
  14073. * Object will rotate to face the camera
  14074. */
  14075. static BILLBOARDMODE_ALL: number;
  14076. /**
  14077. * Object will rotate to face the camera's position instead of orientation
  14078. */
  14079. static BILLBOARDMODE_USE_POSITION: number;
  14080. private _forward;
  14081. private _forwardInverted;
  14082. private _up;
  14083. private _right;
  14084. private _rightInverted;
  14085. private _position;
  14086. private _rotation;
  14087. private _rotationQuaternion;
  14088. protected _scaling: Vector3;
  14089. protected _isDirty: boolean;
  14090. private _transformToBoneReferal;
  14091. private _isAbsoluteSynced;
  14092. private _billboardMode;
  14093. /**
  14094. * Gets or sets the billboard mode. Default is 0.
  14095. *
  14096. * | Value | Type | Description |
  14097. * | --- | --- | --- |
  14098. * | 0 | BILLBOARDMODE_NONE | |
  14099. * | 1 | BILLBOARDMODE_X | |
  14100. * | 2 | BILLBOARDMODE_Y | |
  14101. * | 4 | BILLBOARDMODE_Z | |
  14102. * | 7 | BILLBOARDMODE_ALL | |
  14103. *
  14104. */
  14105. get billboardMode(): number;
  14106. set billboardMode(value: number);
  14107. private _preserveParentRotationForBillboard;
  14108. /**
  14109. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14110. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14111. */
  14112. get preserveParentRotationForBillboard(): boolean;
  14113. set preserveParentRotationForBillboard(value: boolean);
  14114. /**
  14115. * 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
  14116. */
  14117. scalingDeterminant: number;
  14118. private _infiniteDistance;
  14119. /**
  14120. * Gets or sets the distance of the object to max, often used by skybox
  14121. */
  14122. get infiniteDistance(): boolean;
  14123. set infiniteDistance(value: boolean);
  14124. /**
  14125. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14126. * By default the system will update normals to compensate
  14127. */
  14128. ignoreNonUniformScaling: boolean;
  14129. /**
  14130. * 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
  14131. */
  14132. reIntegrateRotationIntoRotationQuaternion: boolean;
  14133. /** @hidden */
  14134. _poseMatrix: Nullable<Matrix>;
  14135. /** @hidden */
  14136. _localMatrix: Matrix;
  14137. private _usePivotMatrix;
  14138. private _absolutePosition;
  14139. private _absoluteScaling;
  14140. private _absoluteRotationQuaternion;
  14141. private _pivotMatrix;
  14142. private _pivotMatrixInverse;
  14143. protected _postMultiplyPivotMatrix: boolean;
  14144. protected _isWorldMatrixFrozen: boolean;
  14145. /** @hidden */
  14146. _indexInSceneTransformNodesArray: number;
  14147. /**
  14148. * An event triggered after the world matrix is updated
  14149. */
  14150. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14151. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14152. /**
  14153. * Gets a string identifying the name of the class
  14154. * @returns "TransformNode" string
  14155. */
  14156. getClassName(): string;
  14157. /**
  14158. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14159. */
  14160. get position(): Vector3;
  14161. set position(newPosition: Vector3);
  14162. /**
  14163. * 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)).
  14164. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14165. */
  14166. get rotation(): Vector3;
  14167. set rotation(newRotation: Vector3);
  14168. /**
  14169. * 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)).
  14170. */
  14171. get scaling(): Vector3;
  14172. set scaling(newScaling: Vector3);
  14173. /**
  14174. * 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).
  14175. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14176. */
  14177. get rotationQuaternion(): Nullable<Quaternion>;
  14178. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14179. /**
  14180. * The forward direction of that transform in world space.
  14181. */
  14182. get forward(): Vector3;
  14183. /**
  14184. * The up direction of that transform in world space.
  14185. */
  14186. get up(): Vector3;
  14187. /**
  14188. * The right direction of that transform in world space.
  14189. */
  14190. get right(): Vector3;
  14191. /**
  14192. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14193. * @param matrix the matrix to copy the pose from
  14194. * @returns this TransformNode.
  14195. */
  14196. updatePoseMatrix(matrix: Matrix): TransformNode;
  14197. /**
  14198. * Returns the mesh Pose matrix.
  14199. * @returns the pose matrix
  14200. */
  14201. getPoseMatrix(): Matrix;
  14202. /** @hidden */
  14203. _isSynchronized(): boolean;
  14204. /** @hidden */
  14205. _initCache(): void;
  14206. /**
  14207. * Flag the transform node as dirty (Forcing it to update everything)
  14208. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14209. * @returns this transform node
  14210. */
  14211. markAsDirty(property: string): TransformNode;
  14212. /**
  14213. * Returns the current mesh absolute position.
  14214. * Returns a Vector3.
  14215. */
  14216. get absolutePosition(): Vector3;
  14217. /**
  14218. * Returns the current mesh absolute scaling.
  14219. * Returns a Vector3.
  14220. */
  14221. get absoluteScaling(): Vector3;
  14222. /**
  14223. * Returns the current mesh absolute rotation.
  14224. * Returns a Quaternion.
  14225. */
  14226. get absoluteRotationQuaternion(): Quaternion;
  14227. /**
  14228. * Sets a new matrix to apply before all other transformation
  14229. * @param matrix defines the transform matrix
  14230. * @returns the current TransformNode
  14231. */
  14232. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14233. /**
  14234. * Sets a new pivot matrix to the current node
  14235. * @param matrix defines the new pivot matrix to use
  14236. * @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
  14237. * @returns the current TransformNode
  14238. */
  14239. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14240. /**
  14241. * Returns the mesh pivot matrix.
  14242. * Default : Identity.
  14243. * @returns the matrix
  14244. */
  14245. getPivotMatrix(): Matrix;
  14246. /**
  14247. * Instantiate (when possible) or clone that node with its hierarchy
  14248. * @param newParent defines the new parent to use for the instance (or clone)
  14249. * @param options defines options to configure how copy is done
  14250. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14251. * @returns an instance (or a clone) of the current node with its hiearchy
  14252. */
  14253. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14254. doNotInstantiate: boolean;
  14255. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14256. /**
  14257. * Prevents the World matrix to be computed any longer
  14258. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14259. * @returns the TransformNode.
  14260. */
  14261. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14262. /**
  14263. * Allows back the World matrix computation.
  14264. * @returns the TransformNode.
  14265. */
  14266. unfreezeWorldMatrix(): this;
  14267. /**
  14268. * True if the World matrix has been frozen.
  14269. */
  14270. get isWorldMatrixFrozen(): boolean;
  14271. /**
  14272. * Retuns the mesh absolute position in the World.
  14273. * @returns a Vector3.
  14274. */
  14275. getAbsolutePosition(): Vector3;
  14276. /**
  14277. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14278. * @param absolutePosition the absolute position to set
  14279. * @returns the TransformNode.
  14280. */
  14281. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14282. /**
  14283. * Sets the mesh position in its local space.
  14284. * @param vector3 the position to set in localspace
  14285. * @returns the TransformNode.
  14286. */
  14287. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14288. /**
  14289. * Returns the mesh position in the local space from the current World matrix values.
  14290. * @returns a new Vector3.
  14291. */
  14292. getPositionExpressedInLocalSpace(): Vector3;
  14293. /**
  14294. * Translates the mesh along the passed Vector3 in its local space.
  14295. * @param vector3 the distance to translate in localspace
  14296. * @returns the TransformNode.
  14297. */
  14298. locallyTranslate(vector3: Vector3): TransformNode;
  14299. private static _lookAtVectorCache;
  14300. /**
  14301. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14302. * @param targetPoint the position (must be in same space as current mesh) to look at
  14303. * @param yawCor optional yaw (y-axis) correction in radians
  14304. * @param pitchCor optional pitch (x-axis) correction in radians
  14305. * @param rollCor optional roll (z-axis) correction in radians
  14306. * @param space the choosen space of the target
  14307. * @returns the TransformNode.
  14308. */
  14309. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14310. /**
  14311. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14312. * This Vector3 is expressed in the World space.
  14313. * @param localAxis axis to rotate
  14314. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14315. */
  14316. getDirection(localAxis: Vector3): Vector3;
  14317. /**
  14318. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14319. * localAxis is expressed in the mesh local space.
  14320. * result is computed in the Wordl space from the mesh World matrix.
  14321. * @param localAxis axis to rotate
  14322. * @param result the resulting transformnode
  14323. * @returns this TransformNode.
  14324. */
  14325. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14326. /**
  14327. * Sets this transform node rotation to the given local axis.
  14328. * @param localAxis the axis in local space
  14329. * @param yawCor optional yaw (y-axis) correction in radians
  14330. * @param pitchCor optional pitch (x-axis) correction in radians
  14331. * @param rollCor optional roll (z-axis) correction in radians
  14332. * @returns this TransformNode
  14333. */
  14334. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14335. /**
  14336. * Sets a new pivot point to the current node
  14337. * @param point defines the new pivot point to use
  14338. * @param space defines if the point is in world or local space (local by default)
  14339. * @returns the current TransformNode
  14340. */
  14341. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14342. /**
  14343. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14344. * @returns the pivot point
  14345. */
  14346. getPivotPoint(): Vector3;
  14347. /**
  14348. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14349. * @param result the vector3 to store the result
  14350. * @returns this TransformNode.
  14351. */
  14352. getPivotPointToRef(result: Vector3): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14355. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14356. */
  14357. getAbsolutePivotPoint(): Vector3;
  14358. /**
  14359. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14360. * @param result vector3 to store the result
  14361. * @returns this TransformNode.
  14362. */
  14363. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14364. /**
  14365. * Defines the passed node as the parent of the current node.
  14366. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14367. * @see https://doc.babylonjs.com/how_to/parenting
  14368. * @param node the node ot set as the parent
  14369. * @returns this TransformNode.
  14370. */
  14371. setParent(node: Nullable<Node>): TransformNode;
  14372. private _nonUniformScaling;
  14373. /**
  14374. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14375. */
  14376. get nonUniformScaling(): boolean;
  14377. /** @hidden */
  14378. _updateNonUniformScalingState(value: boolean): boolean;
  14379. /**
  14380. * Attach the current TransformNode to another TransformNode associated with a bone
  14381. * @param bone Bone affecting the TransformNode
  14382. * @param affectedTransformNode TransformNode associated with the bone
  14383. * @returns this object
  14384. */
  14385. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14386. /**
  14387. * Detach the transform node if its associated with a bone
  14388. * @returns this object
  14389. */
  14390. detachFromBone(): TransformNode;
  14391. private static _rotationAxisCache;
  14392. /**
  14393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14394. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14395. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14396. * The passed axis is also normalized.
  14397. * @param axis the axis to rotate around
  14398. * @param amount the amount to rotate in radians
  14399. * @param space Space to rotate in (Default: local)
  14400. * @returns the TransformNode.
  14401. */
  14402. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14403. /**
  14404. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14405. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14406. * The passed axis is also normalized. .
  14407. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14408. * @param point the point to rotate around
  14409. * @param axis the axis to rotate around
  14410. * @param amount the amount to rotate in radians
  14411. * @returns the TransformNode
  14412. */
  14413. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14414. /**
  14415. * Translates the mesh along the axis vector for the passed distance in the given space.
  14416. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14417. * @param axis the axis to translate in
  14418. * @param distance the distance to translate
  14419. * @param space Space to rotate in (Default: local)
  14420. * @returns the TransformNode.
  14421. */
  14422. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14423. /**
  14424. * Adds a rotation step to the mesh current rotation.
  14425. * x, y, z are Euler angles expressed in radians.
  14426. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14427. * This means this rotation is made in the mesh local space only.
  14428. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14429. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14430. * ```javascript
  14431. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14432. * ```
  14433. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14434. * 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.
  14435. * @param x Rotation to add
  14436. * @param y Rotation to add
  14437. * @param z Rotation to add
  14438. * @returns the TransformNode.
  14439. */
  14440. addRotation(x: number, y: number, z: number): TransformNode;
  14441. /**
  14442. * @hidden
  14443. */
  14444. protected _getEffectiveParent(): Nullable<Node>;
  14445. /**
  14446. * Computes the world matrix of the node
  14447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14448. * @returns the world matrix
  14449. */
  14450. computeWorldMatrix(force?: boolean): Matrix;
  14451. protected _afterComputeWorldMatrix(): void;
  14452. /**
  14453. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14454. * @param func callback function to add
  14455. *
  14456. * @returns the TransformNode.
  14457. */
  14458. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14459. /**
  14460. * Removes a registered callback function.
  14461. * @param func callback function to remove
  14462. * @returns the TransformNode.
  14463. */
  14464. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14465. /**
  14466. * Gets the position of the current mesh in camera space
  14467. * @param camera defines the camera to use
  14468. * @returns a position
  14469. */
  14470. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14471. /**
  14472. * Returns the distance from the mesh to the active camera
  14473. * @param camera defines the camera to use
  14474. * @returns the distance
  14475. */
  14476. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14477. /**
  14478. * Clone the current transform node
  14479. * @param name Name of the new clone
  14480. * @param newParent New parent for the clone
  14481. * @param doNotCloneChildren Do not clone children hierarchy
  14482. * @returns the new transform node
  14483. */
  14484. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14485. /**
  14486. * Serializes the objects information.
  14487. * @param currentSerializationObject defines the object to serialize in
  14488. * @returns the serialized object
  14489. */
  14490. serialize(currentSerializationObject?: any): any;
  14491. /**
  14492. * Returns a new TransformNode object parsed from the source provided.
  14493. * @param parsedTransformNode is the source.
  14494. * @param scene the scne the object belongs to
  14495. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14496. * @returns a new TransformNode object parsed from the source provided.
  14497. */
  14498. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14499. /**
  14500. * Get all child-transformNodes of this node
  14501. * @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
  14502. * @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
  14503. * @returns an array of TransformNode
  14504. */
  14505. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14506. /**
  14507. * Releases resources associated with this transform node.
  14508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14510. */
  14511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14512. /**
  14513. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14514. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14515. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14516. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14517. * @returns the current mesh
  14518. */
  14519. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14520. private _syncAbsoluteScalingAndRotation;
  14521. }
  14522. }
  14523. declare module BABYLON {
  14524. /**
  14525. * Defines the types of pose enabled controllers that are supported
  14526. */
  14527. export enum PoseEnabledControllerType {
  14528. /**
  14529. * HTC Vive
  14530. */
  14531. VIVE = 0,
  14532. /**
  14533. * Oculus Rift
  14534. */
  14535. OCULUS = 1,
  14536. /**
  14537. * Windows mixed reality
  14538. */
  14539. WINDOWS = 2,
  14540. /**
  14541. * Samsung gear VR
  14542. */
  14543. GEAR_VR = 3,
  14544. /**
  14545. * Google Daydream
  14546. */
  14547. DAYDREAM = 4,
  14548. /**
  14549. * Generic
  14550. */
  14551. GENERIC = 5
  14552. }
  14553. /**
  14554. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14555. */
  14556. export interface MutableGamepadButton {
  14557. /**
  14558. * Value of the button/trigger
  14559. */
  14560. value: number;
  14561. /**
  14562. * If the button/trigger is currently touched
  14563. */
  14564. touched: boolean;
  14565. /**
  14566. * If the button/trigger is currently pressed
  14567. */
  14568. pressed: boolean;
  14569. }
  14570. /**
  14571. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14572. * @hidden
  14573. */
  14574. export interface ExtendedGamepadButton extends GamepadButton {
  14575. /**
  14576. * If the button/trigger is currently pressed
  14577. */
  14578. readonly pressed: boolean;
  14579. /**
  14580. * If the button/trigger is currently touched
  14581. */
  14582. readonly touched: boolean;
  14583. /**
  14584. * Value of the button/trigger
  14585. */
  14586. readonly value: number;
  14587. }
  14588. /** @hidden */
  14589. export interface _GamePadFactory {
  14590. /**
  14591. * Returns wether or not the current gamepad can be created for this type of controller.
  14592. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14593. * @returns true if it can be created, otherwise false
  14594. */
  14595. canCreate(gamepadInfo: any): boolean;
  14596. /**
  14597. * Creates a new instance of the Gamepad.
  14598. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14599. * @returns the new gamepad instance
  14600. */
  14601. create(gamepadInfo: any): Gamepad;
  14602. }
  14603. /**
  14604. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14605. */
  14606. export class PoseEnabledControllerHelper {
  14607. /** @hidden */
  14608. static _ControllerFactories: _GamePadFactory[];
  14609. /** @hidden */
  14610. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14611. /**
  14612. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14613. * @param vrGamepad the gamepad to initialized
  14614. * @returns a vr controller of the type the gamepad identified as
  14615. */
  14616. static InitiateController(vrGamepad: any): Gamepad;
  14617. }
  14618. /**
  14619. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14620. */
  14621. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14622. /**
  14623. * If the controller is used in a webXR session
  14624. */
  14625. isXR: boolean;
  14626. private _deviceRoomPosition;
  14627. private _deviceRoomRotationQuaternion;
  14628. /**
  14629. * The device position in babylon space
  14630. */
  14631. devicePosition: Vector3;
  14632. /**
  14633. * The device rotation in babylon space
  14634. */
  14635. deviceRotationQuaternion: Quaternion;
  14636. /**
  14637. * The scale factor of the device in babylon space
  14638. */
  14639. deviceScaleFactor: number;
  14640. /**
  14641. * (Likely devicePosition should be used instead) The device position in its room space
  14642. */
  14643. position: Vector3;
  14644. /**
  14645. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14646. */
  14647. rotationQuaternion: Quaternion;
  14648. /**
  14649. * The type of controller (Eg. Windows mixed reality)
  14650. */
  14651. controllerType: PoseEnabledControllerType;
  14652. protected _calculatedPosition: Vector3;
  14653. private _calculatedRotation;
  14654. /**
  14655. * The raw pose from the device
  14656. */
  14657. rawPose: DevicePose;
  14658. private _trackPosition;
  14659. private _maxRotationDistFromHeadset;
  14660. private _draggedRoomRotation;
  14661. /**
  14662. * @hidden
  14663. */
  14664. _disableTrackPosition(fixedPosition: Vector3): void;
  14665. /**
  14666. * Internal, the mesh attached to the controller
  14667. * @hidden
  14668. */
  14669. _mesh: Nullable<AbstractMesh>;
  14670. private _poseControlledCamera;
  14671. private _leftHandSystemQuaternion;
  14672. /**
  14673. * Internal, matrix used to convert room space to babylon space
  14674. * @hidden
  14675. */
  14676. _deviceToWorld: Matrix;
  14677. /**
  14678. * Node to be used when casting a ray from the controller
  14679. * @hidden
  14680. */
  14681. _pointingPoseNode: Nullable<TransformNode>;
  14682. /**
  14683. * Name of the child mesh that can be used to cast a ray from the controller
  14684. */
  14685. static readonly POINTING_POSE: string;
  14686. /**
  14687. * Creates a new PoseEnabledController from a gamepad
  14688. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14689. */
  14690. constructor(browserGamepad: any);
  14691. private _workingMatrix;
  14692. /**
  14693. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14694. */
  14695. update(): void;
  14696. /**
  14697. * Updates only the pose device and mesh without doing any button event checking
  14698. */
  14699. protected _updatePoseAndMesh(): void;
  14700. /**
  14701. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14702. * @param poseData raw pose fromthe device
  14703. */
  14704. updateFromDevice(poseData: DevicePose): void;
  14705. /**
  14706. * @hidden
  14707. */
  14708. _meshAttachedObservable: Observable<AbstractMesh>;
  14709. /**
  14710. * Attaches a mesh to the controller
  14711. * @param mesh the mesh to be attached
  14712. */
  14713. attachToMesh(mesh: AbstractMesh): void;
  14714. /**
  14715. * Attaches the controllers mesh to a camera
  14716. * @param camera the camera the mesh should be attached to
  14717. */
  14718. attachToPoseControlledCamera(camera: TargetCamera): void;
  14719. /**
  14720. * Disposes of the controller
  14721. */
  14722. dispose(): void;
  14723. /**
  14724. * The mesh that is attached to the controller
  14725. */
  14726. get mesh(): Nullable<AbstractMesh>;
  14727. /**
  14728. * Gets the ray of the controller in the direction the controller is pointing
  14729. * @param length the length the resulting ray should be
  14730. * @returns a ray in the direction the controller is pointing
  14731. */
  14732. getForwardRay(length?: number): Ray;
  14733. }
  14734. }
  14735. declare module BABYLON {
  14736. /**
  14737. * Defines the WebVRController object that represents controllers tracked in 3D space
  14738. */
  14739. export abstract class WebVRController extends PoseEnabledController {
  14740. /**
  14741. * Internal, the default controller model for the controller
  14742. */
  14743. protected _defaultModel: Nullable<AbstractMesh>;
  14744. /**
  14745. * Fired when the trigger state has changed
  14746. */
  14747. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14748. /**
  14749. * Fired when the main button state has changed
  14750. */
  14751. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14752. /**
  14753. * Fired when the secondary button state has changed
  14754. */
  14755. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14756. /**
  14757. * Fired when the pad state has changed
  14758. */
  14759. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14760. /**
  14761. * Fired when controllers stick values have changed
  14762. */
  14763. onPadValuesChangedObservable: Observable<StickValues>;
  14764. /**
  14765. * Array of button availible on the controller
  14766. */
  14767. protected _buttons: Array<MutableGamepadButton>;
  14768. private _onButtonStateChange;
  14769. /**
  14770. * Fired when a controller button's state has changed
  14771. * @param callback the callback containing the button that was modified
  14772. */
  14773. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14774. /**
  14775. * X and Y axis corresponding to the controllers joystick
  14776. */
  14777. pad: StickValues;
  14778. /**
  14779. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14780. */
  14781. hand: string;
  14782. /**
  14783. * The default controller model for the controller
  14784. */
  14785. get defaultModel(): Nullable<AbstractMesh>;
  14786. /**
  14787. * Creates a new WebVRController from a gamepad
  14788. * @param vrGamepad the gamepad that the WebVRController should be created from
  14789. */
  14790. constructor(vrGamepad: any);
  14791. /**
  14792. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14793. */
  14794. update(): void;
  14795. /**
  14796. * Function to be called when a button is modified
  14797. */
  14798. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14799. /**
  14800. * Loads a mesh and attaches it to the controller
  14801. * @param scene the scene the mesh should be added to
  14802. * @param meshLoaded callback for when the mesh has been loaded
  14803. */
  14804. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14805. private _setButtonValue;
  14806. private _changes;
  14807. private _checkChanges;
  14808. /**
  14809. * Disposes of th webVRCOntroller
  14810. */
  14811. dispose(): void;
  14812. }
  14813. }
  14814. declare module BABYLON {
  14815. /**
  14816. * The HemisphericLight simulates the ambient environment light,
  14817. * so the passed direction is the light reflection direction, not the incoming direction.
  14818. */
  14819. export class HemisphericLight extends Light {
  14820. /**
  14821. * The groundColor is the light in the opposite direction to the one specified during creation.
  14822. * 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.
  14823. */
  14824. groundColor: Color3;
  14825. /**
  14826. * The light reflection direction, not the incoming direction.
  14827. */
  14828. direction: Vector3;
  14829. /**
  14830. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14831. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14832. * The HemisphericLight can't cast shadows.
  14833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14834. * @param name The friendly name of the light
  14835. * @param direction The direction of the light reflection
  14836. * @param scene The scene the light belongs to
  14837. */
  14838. constructor(name: string, direction: Vector3, scene: Scene);
  14839. protected _buildUniformLayout(): void;
  14840. /**
  14841. * Returns the string "HemisphericLight".
  14842. * @return The class name
  14843. */
  14844. getClassName(): string;
  14845. /**
  14846. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14847. * Returns the updated direction.
  14848. * @param target The target the direction should point to
  14849. * @return The computed direction
  14850. */
  14851. setDirectionToTarget(target: Vector3): Vector3;
  14852. /**
  14853. * Returns the shadow generator associated to the light.
  14854. * @returns Always null for hemispheric lights because it does not support shadows.
  14855. */
  14856. getShadowGenerator(): Nullable<IShadowGenerator>;
  14857. /**
  14858. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14859. * @param effect The effect to update
  14860. * @param lightIndex The index of the light in the effect to update
  14861. * @returns The hemispheric light
  14862. */
  14863. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14864. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14865. /**
  14866. * Computes the world matrix of the node
  14867. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14868. * @param useWasUpdatedFlag defines a reserved property
  14869. * @returns the world matrix
  14870. */
  14871. computeWorldMatrix(): Matrix;
  14872. /**
  14873. * Returns the integer 3.
  14874. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14875. */
  14876. getTypeID(): number;
  14877. /**
  14878. * Prepares the list of defines specific to the light type.
  14879. * @param defines the list of defines
  14880. * @param lightIndex defines the index of the light for the effect
  14881. */
  14882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14883. }
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var vrMultiviewToSingleviewPixelShader: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /**
  14894. * Renders to multiple views with a single draw call
  14895. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14896. */
  14897. export class MultiviewRenderTarget extends RenderTargetTexture {
  14898. /**
  14899. * Creates a multiview render target
  14900. * @param scene scene used with the render target
  14901. * @param size the size of the render target (used for each view)
  14902. */
  14903. constructor(scene: Scene, size?: number | {
  14904. width: number;
  14905. height: number;
  14906. } | {
  14907. ratio: number;
  14908. });
  14909. /**
  14910. * @hidden
  14911. * @param faceIndex the face index, if its a cube texture
  14912. */
  14913. _bindFrameBuffer(faceIndex?: number): void;
  14914. /**
  14915. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14916. * @returns the view count
  14917. */
  14918. getViewCount(): number;
  14919. }
  14920. }
  14921. declare module BABYLON {
  14922. /**
  14923. * Represents a camera frustum
  14924. */
  14925. export class Frustum {
  14926. /**
  14927. * Gets the planes representing the frustum
  14928. * @param transform matrix to be applied to the returned planes
  14929. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14930. */
  14931. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14932. /**
  14933. * Gets the near frustum plane transformed by the transform matrix
  14934. * @param transform transformation matrix to be applied to the resulting frustum plane
  14935. * @param frustumPlane the resuling frustum plane
  14936. */
  14937. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14938. /**
  14939. * Gets the far frustum plane transformed by the transform matrix
  14940. * @param transform transformation matrix to be applied to the resulting frustum plane
  14941. * @param frustumPlane the resuling frustum plane
  14942. */
  14943. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14944. /**
  14945. * Gets the left frustum plane transformed by the transform matrix
  14946. * @param transform transformation matrix to be applied to the resulting frustum plane
  14947. * @param frustumPlane the resuling frustum plane
  14948. */
  14949. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the right frustum plane transformed by the transform matrix
  14952. * @param transform transformation matrix to be applied to the resulting frustum plane
  14953. * @param frustumPlane the resuling frustum plane
  14954. */
  14955. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Gets the top frustum plane transformed by the transform matrix
  14958. * @param transform transformation matrix to be applied to the resulting frustum plane
  14959. * @param frustumPlane the resuling frustum plane
  14960. */
  14961. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14962. /**
  14963. * Gets the bottom frustum plane transformed by the transform matrix
  14964. * @param transform transformation matrix to be applied to the resulting frustum plane
  14965. * @param frustumPlane the resuling frustum plane
  14966. */
  14967. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14968. /**
  14969. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14970. * @param transform transformation matrix to be applied to the resulting frustum planes
  14971. * @param frustumPlanes the resuling frustum planes
  14972. */
  14973. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14974. }
  14975. }
  14976. declare module BABYLON {
  14977. interface Engine {
  14978. /**
  14979. * Creates a new multiview render target
  14980. * @param width defines the width of the texture
  14981. * @param height defines the height of the texture
  14982. * @returns the created multiview texture
  14983. */
  14984. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14985. /**
  14986. * Binds a multiview framebuffer to be drawn to
  14987. * @param multiviewTexture texture to bind
  14988. */
  14989. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14990. }
  14991. interface Camera {
  14992. /**
  14993. * @hidden
  14994. * 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)
  14995. */
  14996. _useMultiviewToSingleView: boolean;
  14997. /**
  14998. * @hidden
  14999. * 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)
  15000. */
  15001. _multiviewTexture: Nullable<RenderTargetTexture>;
  15002. /**
  15003. * @hidden
  15004. * ensures the multiview texture of the camera exists and has the specified width/height
  15005. * @param width height to set on the multiview texture
  15006. * @param height width to set on the multiview texture
  15007. */
  15008. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15009. }
  15010. interface Scene {
  15011. /** @hidden */
  15012. _transformMatrixR: Matrix;
  15013. /** @hidden */
  15014. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15015. /** @hidden */
  15016. _createMultiviewUbo(): void;
  15017. /** @hidden */
  15018. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15019. /** @hidden */
  15020. _renderMultiviewToSingleView(camera: Camera): void;
  15021. }
  15022. }
  15023. declare module BABYLON {
  15024. /**
  15025. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15026. * This will not be used for webXR as it supports displaying texture arrays directly
  15027. */
  15028. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15029. /**
  15030. * Initializes a VRMultiviewToSingleview
  15031. * @param name name of the post process
  15032. * @param camera camera to be applied to
  15033. * @param scaleFactor scaling factor to the size of the output texture
  15034. */
  15035. constructor(name: string, camera: Camera, scaleFactor: number);
  15036. }
  15037. }
  15038. declare module BABYLON {
  15039. /**
  15040. * Interface used to define additional presentation attributes
  15041. */
  15042. export interface IVRPresentationAttributes {
  15043. /**
  15044. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15045. */
  15046. highRefreshRate: boolean;
  15047. /**
  15048. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15049. */
  15050. foveationLevel: number;
  15051. }
  15052. interface Engine {
  15053. /** @hidden */
  15054. _vrDisplay: any;
  15055. /** @hidden */
  15056. _vrSupported: boolean;
  15057. /** @hidden */
  15058. _oldSize: Size;
  15059. /** @hidden */
  15060. _oldHardwareScaleFactor: number;
  15061. /** @hidden */
  15062. _vrExclusivePointerMode: boolean;
  15063. /** @hidden */
  15064. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _onVRDisplayPointerRestricted: () => void;
  15067. /** @hidden */
  15068. _onVRDisplayPointerUnrestricted: () => void;
  15069. /** @hidden */
  15070. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15071. /** @hidden */
  15072. _onVrDisplayDisconnect: Nullable<() => void>;
  15073. /** @hidden */
  15074. _onVrDisplayPresentChange: Nullable<() => void>;
  15075. /**
  15076. * Observable signaled when VR display mode changes
  15077. */
  15078. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15079. /**
  15080. * Observable signaled when VR request present is complete
  15081. */
  15082. onVRRequestPresentComplete: Observable<boolean>;
  15083. /**
  15084. * Observable signaled when VR request present starts
  15085. */
  15086. onVRRequestPresentStart: Observable<Engine>;
  15087. /**
  15088. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15089. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15090. */
  15091. isInVRExclusivePointerMode: boolean;
  15092. /**
  15093. * Gets a boolean indicating if a webVR device was detected
  15094. * @returns true if a webVR device was detected
  15095. */
  15096. isVRDevicePresent(): boolean;
  15097. /**
  15098. * Gets the current webVR device
  15099. * @returns the current webVR device (or null)
  15100. */
  15101. getVRDevice(): any;
  15102. /**
  15103. * Initializes a webVR display and starts listening to display change events
  15104. * The onVRDisplayChangedObservable will be notified upon these changes
  15105. * @returns A promise containing a VRDisplay and if vr is supported
  15106. */
  15107. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15108. /** @hidden */
  15109. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15110. /**
  15111. * Gets or sets the presentation attributes used to configure VR rendering
  15112. */
  15113. vrPresentationAttributes?: IVRPresentationAttributes;
  15114. /**
  15115. * Call this function to switch to webVR mode
  15116. * Will do nothing if webVR is not supported or if there is no webVR device
  15117. * @param options the webvr options provided to the camera. mainly used for multiview
  15118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15119. */
  15120. enableVR(options: WebVROptions): void;
  15121. /** @hidden */
  15122. _onVRFullScreenTriggered(): void;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15128. * IMPORTANT!! The data is right-hand data.
  15129. * @export
  15130. * @interface DevicePose
  15131. */
  15132. export interface DevicePose {
  15133. /**
  15134. * The position of the device, values in array are [x,y,z].
  15135. */
  15136. readonly position: Nullable<Float32Array>;
  15137. /**
  15138. * The linearVelocity of the device, values in array are [x,y,z].
  15139. */
  15140. readonly linearVelocity: Nullable<Float32Array>;
  15141. /**
  15142. * The linearAcceleration of the device, values in array are [x,y,z].
  15143. */
  15144. readonly linearAcceleration: Nullable<Float32Array>;
  15145. /**
  15146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15147. */
  15148. readonly orientation: Nullable<Float32Array>;
  15149. /**
  15150. * The angularVelocity of the device, values in array are [x,y,z].
  15151. */
  15152. readonly angularVelocity: Nullable<Float32Array>;
  15153. /**
  15154. * The angularAcceleration of the device, values in array are [x,y,z].
  15155. */
  15156. readonly angularAcceleration: Nullable<Float32Array>;
  15157. }
  15158. /**
  15159. * Interface representing a pose controlled object in Babylon.
  15160. * A pose controlled object has both regular pose values as well as pose values
  15161. * from an external device such as a VR head mounted display
  15162. */
  15163. export interface PoseControlled {
  15164. /**
  15165. * The position of the object in babylon space.
  15166. */
  15167. position: Vector3;
  15168. /**
  15169. * The rotation quaternion of the object in babylon space.
  15170. */
  15171. rotationQuaternion: Quaternion;
  15172. /**
  15173. * The position of the device in babylon space.
  15174. */
  15175. devicePosition?: Vector3;
  15176. /**
  15177. * The rotation quaternion of the device in babylon space.
  15178. */
  15179. deviceRotationQuaternion: Quaternion;
  15180. /**
  15181. * The raw pose coming from the device.
  15182. */
  15183. rawPose: Nullable<DevicePose>;
  15184. /**
  15185. * The scale of the device to be used when translating from device space to babylon space.
  15186. */
  15187. deviceScaleFactor: number;
  15188. /**
  15189. * Updates the poseControlled values based on the input device pose.
  15190. * @param poseData the pose data to update the object with
  15191. */
  15192. updateFromDevice(poseData: DevicePose): void;
  15193. }
  15194. /**
  15195. * Set of options to customize the webVRCamera
  15196. */
  15197. export interface WebVROptions {
  15198. /**
  15199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15200. */
  15201. trackPosition?: boolean;
  15202. /**
  15203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15204. */
  15205. positionScale?: number;
  15206. /**
  15207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15208. */
  15209. displayName?: string;
  15210. /**
  15211. * Should the native controller meshes be initialized. (default: true)
  15212. */
  15213. controllerMeshes?: boolean;
  15214. /**
  15215. * Creating a default HemiLight only on controllers. (default: true)
  15216. */
  15217. defaultLightingOnControllers?: boolean;
  15218. /**
  15219. * If you don't want to use the default VR button of the helper. (default: false)
  15220. */
  15221. useCustomVRButton?: boolean;
  15222. /**
  15223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15224. */
  15225. customVRButton?: HTMLButtonElement;
  15226. /**
  15227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15228. */
  15229. rayLength?: number;
  15230. /**
  15231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15232. */
  15233. defaultHeight?: number;
  15234. /**
  15235. * If multiview should be used if availible (default: false)
  15236. */
  15237. useMultiview?: boolean;
  15238. }
  15239. /**
  15240. * This represents a WebVR camera.
  15241. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15242. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15243. */
  15244. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15245. private webVROptions;
  15246. /**
  15247. * @hidden
  15248. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15249. */
  15250. _vrDevice: any;
  15251. /**
  15252. * The rawPose of the vrDevice.
  15253. */
  15254. rawPose: Nullable<DevicePose>;
  15255. private _onVREnabled;
  15256. private _specsVersion;
  15257. private _attached;
  15258. private _frameData;
  15259. protected _descendants: Array<Node>;
  15260. private _deviceRoomPosition;
  15261. /** @hidden */
  15262. _deviceRoomRotationQuaternion: Quaternion;
  15263. private _standingMatrix;
  15264. /**
  15265. * Represents device position in babylon space.
  15266. */
  15267. devicePosition: Vector3;
  15268. /**
  15269. * Represents device rotation in babylon space.
  15270. */
  15271. deviceRotationQuaternion: Quaternion;
  15272. /**
  15273. * The scale of the device to be used when translating from device space to babylon space.
  15274. */
  15275. deviceScaleFactor: number;
  15276. private _deviceToWorld;
  15277. private _worldToDevice;
  15278. /**
  15279. * References to the webVR controllers for the vrDevice.
  15280. */
  15281. controllers: Array<WebVRController>;
  15282. /**
  15283. * Emits an event when a controller is attached.
  15284. */
  15285. onControllersAttachedObservable: Observable<WebVRController[]>;
  15286. /**
  15287. * Emits an event when a controller's mesh has been loaded;
  15288. */
  15289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15290. /**
  15291. * Emits an event when the HMD's pose has been updated.
  15292. */
  15293. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15294. private _poseSet;
  15295. /**
  15296. * If the rig cameras be used as parent instead of this camera.
  15297. */
  15298. rigParenting: boolean;
  15299. private _lightOnControllers;
  15300. private _defaultHeight?;
  15301. /**
  15302. * Instantiates a WebVRFreeCamera.
  15303. * @param name The name of the WebVRFreeCamera
  15304. * @param position The starting anchor position for the camera
  15305. * @param scene The scene the camera belongs to
  15306. * @param webVROptions a set of customizable options for the webVRCamera
  15307. */
  15308. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15309. /**
  15310. * Gets the device distance from the ground in meters.
  15311. * @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.
  15312. */
  15313. deviceDistanceToRoomGround(): number;
  15314. /**
  15315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15316. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15317. */
  15318. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15319. /**
  15320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15321. * @returns A promise with a boolean set to if the standing matrix is supported.
  15322. */
  15323. useStandingMatrixAsync(): Promise<boolean>;
  15324. /**
  15325. * Disposes the camera
  15326. */
  15327. dispose(): void;
  15328. /**
  15329. * Gets a vrController by name.
  15330. * @param name The name of the controller to retreive
  15331. * @returns the controller matching the name specified or null if not found
  15332. */
  15333. getControllerByName(name: string): Nullable<WebVRController>;
  15334. private _leftController;
  15335. /**
  15336. * The controller corresponding to the users left hand.
  15337. */
  15338. get leftController(): Nullable<WebVRController>;
  15339. private _rightController;
  15340. /**
  15341. * The controller corresponding to the users right hand.
  15342. */
  15343. get rightController(): Nullable<WebVRController>;
  15344. /**
  15345. * Casts a ray forward from the vrCamera's gaze.
  15346. * @param length Length of the ray (default: 100)
  15347. * @returns the ray corresponding to the gaze
  15348. */
  15349. getForwardRay(length?: number): Ray;
  15350. /**
  15351. * @hidden
  15352. * Updates the camera based on device's frame data
  15353. */
  15354. _checkInputs(): void;
  15355. /**
  15356. * Updates the poseControlled values based on the input device pose.
  15357. * @param poseData Pose coming from the device
  15358. */
  15359. updateFromDevice(poseData: DevicePose): void;
  15360. private _htmlElementAttached;
  15361. private _detachIfAttached;
  15362. /**
  15363. * WebVR's attach control will start broadcasting frames to the device.
  15364. * Note that in certain browsers (chrome for example) this function must be called
  15365. * within a user-interaction callback. Example:
  15366. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15367. *
  15368. * @param element html element to attach the vrDevice to
  15369. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15370. */
  15371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15372. /**
  15373. * Detaches the camera from the html element and disables VR
  15374. *
  15375. * @param element html element to detach from
  15376. */
  15377. detachControl(element: HTMLElement): void;
  15378. /**
  15379. * @returns the name of this class
  15380. */
  15381. getClassName(): string;
  15382. /**
  15383. * Calls resetPose on the vrDisplay
  15384. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15385. */
  15386. resetToCurrentRotation(): void;
  15387. /**
  15388. * @hidden
  15389. * Updates the rig cameras (left and right eye)
  15390. */
  15391. _updateRigCameras(): void;
  15392. private _workingVector;
  15393. private _oneVector;
  15394. private _workingMatrix;
  15395. private updateCacheCalled;
  15396. private _correctPositionIfNotTrackPosition;
  15397. /**
  15398. * @hidden
  15399. * Updates the cached values of the camera
  15400. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15401. */
  15402. _updateCache(ignoreParentClass?: boolean): void;
  15403. /**
  15404. * @hidden
  15405. * Get current device position in babylon world
  15406. */
  15407. _computeDevicePosition(): void;
  15408. /**
  15409. * Updates the current device position and rotation in the babylon world
  15410. */
  15411. update(): void;
  15412. /**
  15413. * @hidden
  15414. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15415. * @returns an identity matrix
  15416. */
  15417. _getViewMatrix(): Matrix;
  15418. private _tmpMatrix;
  15419. /**
  15420. * This function is called by the two RIG cameras.
  15421. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15422. * @hidden
  15423. */
  15424. _getWebVRViewMatrix(): Matrix;
  15425. /** @hidden */
  15426. _getWebVRProjectionMatrix(): Matrix;
  15427. private _onGamepadConnectedObserver;
  15428. private _onGamepadDisconnectedObserver;
  15429. private _updateCacheWhenTrackingDisabledObserver;
  15430. /**
  15431. * Initializes the controllers and their meshes
  15432. */
  15433. initControllers(): void;
  15434. }
  15435. }
  15436. declare module BABYLON {
  15437. /**
  15438. * Size options for a post process
  15439. */
  15440. export type PostProcessOptions = {
  15441. width: number;
  15442. height: number;
  15443. };
  15444. /**
  15445. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15446. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15447. */
  15448. export class PostProcess {
  15449. /** Name of the PostProcess. */
  15450. name: string;
  15451. /**
  15452. * Gets or sets the unique id of the post process
  15453. */
  15454. uniqueId: number;
  15455. /**
  15456. * Width of the texture to apply the post process on
  15457. */
  15458. width: number;
  15459. /**
  15460. * Height of the texture to apply the post process on
  15461. */
  15462. height: number;
  15463. /**
  15464. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15465. * @hidden
  15466. */
  15467. _outputTexture: Nullable<InternalTexture>;
  15468. /**
  15469. * Sampling mode used by the shader
  15470. * See https://doc.babylonjs.com/classes/3.1/texture
  15471. */
  15472. renderTargetSamplingMode: number;
  15473. /**
  15474. * Clear color to use when screen clearing
  15475. */
  15476. clearColor: Color4;
  15477. /**
  15478. * If the buffer needs to be cleared before applying the post process. (default: true)
  15479. * Should be set to false if shader will overwrite all previous pixels.
  15480. */
  15481. autoClear: boolean;
  15482. /**
  15483. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15484. */
  15485. alphaMode: number;
  15486. /**
  15487. * Sets the setAlphaBlendConstants of the babylon engine
  15488. */
  15489. alphaConstants: Color4;
  15490. /**
  15491. * Animations to be used for the post processing
  15492. */
  15493. animations: Animation[];
  15494. /**
  15495. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15496. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15497. */
  15498. enablePixelPerfectMode: boolean;
  15499. /**
  15500. * Force the postprocess to be applied without taking in account viewport
  15501. */
  15502. forceFullscreenViewport: boolean;
  15503. /**
  15504. * List of inspectable custom properties (used by the Inspector)
  15505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15506. */
  15507. inspectableCustomProperties: IInspectable[];
  15508. /**
  15509. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15510. *
  15511. * | Value | Type | Description |
  15512. * | ----- | ----------------------------------- | ----------- |
  15513. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15514. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15515. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15516. *
  15517. */
  15518. scaleMode: number;
  15519. /**
  15520. * Force textures to be a power of two (default: false)
  15521. */
  15522. alwaysForcePOT: boolean;
  15523. private _samples;
  15524. /**
  15525. * Number of sample textures (default: 1)
  15526. */
  15527. get samples(): number;
  15528. set samples(n: number);
  15529. /**
  15530. * Modify the scale of the post process to be the same as the viewport (default: false)
  15531. */
  15532. adaptScaleToCurrentViewport: boolean;
  15533. private _camera;
  15534. private _scene;
  15535. private _engine;
  15536. private _options;
  15537. private _reusable;
  15538. private _textureType;
  15539. /**
  15540. * Smart array of input and output textures for the post process.
  15541. * @hidden
  15542. */
  15543. _textures: SmartArray<InternalTexture>;
  15544. /**
  15545. * The index in _textures that corresponds to the output texture.
  15546. * @hidden
  15547. */
  15548. _currentRenderTextureInd: number;
  15549. private _effect;
  15550. private _samplers;
  15551. private _fragmentUrl;
  15552. private _vertexUrl;
  15553. private _parameters;
  15554. private _scaleRatio;
  15555. protected _indexParameters: any;
  15556. private _shareOutputWithPostProcess;
  15557. private _texelSize;
  15558. private _forcedOutputTexture;
  15559. /**
  15560. * Returns the fragment url or shader name used in the post process.
  15561. * @returns the fragment url or name in the shader store.
  15562. */
  15563. getEffectName(): string;
  15564. /**
  15565. * An event triggered when the postprocess is activated.
  15566. */
  15567. onActivateObservable: Observable<Camera>;
  15568. private _onActivateObserver;
  15569. /**
  15570. * A function that is added to the onActivateObservable
  15571. */
  15572. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15573. /**
  15574. * An event triggered when the postprocess changes its size.
  15575. */
  15576. onSizeChangedObservable: Observable<PostProcess>;
  15577. private _onSizeChangedObserver;
  15578. /**
  15579. * A function that is added to the onSizeChangedObservable
  15580. */
  15581. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15582. /**
  15583. * An event triggered when the postprocess applies its effect.
  15584. */
  15585. onApplyObservable: Observable<Effect>;
  15586. private _onApplyObserver;
  15587. /**
  15588. * A function that is added to the onApplyObservable
  15589. */
  15590. set onApply(callback: (effect: Effect) => void);
  15591. /**
  15592. * An event triggered before rendering the postprocess
  15593. */
  15594. onBeforeRenderObservable: Observable<Effect>;
  15595. private _onBeforeRenderObserver;
  15596. /**
  15597. * A function that is added to the onBeforeRenderObservable
  15598. */
  15599. set onBeforeRender(callback: (effect: Effect) => void);
  15600. /**
  15601. * An event triggered after rendering the postprocess
  15602. */
  15603. onAfterRenderObservable: Observable<Effect>;
  15604. private _onAfterRenderObserver;
  15605. /**
  15606. * A function that is added to the onAfterRenderObservable
  15607. */
  15608. set onAfterRender(callback: (efect: Effect) => void);
  15609. /**
  15610. * 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
  15611. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15612. */
  15613. get inputTexture(): InternalTexture;
  15614. set inputTexture(value: InternalTexture);
  15615. /**
  15616. * Gets the camera which post process is applied to.
  15617. * @returns The camera the post process is applied to.
  15618. */
  15619. getCamera(): Camera;
  15620. /**
  15621. * Gets the texel size of the postprocess.
  15622. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15623. */
  15624. get texelSize(): Vector2;
  15625. /**
  15626. * Creates a new instance PostProcess
  15627. * @param name The name of the PostProcess.
  15628. * @param fragmentUrl The url of the fragment shader to be used.
  15629. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15630. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15631. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15632. * @param camera The camera to apply the render pass to.
  15633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15634. * @param engine The engine which the post process will be applied. (default: current engine)
  15635. * @param reusable If the post process can be reused on the same frame. (default: false)
  15636. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15637. * @param textureType Type of textures used when performing the post process. (default: 0)
  15638. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15639. * @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
  15640. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15641. */
  15642. constructor(
  15643. /** Name of the PostProcess. */
  15644. 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);
  15645. /**
  15646. * Gets a string idenfifying the name of the class
  15647. * @returns "PostProcess" string
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Gets the engine which this post process belongs to.
  15652. * @returns The engine the post process was enabled with.
  15653. */
  15654. getEngine(): Engine;
  15655. /**
  15656. * The effect that is created when initializing the post process.
  15657. * @returns The created effect corresponding the the postprocess.
  15658. */
  15659. getEffect(): Effect;
  15660. /**
  15661. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15662. * @param postProcess The post process to share the output with.
  15663. * @returns This post process.
  15664. */
  15665. shareOutputWith(postProcess: PostProcess): PostProcess;
  15666. /**
  15667. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15668. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15669. */
  15670. useOwnOutput(): void;
  15671. /**
  15672. * Updates the effect with the current post process compile time values and recompiles the shader.
  15673. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15674. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15675. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15676. * @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
  15677. * @param onCompiled Called when the shader has been compiled.
  15678. * @param onError Called if there is an error when compiling a shader.
  15679. */
  15680. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15681. /**
  15682. * The post process is reusable if it can be used multiple times within one frame.
  15683. * @returns If the post process is reusable
  15684. */
  15685. isReusable(): boolean;
  15686. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15687. markTextureDirty(): void;
  15688. /**
  15689. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15690. * 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.
  15691. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15692. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15693. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15694. * @returns The target texture that was bound to be written to.
  15695. */
  15696. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15697. /**
  15698. * If the post process is supported.
  15699. */
  15700. get isSupported(): boolean;
  15701. /**
  15702. * The aspect ratio of the output texture.
  15703. */
  15704. get aspectRatio(): number;
  15705. /**
  15706. * Get a value indicating if the post-process is ready to be used
  15707. * @returns true if the post-process is ready (shader is compiled)
  15708. */
  15709. isReady(): boolean;
  15710. /**
  15711. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15712. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15713. */
  15714. apply(): Nullable<Effect>;
  15715. private _disposeTextures;
  15716. /**
  15717. * Disposes the post process.
  15718. * @param camera The camera to dispose the post process on.
  15719. */
  15720. dispose(camera?: Camera): void;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /** @hidden */
  15725. export var kernelBlurVaryingDeclaration: {
  15726. name: string;
  15727. shader: string;
  15728. };
  15729. }
  15730. declare module BABYLON {
  15731. /** @hidden */
  15732. export var kernelBlurFragment: {
  15733. name: string;
  15734. shader: string;
  15735. };
  15736. }
  15737. declare module BABYLON {
  15738. /** @hidden */
  15739. export var kernelBlurFragment2: {
  15740. name: string;
  15741. shader: string;
  15742. };
  15743. }
  15744. declare module BABYLON {
  15745. /** @hidden */
  15746. export var kernelBlurPixelShader: {
  15747. name: string;
  15748. shader: string;
  15749. };
  15750. }
  15751. declare module BABYLON {
  15752. /** @hidden */
  15753. export var kernelBlurVertex: {
  15754. name: string;
  15755. shader: string;
  15756. };
  15757. }
  15758. declare module BABYLON {
  15759. /** @hidden */
  15760. export var kernelBlurVertexShader: {
  15761. name: string;
  15762. shader: string;
  15763. };
  15764. }
  15765. declare module BABYLON {
  15766. /**
  15767. * The Blur Post Process which blurs an image based on a kernel and direction.
  15768. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15769. */
  15770. export class BlurPostProcess extends PostProcess {
  15771. /** The direction in which to blur the image. */
  15772. direction: Vector2;
  15773. private blockCompilation;
  15774. protected _kernel: number;
  15775. protected _idealKernel: number;
  15776. protected _packedFloat: boolean;
  15777. private _staticDefines;
  15778. /**
  15779. * Sets the length in pixels of the blur sample region
  15780. */
  15781. set kernel(v: number);
  15782. /**
  15783. * Gets the length in pixels of the blur sample region
  15784. */
  15785. get kernel(): number;
  15786. /**
  15787. * Sets wether or not the blur needs to unpack/repack floats
  15788. */
  15789. set packedFloat(v: boolean);
  15790. /**
  15791. * Gets wether or not the blur is unpacking/repacking floats
  15792. */
  15793. get packedFloat(): boolean;
  15794. /**
  15795. * Creates a new instance BlurPostProcess
  15796. * @param name The name of the effect.
  15797. * @param direction The direction in which to blur the image.
  15798. * @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.
  15799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15800. * @param camera The camera to apply the render pass to.
  15801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15802. * @param engine The engine which the post process will be applied. (default: current engine)
  15803. * @param reusable If the post process can be reused on the same frame. (default: false)
  15804. * @param textureType Type of textures used when performing the post process. (default: 0)
  15805. * @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)
  15806. */
  15807. constructor(name: string,
  15808. /** The direction in which to blur the image. */
  15809. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15821. /**
  15822. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15823. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15824. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15825. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15826. * The gaps between physical kernels are compensated for in the weighting of the samples
  15827. * @param idealKernel Ideal blur kernel.
  15828. * @return Nearest best kernel.
  15829. */
  15830. protected _nearestBestKernel(idealKernel: number): number;
  15831. /**
  15832. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15833. * @param x The point on the Gaussian distribution to sample.
  15834. * @return the value of the Gaussian function at x.
  15835. */
  15836. protected _gaussianWeight(x: number): number;
  15837. /**
  15838. * Generates a string that can be used as a floating point number in GLSL.
  15839. * @param x Value to print.
  15840. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15841. * @return GLSL float string.
  15842. */
  15843. protected _glslFloat(x: number, decimalFigures?: number): string;
  15844. }
  15845. }
  15846. declare module BABYLON {
  15847. /**
  15848. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15849. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15850. * You can then easily use it as a reflectionTexture on a flat surface.
  15851. * In case the surface is not a plane, please consider relying on reflection probes.
  15852. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15853. */
  15854. export class MirrorTexture extends RenderTargetTexture {
  15855. private scene;
  15856. /**
  15857. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15858. * 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.
  15859. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15860. */
  15861. mirrorPlane: Plane;
  15862. /**
  15863. * Define the blur ratio used to blur the reflection if needed.
  15864. */
  15865. set blurRatio(value: number);
  15866. get blurRatio(): number;
  15867. /**
  15868. * Define the adaptive blur kernel used to blur the reflection if needed.
  15869. * This will autocompute the closest best match for the `blurKernel`
  15870. */
  15871. set adaptiveBlurKernel(value: number);
  15872. /**
  15873. * Define the blur kernel used to blur the reflection if needed.
  15874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15875. */
  15876. set blurKernel(value: number);
  15877. /**
  15878. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15880. */
  15881. set blurKernelX(value: number);
  15882. get blurKernelX(): number;
  15883. /**
  15884. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15886. */
  15887. set blurKernelY(value: number);
  15888. get blurKernelY(): number;
  15889. private _autoComputeBlurKernel;
  15890. protected _onRatioRescale(): void;
  15891. private _updateGammaSpace;
  15892. private _imageProcessingConfigChangeObserver;
  15893. private _transformMatrix;
  15894. private _mirrorMatrix;
  15895. private _savedViewMatrix;
  15896. private _blurX;
  15897. private _blurY;
  15898. private _adaptiveBlurKernel;
  15899. private _blurKernelX;
  15900. private _blurKernelY;
  15901. private _blurRatio;
  15902. /**
  15903. * Instantiates a Mirror Texture.
  15904. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15905. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15906. * You can then easily use it as a reflectionTexture on a flat surface.
  15907. * In case the surface is not a plane, please consider relying on reflection probes.
  15908. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15909. * @param name
  15910. * @param size
  15911. * @param scene
  15912. * @param generateMipMaps
  15913. * @param type
  15914. * @param samplingMode
  15915. * @param generateDepthBuffer
  15916. */
  15917. constructor(name: string, size: number | {
  15918. width: number;
  15919. height: number;
  15920. } | {
  15921. ratio: number;
  15922. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15923. private _preparePostProcesses;
  15924. /**
  15925. * Clone the mirror texture.
  15926. * @returns the cloned texture
  15927. */
  15928. clone(): MirrorTexture;
  15929. /**
  15930. * Serialize the texture to a JSON representation you could use in Parse later on
  15931. * @returns the serialized JSON representation
  15932. */
  15933. serialize(): any;
  15934. /**
  15935. * Dispose the texture and release its associated resources.
  15936. */
  15937. dispose(): void;
  15938. }
  15939. }
  15940. declare module BABYLON {
  15941. /**
  15942. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15943. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15944. */
  15945. export class Texture extends BaseTexture {
  15946. /**
  15947. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15948. */
  15949. static SerializeBuffers: boolean;
  15950. /** @hidden */
  15951. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15952. /** @hidden */
  15953. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15954. /** @hidden */
  15955. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15956. /** nearest is mag = nearest and min = nearest and mip = linear */
  15957. static readonly NEAREST_SAMPLINGMODE: number;
  15958. /** nearest is mag = nearest and min = nearest and mip = linear */
  15959. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15961. static readonly BILINEAR_SAMPLINGMODE: number;
  15962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15963. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15964. /** Trilinear is mag = linear and min = linear and mip = linear */
  15965. static readonly TRILINEAR_SAMPLINGMODE: number;
  15966. /** Trilinear is mag = linear and min = linear and mip = linear */
  15967. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15968. /** mag = nearest and min = nearest and mip = nearest */
  15969. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15970. /** mag = nearest and min = linear and mip = nearest */
  15971. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15972. /** mag = nearest and min = linear and mip = linear */
  15973. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15974. /** mag = nearest and min = linear and mip = none */
  15975. static readonly NEAREST_LINEAR: number;
  15976. /** mag = nearest and min = nearest and mip = none */
  15977. static readonly NEAREST_NEAREST: number;
  15978. /** mag = linear and min = nearest and mip = nearest */
  15979. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15980. /** mag = linear and min = nearest and mip = linear */
  15981. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15982. /** mag = linear and min = linear and mip = none */
  15983. static readonly LINEAR_LINEAR: number;
  15984. /** mag = linear and min = nearest and mip = none */
  15985. static readonly LINEAR_NEAREST: number;
  15986. /** Explicit coordinates mode */
  15987. static readonly EXPLICIT_MODE: number;
  15988. /** Spherical coordinates mode */
  15989. static readonly SPHERICAL_MODE: number;
  15990. /** Planar coordinates mode */
  15991. static readonly PLANAR_MODE: number;
  15992. /** Cubic coordinates mode */
  15993. static readonly CUBIC_MODE: number;
  15994. /** Projection coordinates mode */
  15995. static readonly PROJECTION_MODE: number;
  15996. /** Inverse Cubic coordinates mode */
  15997. static readonly SKYBOX_MODE: number;
  15998. /** Inverse Cubic coordinates mode */
  15999. static readonly INVCUBIC_MODE: number;
  16000. /** Equirectangular coordinates mode */
  16001. static readonly EQUIRECTANGULAR_MODE: number;
  16002. /** Equirectangular Fixed coordinates mode */
  16003. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16004. /** Equirectangular Fixed Mirrored coordinates mode */
  16005. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16006. /** Texture is not repeating outside of 0..1 UVs */
  16007. static readonly CLAMP_ADDRESSMODE: number;
  16008. /** Texture is repeating outside of 0..1 UVs */
  16009. static readonly WRAP_ADDRESSMODE: number;
  16010. /** Texture is repeating and mirrored */
  16011. static readonly MIRROR_ADDRESSMODE: number;
  16012. /**
  16013. * 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
  16014. */
  16015. static UseSerializedUrlIfAny: boolean;
  16016. /**
  16017. * Define the url of the texture.
  16018. */
  16019. url: Nullable<string>;
  16020. /**
  16021. * Define an offset on the texture to offset the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16023. */
  16024. uOffset: number;
  16025. /**
  16026. * Define an offset on the texture to offset the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16028. */
  16029. vOffset: number;
  16030. /**
  16031. * Define an offset on the texture to scale the u coordinates of the UVs
  16032. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16033. */
  16034. uScale: number;
  16035. /**
  16036. * Define an offset on the texture to scale the v coordinates of the UVs
  16037. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16038. */
  16039. vScale: number;
  16040. /**
  16041. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16042. * @see http://doc.babylonjs.com/how_to/more_materials
  16043. */
  16044. uAng: number;
  16045. /**
  16046. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16047. * @see http://doc.babylonjs.com/how_to/more_materials
  16048. */
  16049. vAng: number;
  16050. /**
  16051. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16052. * @see http://doc.babylonjs.com/how_to/more_materials
  16053. */
  16054. wAng: number;
  16055. /**
  16056. * Defines the center of rotation (U)
  16057. */
  16058. uRotationCenter: number;
  16059. /**
  16060. * Defines the center of rotation (V)
  16061. */
  16062. vRotationCenter: number;
  16063. /**
  16064. * Defines the center of rotation (W)
  16065. */
  16066. wRotationCenter: number;
  16067. /**
  16068. * Are mip maps generated for this texture or not.
  16069. */
  16070. get noMipmap(): boolean;
  16071. /**
  16072. * List of inspectable custom properties (used by the Inspector)
  16073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16074. */
  16075. inspectableCustomProperties: Nullable<IInspectable[]>;
  16076. private _noMipmap;
  16077. /** @hidden */
  16078. _invertY: boolean;
  16079. private _rowGenerationMatrix;
  16080. private _cachedTextureMatrix;
  16081. private _projectionModeMatrix;
  16082. private _t0;
  16083. private _t1;
  16084. private _t2;
  16085. private _cachedUOffset;
  16086. private _cachedVOffset;
  16087. private _cachedUScale;
  16088. private _cachedVScale;
  16089. private _cachedUAng;
  16090. private _cachedVAng;
  16091. private _cachedWAng;
  16092. private _cachedProjectionMatrixId;
  16093. private _cachedCoordinatesMode;
  16094. /** @hidden */
  16095. protected _initialSamplingMode: number;
  16096. /** @hidden */
  16097. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16098. private _deleteBuffer;
  16099. protected _format: Nullable<number>;
  16100. private _delayedOnLoad;
  16101. private _delayedOnError;
  16102. private _mimeType?;
  16103. /**
  16104. * Observable triggered once the texture has been loaded.
  16105. */
  16106. onLoadObservable: Observable<Texture>;
  16107. protected _isBlocking: boolean;
  16108. /**
  16109. * Is the texture preventing material to render while loading.
  16110. * If false, a default texture will be used instead of the loading one during the preparation step.
  16111. */
  16112. set isBlocking(value: boolean);
  16113. get isBlocking(): boolean;
  16114. /**
  16115. * Get the current sampling mode associated with the texture.
  16116. */
  16117. get samplingMode(): number;
  16118. /**
  16119. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16120. */
  16121. get invertY(): boolean;
  16122. /**
  16123. * Instantiates a new texture.
  16124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16126. * @param url defines the url of the picture to load as a texture
  16127. * @param scene defines the scene or engine the texture will belong to
  16128. * @param noMipmap defines if the texture will require mip maps or not
  16129. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16130. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16131. * @param onLoad defines a callback triggered when the texture has been loaded
  16132. * @param onError defines a callback triggered when an error occurred during the loading session
  16133. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16134. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16135. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16136. * @param mimeType defines an optional mime type information
  16137. */
  16138. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16139. /**
  16140. * Update the url (and optional buffer) of this texture if url was null during construction.
  16141. * @param url the url of the texture
  16142. * @param buffer the buffer of the texture (defaults to null)
  16143. * @param onLoad callback called when the texture is loaded (defaults to null)
  16144. */
  16145. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16146. /**
  16147. * Finish the loading sequence of a texture flagged as delayed load.
  16148. * @hidden
  16149. */
  16150. delayLoad(): void;
  16151. private _prepareRowForTextureGeneration;
  16152. /**
  16153. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16154. * @returns the transform matrix of the texture.
  16155. */
  16156. getTextureMatrix(uBase?: number): Matrix;
  16157. /**
  16158. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16159. * @returns The reflection texture transform
  16160. */
  16161. getReflectionTextureMatrix(): Matrix;
  16162. /**
  16163. * Clones the texture.
  16164. * @returns the cloned texture
  16165. */
  16166. clone(): Texture;
  16167. /**
  16168. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16169. * @returns The JSON representation of the texture
  16170. */
  16171. serialize(): any;
  16172. /**
  16173. * Get the current class name of the texture useful for serialization or dynamic coding.
  16174. * @returns "Texture"
  16175. */
  16176. getClassName(): string;
  16177. /**
  16178. * Dispose the texture and release its associated resources.
  16179. */
  16180. dispose(): void;
  16181. /**
  16182. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16183. * @param parsedTexture Define the JSON representation of the texture
  16184. * @param scene Define the scene the parsed texture should be instantiated in
  16185. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16186. * @returns The parsed texture if successful
  16187. */
  16188. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16189. /**
  16190. * Creates a texture from its base 64 representation.
  16191. * @param data Define the base64 payload without the data: prefix
  16192. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16193. * @param scene Define the scene the texture should belong to
  16194. * @param noMipmap Forces the texture to not create mip map information if true
  16195. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16196. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16197. * @param onLoad define a callback triggered when the texture has been loaded
  16198. * @param onError define a callback triggered when an error occurred during the loading session
  16199. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16200. * @returns the created texture
  16201. */
  16202. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16203. /**
  16204. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16205. * @param data Define the base64 payload without the data: prefix
  16206. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16207. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16208. * @param scene Define the scene the texture should belong to
  16209. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16210. * @param noMipmap Forces the texture to not create mip map information if true
  16211. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16212. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16213. * @param onLoad define a callback triggered when the texture has been loaded
  16214. * @param onError define a callback triggered when an error occurred during the loading session
  16215. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16216. * @returns the created texture
  16217. */
  16218. 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;
  16219. }
  16220. }
  16221. declare module BABYLON {
  16222. /**
  16223. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16224. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16225. */
  16226. export class PostProcessManager {
  16227. private _scene;
  16228. private _indexBuffer;
  16229. private _vertexBuffers;
  16230. /**
  16231. * Creates a new instance PostProcess
  16232. * @param scene The scene that the post process is associated with.
  16233. */
  16234. constructor(scene: Scene);
  16235. private _prepareBuffers;
  16236. private _buildIndexBuffer;
  16237. /**
  16238. * Rebuilds the vertex buffers of the manager.
  16239. * @hidden
  16240. */
  16241. _rebuild(): void;
  16242. /**
  16243. * Prepares a frame to be run through a post process.
  16244. * @param sourceTexture The input texture to the post procesess. (default: null)
  16245. * @param postProcesses An array of post processes to be run. (default: null)
  16246. * @returns True if the post processes were able to be run.
  16247. * @hidden
  16248. */
  16249. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16250. /**
  16251. * Manually render a set of post processes to a texture.
  16252. * @param postProcesses An array of post processes to be run.
  16253. * @param targetTexture The target texture to render to.
  16254. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16255. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16256. * @param lodLevel defines which lod of the texture to render to
  16257. */
  16258. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16259. /**
  16260. * Finalize the result of the output of the postprocesses.
  16261. * @param doNotPresent If true the result will not be displayed to the screen.
  16262. * @param targetTexture The target texture to render to.
  16263. * @param faceIndex The index of the face to bind the target texture to.
  16264. * @param postProcesses The array of post processes to render.
  16265. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16266. * @hidden
  16267. */
  16268. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16269. /**
  16270. * Disposes of the post process manager.
  16271. */
  16272. dispose(): void;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /** Interface used by value gradients (color, factor, ...) */
  16277. export interface IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. }
  16283. /** Class used to store color4 gradient */
  16284. export class ColorGradient implements IValueGradient {
  16285. /**
  16286. * Gets or sets the gradient value (between 0 and 1)
  16287. */
  16288. gradient: number;
  16289. /**
  16290. * Gets or sets first associated color
  16291. */
  16292. color1: Color4;
  16293. /**
  16294. * Gets or sets second associated color
  16295. */
  16296. color2?: Color4;
  16297. /**
  16298. * Will get a color picked randomly between color1 and color2.
  16299. * If color2 is undefined then color1 will be used
  16300. * @param result defines the target Color4 to store the result in
  16301. */
  16302. getColorToRef(result: Color4): void;
  16303. }
  16304. /** Class used to store color 3 gradient */
  16305. export class Color3Gradient implements IValueGradient {
  16306. /**
  16307. * Gets or sets the gradient value (between 0 and 1)
  16308. */
  16309. gradient: number;
  16310. /**
  16311. * Gets or sets the associated color
  16312. */
  16313. color: Color3;
  16314. }
  16315. /** Class used to store factor gradient */
  16316. export class FactorGradient implements IValueGradient {
  16317. /**
  16318. * Gets or sets the gradient value (between 0 and 1)
  16319. */
  16320. gradient: number;
  16321. /**
  16322. * Gets or sets first associated factor
  16323. */
  16324. factor1: number;
  16325. /**
  16326. * Gets or sets second associated factor
  16327. */
  16328. factor2?: number;
  16329. /**
  16330. * Will get a number picked randomly between factor1 and factor2.
  16331. * If factor2 is undefined then factor1 will be used
  16332. * @returns the picked number
  16333. */
  16334. getFactor(): number;
  16335. }
  16336. /**
  16337. * Helper used to simplify some generic gradient tasks
  16338. */
  16339. export class GradientHelper {
  16340. /**
  16341. * Gets the current gradient from an array of IValueGradient
  16342. * @param ratio defines the current ratio to get
  16343. * @param gradients defines the array of IValueGradient
  16344. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16345. */
  16346. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16347. }
  16348. }
  16349. declare module BABYLON {
  16350. interface ThinEngine {
  16351. /**
  16352. * Creates a dynamic texture
  16353. * @param width defines the width of the texture
  16354. * @param height defines the height of the texture
  16355. * @param generateMipMaps defines if the engine should generate the mip levels
  16356. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16357. * @returns the dynamic texture inside an InternalTexture
  16358. */
  16359. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16360. /**
  16361. * Update the content of a dynamic texture
  16362. * @param texture defines the texture to update
  16363. * @param canvas defines the canvas containing the source
  16364. * @param invertY defines if data must be stored with Y axis inverted
  16365. * @param premulAlpha defines if alpha is stored as premultiplied
  16366. * @param format defines the format of the data
  16367. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16368. */
  16369. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16370. }
  16371. }
  16372. declare module BABYLON {
  16373. /**
  16374. * Helper class used to generate a canvas to manipulate images
  16375. */
  16376. export class CanvasGenerator {
  16377. /**
  16378. * Create a new canvas (or offscreen canvas depending on the context)
  16379. * @param width defines the expected width
  16380. * @param height defines the expected height
  16381. * @return a new canvas or offscreen canvas
  16382. */
  16383. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16384. }
  16385. }
  16386. declare module BABYLON {
  16387. /**
  16388. * A class extending Texture allowing drawing on a texture
  16389. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16390. */
  16391. export class DynamicTexture extends Texture {
  16392. private _generateMipMaps;
  16393. private _canvas;
  16394. private _context;
  16395. private _engine;
  16396. /**
  16397. * Creates a DynamicTexture
  16398. * @param name defines the name of the texture
  16399. * @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
  16400. * @param scene defines the scene where you want the texture
  16401. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16402. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16403. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16404. */
  16405. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16406. /**
  16407. * Get the current class name of the texture useful for serialization or dynamic coding.
  16408. * @returns "DynamicTexture"
  16409. */
  16410. getClassName(): string;
  16411. /**
  16412. * Gets the current state of canRescale
  16413. */
  16414. get canRescale(): boolean;
  16415. private _recreate;
  16416. /**
  16417. * Scales the texture
  16418. * @param ratio the scale factor to apply to both width and height
  16419. */
  16420. scale(ratio: number): void;
  16421. /**
  16422. * Resizes the texture
  16423. * @param width the new width
  16424. * @param height the new height
  16425. */
  16426. scaleTo(width: number, height: number): void;
  16427. /**
  16428. * Gets the context of the canvas used by the texture
  16429. * @returns the canvas context of the dynamic texture
  16430. */
  16431. getContext(): CanvasRenderingContext2D;
  16432. /**
  16433. * Clears the texture
  16434. */
  16435. clear(): void;
  16436. /**
  16437. * Updates the texture
  16438. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16439. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16440. */
  16441. update(invertY?: boolean, premulAlpha?: boolean): void;
  16442. /**
  16443. * Draws text onto the texture
  16444. * @param text defines the text to be drawn
  16445. * @param x defines the placement of the text from the left
  16446. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16447. * @param font defines the font to be used with font-style, font-size, font-name
  16448. * @param color defines the color used for the text
  16449. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16450. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16451. * @param update defines whether texture is immediately update (default is true)
  16452. */
  16453. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16454. /**
  16455. * Clones the texture
  16456. * @returns the clone of the texture.
  16457. */
  16458. clone(): DynamicTexture;
  16459. /**
  16460. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16461. * @returns a serialized dynamic texture object
  16462. */
  16463. serialize(): any;
  16464. /** @hidden */
  16465. _rebuild(): void;
  16466. }
  16467. }
  16468. declare module BABYLON {
  16469. interface AbstractScene {
  16470. /**
  16471. * The list of procedural textures added to the scene
  16472. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16473. */
  16474. proceduralTextures: Array<ProceduralTexture>;
  16475. }
  16476. /**
  16477. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16478. * in a given scene.
  16479. */
  16480. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16481. /**
  16482. * The component name helpfull to identify the component in the list of scene components.
  16483. */
  16484. readonly name: string;
  16485. /**
  16486. * The scene the component belongs to.
  16487. */
  16488. scene: Scene;
  16489. /**
  16490. * Creates a new instance of the component for the given scene
  16491. * @param scene Defines the scene to register the component in
  16492. */
  16493. constructor(scene: Scene);
  16494. /**
  16495. * Registers the component in a given scene
  16496. */
  16497. register(): void;
  16498. /**
  16499. * Rebuilds the elements related to this component in case of
  16500. * context lost for instance.
  16501. */
  16502. rebuild(): void;
  16503. /**
  16504. * Disposes the component and the associated ressources.
  16505. */
  16506. dispose(): void;
  16507. private _beforeClear;
  16508. }
  16509. }
  16510. declare module BABYLON {
  16511. interface ThinEngine {
  16512. /**
  16513. * Creates a new render target cube texture
  16514. * @param size defines the size of the texture
  16515. * @param options defines the options used to create the texture
  16516. * @returns a new render target cube texture stored in an InternalTexture
  16517. */
  16518. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16519. }
  16520. }
  16521. declare module BABYLON {
  16522. /** @hidden */
  16523. export var proceduralVertexShader: {
  16524. name: string;
  16525. shader: string;
  16526. };
  16527. }
  16528. declare module BABYLON {
  16529. /**
  16530. * 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.
  16531. * This is the base class of any Procedural texture and contains most of the shareable code.
  16532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16533. */
  16534. export class ProceduralTexture extends Texture {
  16535. isCube: boolean;
  16536. /**
  16537. * Define if the texture is enabled or not (disabled texture will not render)
  16538. */
  16539. isEnabled: boolean;
  16540. /**
  16541. * Define if the texture must be cleared before rendering (default is true)
  16542. */
  16543. autoClear: boolean;
  16544. /**
  16545. * Callback called when the texture is generated
  16546. */
  16547. onGenerated: () => void;
  16548. /**
  16549. * Event raised when the texture is generated
  16550. */
  16551. onGeneratedObservable: Observable<ProceduralTexture>;
  16552. /** @hidden */
  16553. _generateMipMaps: boolean;
  16554. /** @hidden **/
  16555. _effect: Effect;
  16556. /** @hidden */
  16557. _textures: {
  16558. [key: string]: Texture;
  16559. };
  16560. private _size;
  16561. private _currentRefreshId;
  16562. private _frameId;
  16563. private _refreshRate;
  16564. private _vertexBuffers;
  16565. private _indexBuffer;
  16566. private _uniforms;
  16567. private _samplers;
  16568. private _fragment;
  16569. private _floats;
  16570. private _ints;
  16571. private _floatsArrays;
  16572. private _colors3;
  16573. private _colors4;
  16574. private _vectors2;
  16575. private _vectors3;
  16576. private _matrices;
  16577. private _fallbackTexture;
  16578. private _fallbackTextureUsed;
  16579. private _engine;
  16580. private _cachedDefines;
  16581. private _contentUpdateId;
  16582. private _contentData;
  16583. /**
  16584. * Instantiates a new procedural texture.
  16585. * 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.
  16586. * This is the base class of any Procedural texture and contains most of the shareable code.
  16587. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16588. * @param name Define the name of the texture
  16589. * @param size Define the size of the texture to create
  16590. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16591. * @param scene Define the scene the texture belongs to
  16592. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16593. * @param generateMipMaps Define if the texture should creates mip maps or not
  16594. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16595. */
  16596. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16597. /**
  16598. * The effect that is created when initializing the post process.
  16599. * @returns The created effect corresponding the the postprocess.
  16600. */
  16601. getEffect(): Effect;
  16602. /**
  16603. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16604. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16605. */
  16606. getContent(): Nullable<ArrayBufferView>;
  16607. private _createIndexBuffer;
  16608. /** @hidden */
  16609. _rebuild(): void;
  16610. /**
  16611. * Resets the texture in order to recreate its associated resources.
  16612. * This can be called in case of context loss
  16613. */
  16614. reset(): void;
  16615. protected _getDefines(): string;
  16616. /**
  16617. * Is the texture ready to be used ? (rendered at least once)
  16618. * @returns true if ready, otherwise, false.
  16619. */
  16620. isReady(): boolean;
  16621. /**
  16622. * Resets the refresh counter of the texture and start bak from scratch.
  16623. * Could be useful to regenerate the texture if it is setup to render only once.
  16624. */
  16625. resetRefreshCounter(): void;
  16626. /**
  16627. * Set the fragment shader to use in order to render the texture.
  16628. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16629. */
  16630. setFragment(fragment: any): void;
  16631. /**
  16632. * Define the refresh rate of the texture or the rendering frequency.
  16633. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16634. */
  16635. get refreshRate(): number;
  16636. set refreshRate(value: number);
  16637. /** @hidden */
  16638. _shouldRender(): boolean;
  16639. /**
  16640. * Get the size the texture is rendering at.
  16641. * @returns the size (texture is always squared)
  16642. */
  16643. getRenderSize(): number;
  16644. /**
  16645. * Resize the texture to new value.
  16646. * @param size Define the new size the texture should have
  16647. * @param generateMipMaps Define whether the new texture should create mip maps
  16648. */
  16649. resize(size: number, generateMipMaps: boolean): void;
  16650. private _checkUniform;
  16651. /**
  16652. * Set a texture in the shader program used to render.
  16653. * @param name Define the name of the uniform samplers as defined in the shader
  16654. * @param texture Define the texture to bind to this sampler
  16655. * @return the texture itself allowing "fluent" like uniform updates
  16656. */
  16657. setTexture(name: string, texture: Texture): ProceduralTexture;
  16658. /**
  16659. * Set a float in the shader.
  16660. * @param name Define the name of the uniform as defined in the shader
  16661. * @param value Define the value to give to the uniform
  16662. * @return the texture itself allowing "fluent" like uniform updates
  16663. */
  16664. setFloat(name: string, value: number): ProceduralTexture;
  16665. /**
  16666. * Set a int in the shader.
  16667. * @param name Define the name of the uniform as defined in the shader
  16668. * @param value Define the value to give to the uniform
  16669. * @return the texture itself allowing "fluent" like uniform updates
  16670. */
  16671. setInt(name: string, value: number): ProceduralTexture;
  16672. /**
  16673. * Set an array of floats in the shader.
  16674. * @param name Define the name of the uniform as defined in the shader
  16675. * @param value Define the value to give to the uniform
  16676. * @return the texture itself allowing "fluent" like uniform updates
  16677. */
  16678. setFloats(name: string, value: number[]): ProceduralTexture;
  16679. /**
  16680. * Set a vec3 in the shader from a Color3.
  16681. * @param name Define the name of the uniform as defined in the shader
  16682. * @param value Define the value to give to the uniform
  16683. * @return the texture itself allowing "fluent" like uniform updates
  16684. */
  16685. setColor3(name: string, value: Color3): ProceduralTexture;
  16686. /**
  16687. * Set a vec4 in the shader from a Color4.
  16688. * @param name Define the name of the uniform as defined in the shader
  16689. * @param value Define the value to give to the uniform
  16690. * @return the texture itself allowing "fluent" like uniform updates
  16691. */
  16692. setColor4(name: string, value: Color4): ProceduralTexture;
  16693. /**
  16694. * Set a vec2 in the shader from a Vector2.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the texture itself allowing "fluent" like uniform updates
  16698. */
  16699. setVector2(name: string, value: Vector2): ProceduralTexture;
  16700. /**
  16701. * Set a vec3 in the shader from a Vector3.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the texture itself allowing "fluent" like uniform updates
  16705. */
  16706. setVector3(name: string, value: Vector3): ProceduralTexture;
  16707. /**
  16708. * Set a mat4 in the shader from a MAtrix.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the texture itself allowing "fluent" like uniform updates
  16712. */
  16713. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16714. /**
  16715. * Render the texture to its associated render target.
  16716. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16717. */
  16718. render(useCameraPostProcess?: boolean): void;
  16719. /**
  16720. * Clone the texture.
  16721. * @returns the cloned texture
  16722. */
  16723. clone(): ProceduralTexture;
  16724. /**
  16725. * Dispose the texture and release its asoociated resources.
  16726. */
  16727. dispose(): void;
  16728. }
  16729. }
  16730. declare module BABYLON {
  16731. /**
  16732. * This represents the base class for particle system in Babylon.
  16733. * 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.
  16734. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16735. * @example https://doc.babylonjs.com/babylon101/particles
  16736. */
  16737. export class BaseParticleSystem {
  16738. /**
  16739. * Source color is added to the destination color without alpha affecting the result
  16740. */
  16741. static BLENDMODE_ONEONE: number;
  16742. /**
  16743. * Blend current color and particle color using particle’s alpha
  16744. */
  16745. static BLENDMODE_STANDARD: number;
  16746. /**
  16747. * Add current color and particle color multiplied by particle’s alpha
  16748. */
  16749. static BLENDMODE_ADD: number;
  16750. /**
  16751. * Multiply current color with particle color
  16752. */
  16753. static BLENDMODE_MULTIPLY: number;
  16754. /**
  16755. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16756. */
  16757. static BLENDMODE_MULTIPLYADD: number;
  16758. /**
  16759. * List of animations used by the particle system.
  16760. */
  16761. animations: Animation[];
  16762. /**
  16763. * The id of the Particle system.
  16764. */
  16765. id: string;
  16766. /**
  16767. * The friendly name of the Particle system.
  16768. */
  16769. name: string;
  16770. /**
  16771. * The rendering group used by the Particle system to chose when to render.
  16772. */
  16773. renderingGroupId: number;
  16774. /**
  16775. * The emitter represents the Mesh or position we are attaching the particle system to.
  16776. */
  16777. emitter: Nullable<AbstractMesh | Vector3>;
  16778. /**
  16779. * The maximum number of particles to emit per frame
  16780. */
  16781. emitRate: number;
  16782. /**
  16783. * If you want to launch only a few particles at once, that can be done, as well.
  16784. */
  16785. manualEmitCount: number;
  16786. /**
  16787. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16788. */
  16789. updateSpeed: number;
  16790. /**
  16791. * The amount of time the particle system is running (depends of the overall update speed).
  16792. */
  16793. targetStopDuration: number;
  16794. /**
  16795. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16796. */
  16797. disposeOnStop: boolean;
  16798. /**
  16799. * Minimum power of emitting particles.
  16800. */
  16801. minEmitPower: number;
  16802. /**
  16803. * Maximum power of emitting particles.
  16804. */
  16805. maxEmitPower: number;
  16806. /**
  16807. * Minimum life time of emitting particles.
  16808. */
  16809. minLifeTime: number;
  16810. /**
  16811. * Maximum life time of emitting particles.
  16812. */
  16813. maxLifeTime: number;
  16814. /**
  16815. * Minimum Size of emitting particles.
  16816. */
  16817. minSize: number;
  16818. /**
  16819. * Maximum Size of emitting particles.
  16820. */
  16821. maxSize: number;
  16822. /**
  16823. * Minimum scale of emitting particles on X axis.
  16824. */
  16825. minScaleX: number;
  16826. /**
  16827. * Maximum scale of emitting particles on X axis.
  16828. */
  16829. maxScaleX: number;
  16830. /**
  16831. * Minimum scale of emitting particles on Y axis.
  16832. */
  16833. minScaleY: number;
  16834. /**
  16835. * Maximum scale of emitting particles on Y axis.
  16836. */
  16837. maxScaleY: number;
  16838. /**
  16839. * Gets or sets the minimal initial rotation in radians.
  16840. */
  16841. minInitialRotation: number;
  16842. /**
  16843. * Gets or sets the maximal initial rotation in radians.
  16844. */
  16845. maxInitialRotation: number;
  16846. /**
  16847. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16848. */
  16849. minAngularSpeed: number;
  16850. /**
  16851. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16852. */
  16853. maxAngularSpeed: number;
  16854. /**
  16855. * The texture used to render each particle. (this can be a spritesheet)
  16856. */
  16857. particleTexture: Nullable<Texture>;
  16858. /**
  16859. * The layer mask we are rendering the particles through.
  16860. */
  16861. layerMask: number;
  16862. /**
  16863. * This can help using your own shader to render the particle system.
  16864. * The according effect will be created
  16865. */
  16866. customShader: any;
  16867. /**
  16868. * By default particle system starts as soon as they are created. This prevents the
  16869. * automatic start to happen and let you decide when to start emitting particles.
  16870. */
  16871. preventAutoStart: boolean;
  16872. private _noiseTexture;
  16873. /**
  16874. * Gets or sets a texture used to add random noise to particle positions
  16875. */
  16876. get noiseTexture(): Nullable<ProceduralTexture>;
  16877. set noiseTexture(value: Nullable<ProceduralTexture>);
  16878. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16879. noiseStrength: Vector3;
  16880. /**
  16881. * Callback triggered when the particle animation is ending.
  16882. */
  16883. onAnimationEnd: Nullable<() => void>;
  16884. /**
  16885. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16886. */
  16887. blendMode: number;
  16888. /**
  16889. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16890. * to override the particles.
  16891. */
  16892. forceDepthWrite: boolean;
  16893. /** 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 */
  16894. preWarmCycles: number;
  16895. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16896. preWarmStepOffset: number;
  16897. /**
  16898. * 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)
  16899. */
  16900. spriteCellChangeSpeed: number;
  16901. /**
  16902. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16903. */
  16904. startSpriteCellID: number;
  16905. /**
  16906. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16907. */
  16908. endSpriteCellID: number;
  16909. /**
  16910. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16911. */
  16912. spriteCellWidth: number;
  16913. /**
  16914. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16915. */
  16916. spriteCellHeight: number;
  16917. /**
  16918. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16919. */
  16920. spriteRandomStartCell: boolean;
  16921. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16922. translationPivot: Vector2;
  16923. /** @hidden */
  16924. protected _isAnimationSheetEnabled: boolean;
  16925. /**
  16926. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16927. */
  16928. beginAnimationOnStart: boolean;
  16929. /**
  16930. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16931. */
  16932. beginAnimationFrom: number;
  16933. /**
  16934. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16935. */
  16936. beginAnimationTo: number;
  16937. /**
  16938. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16939. */
  16940. beginAnimationLoop: boolean;
  16941. /**
  16942. * Gets or sets a world offset applied to all particles
  16943. */
  16944. worldOffset: Vector3;
  16945. /**
  16946. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16947. */
  16948. get isAnimationSheetEnabled(): boolean;
  16949. set isAnimationSheetEnabled(value: boolean);
  16950. /**
  16951. * Get hosting scene
  16952. * @returns the scene
  16953. */
  16954. getScene(): Scene;
  16955. /**
  16956. * You can use gravity if you want to give an orientation to your particles.
  16957. */
  16958. gravity: Vector3;
  16959. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16960. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16961. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16962. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16963. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16964. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16965. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16966. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16967. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16968. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16969. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16970. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16971. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16972. /**
  16973. * Defines the delay in milliseconds before starting the system (0 by default)
  16974. */
  16975. startDelay: number;
  16976. /**
  16977. * Gets the current list of drag gradients.
  16978. * You must use addDragGradient and removeDragGradient to udpate this list
  16979. * @returns the list of drag gradients
  16980. */
  16981. getDragGradients(): Nullable<Array<FactorGradient>>;
  16982. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16983. limitVelocityDamping: number;
  16984. /**
  16985. * Gets the current list of limit velocity gradients.
  16986. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16987. * @returns the list of limit velocity gradients
  16988. */
  16989. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16990. /**
  16991. * Gets the current list of color gradients.
  16992. * You must use addColorGradient and removeColorGradient to udpate this list
  16993. * @returns the list of color gradients
  16994. */
  16995. getColorGradients(): Nullable<Array<ColorGradient>>;
  16996. /**
  16997. * Gets the current list of size gradients.
  16998. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16999. * @returns the list of size gradients
  17000. */
  17001. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17002. /**
  17003. * Gets the current list of color remap gradients.
  17004. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17005. * @returns the list of color remap gradients
  17006. */
  17007. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17008. /**
  17009. * Gets the current list of alpha remap gradients.
  17010. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17011. * @returns the list of alpha remap gradients
  17012. */
  17013. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17014. /**
  17015. * Gets the current list of life time gradients.
  17016. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17017. * @returns the list of life time gradients
  17018. */
  17019. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17020. /**
  17021. * Gets the current list of angular speed gradients.
  17022. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17023. * @returns the list of angular speed gradients
  17024. */
  17025. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of velocity gradients.
  17028. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17029. * @returns the list of velocity gradients
  17030. */
  17031. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17032. /**
  17033. * Gets the current list of start size gradients.
  17034. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17035. * @returns the list of start size gradients
  17036. */
  17037. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17038. /**
  17039. * Gets the current list of emit rate gradients.
  17040. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17041. * @returns the list of emit rate gradients
  17042. */
  17043. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17046. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17047. */
  17048. get direction1(): Vector3;
  17049. set direction1(value: Vector3);
  17050. /**
  17051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17052. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17053. */
  17054. get direction2(): Vector3;
  17055. set direction2(value: Vector3);
  17056. /**
  17057. * 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.
  17058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17059. */
  17060. get minEmitBox(): Vector3;
  17061. set minEmitBox(value: Vector3);
  17062. /**
  17063. * 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.
  17064. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17065. */
  17066. get maxEmitBox(): Vector3;
  17067. set maxEmitBox(value: Vector3);
  17068. /**
  17069. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17070. */
  17071. color1: Color4;
  17072. /**
  17073. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17074. */
  17075. color2: Color4;
  17076. /**
  17077. * Color the particle will have at the end of its lifetime
  17078. */
  17079. colorDead: Color4;
  17080. /**
  17081. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17082. */
  17083. textureMask: Color4;
  17084. /**
  17085. * The particle emitter type defines the emitter used by the particle system.
  17086. * It can be for example box, sphere, or cone...
  17087. */
  17088. particleEmitterType: IParticleEmitterType;
  17089. /** @hidden */
  17090. _isSubEmitter: boolean;
  17091. /**
  17092. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17093. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17094. */
  17095. billboardMode: number;
  17096. protected _isBillboardBased: boolean;
  17097. /**
  17098. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17099. */
  17100. get isBillboardBased(): boolean;
  17101. set isBillboardBased(value: boolean);
  17102. /**
  17103. * The scene the particle system belongs to.
  17104. */
  17105. protected _scene: Scene;
  17106. /**
  17107. * Local cache of defines for image processing.
  17108. */
  17109. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17110. /**
  17111. * Default configuration related to image processing available in the standard Material.
  17112. */
  17113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17114. /**
  17115. * Gets the image processing configuration used either in this material.
  17116. */
  17117. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17118. /**
  17119. * Sets the Default image processing configuration used either in the this material.
  17120. *
  17121. * If sets to null, the scene one is in use.
  17122. */
  17123. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17124. /**
  17125. * Attaches a new image processing configuration to the Standard Material.
  17126. * @param configuration
  17127. */
  17128. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17129. /** @hidden */
  17130. protected _reset(): void;
  17131. /** @hidden */
  17132. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17133. /**
  17134. * Instantiates a particle system.
  17135. * 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.
  17136. * @param name The name of the particle system
  17137. */
  17138. constructor(name: string);
  17139. /**
  17140. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17143. * @returns the emitter
  17144. */
  17145. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17146. /**
  17147. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17148. * @param radius The radius of the hemisphere to emit from
  17149. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17150. * @returns the emitter
  17151. */
  17152. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17153. /**
  17154. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17155. * @param radius The radius of the sphere to emit from
  17156. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17157. * @returns the emitter
  17158. */
  17159. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17160. /**
  17161. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17162. * @param radius The radius of the sphere to emit from
  17163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17165. * @returns the emitter
  17166. */
  17167. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17168. /**
  17169. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17170. * @param radius The radius of the emission cylinder
  17171. * @param height The height of the emission cylinder
  17172. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17173. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17174. * @returns the emitter
  17175. */
  17176. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17177. /**
  17178. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17179. * @param radius The radius of the cylinder to emit from
  17180. * @param height The height of the emission cylinder
  17181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17184. * @returns the emitter
  17185. */
  17186. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17187. /**
  17188. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17189. * @param radius The radius of the cone to emit from
  17190. * @param angle The base angle of the cone
  17191. * @returns the emitter
  17192. */
  17193. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17194. /**
  17195. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17196. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17197. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17198. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17199. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17200. * @returns the emitter
  17201. */
  17202. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17203. }
  17204. }
  17205. declare module BABYLON {
  17206. /**
  17207. * Type of sub emitter
  17208. */
  17209. export enum SubEmitterType {
  17210. /**
  17211. * Attached to the particle over it's lifetime
  17212. */
  17213. ATTACHED = 0,
  17214. /**
  17215. * Created when the particle dies
  17216. */
  17217. END = 1
  17218. }
  17219. /**
  17220. * Sub emitter class used to emit particles from an existing particle
  17221. */
  17222. export class SubEmitter {
  17223. /**
  17224. * the particle system to be used by the sub emitter
  17225. */
  17226. particleSystem: ParticleSystem;
  17227. /**
  17228. * Type of the submitter (Default: END)
  17229. */
  17230. type: SubEmitterType;
  17231. /**
  17232. * 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)
  17233. * Note: This only is supported when using an emitter of type Mesh
  17234. */
  17235. inheritDirection: boolean;
  17236. /**
  17237. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17238. */
  17239. inheritedVelocityAmount: number;
  17240. /**
  17241. * Creates a sub emitter
  17242. * @param particleSystem the particle system to be used by the sub emitter
  17243. */
  17244. constructor(
  17245. /**
  17246. * the particle system to be used by the sub emitter
  17247. */
  17248. particleSystem: ParticleSystem);
  17249. /**
  17250. * Clones the sub emitter
  17251. * @returns the cloned sub emitter
  17252. */
  17253. clone(): SubEmitter;
  17254. /**
  17255. * Serialize current object to a JSON object
  17256. * @returns the serialized object
  17257. */
  17258. serialize(): any;
  17259. /** @hidden */
  17260. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17261. /**
  17262. * Creates a new SubEmitter from a serialized JSON version
  17263. * @param serializationObject defines the JSON object to read from
  17264. * @param scene defines the hosting scene
  17265. * @param rootUrl defines the rootUrl for data loading
  17266. * @returns a new SubEmitter
  17267. */
  17268. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17269. /** Release associated resources */
  17270. dispose(): void;
  17271. }
  17272. }
  17273. declare module BABYLON {
  17274. /** @hidden */
  17275. export var clipPlaneFragmentDeclaration: {
  17276. name: string;
  17277. shader: string;
  17278. };
  17279. }
  17280. declare module BABYLON {
  17281. /** @hidden */
  17282. export var imageProcessingDeclaration: {
  17283. name: string;
  17284. shader: string;
  17285. };
  17286. }
  17287. declare module BABYLON {
  17288. /** @hidden */
  17289. export var imageProcessingFunctions: {
  17290. name: string;
  17291. shader: string;
  17292. };
  17293. }
  17294. declare module BABYLON {
  17295. /** @hidden */
  17296. export var clipPlaneFragment: {
  17297. name: string;
  17298. shader: string;
  17299. };
  17300. }
  17301. declare module BABYLON {
  17302. /** @hidden */
  17303. export var particlesPixelShader: {
  17304. name: string;
  17305. shader: string;
  17306. };
  17307. }
  17308. declare module BABYLON {
  17309. /** @hidden */
  17310. export var clipPlaneVertexDeclaration: {
  17311. name: string;
  17312. shader: string;
  17313. };
  17314. }
  17315. declare module BABYLON {
  17316. /** @hidden */
  17317. export var clipPlaneVertex: {
  17318. name: string;
  17319. shader: string;
  17320. };
  17321. }
  17322. declare module BABYLON {
  17323. /** @hidden */
  17324. export var particlesVertexShader: {
  17325. name: string;
  17326. shader: string;
  17327. };
  17328. }
  17329. declare module BABYLON {
  17330. /**
  17331. * This represents a particle system in Babylon.
  17332. * 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.
  17333. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17334. * @example https://doc.babylonjs.com/babylon101/particles
  17335. */
  17336. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17337. /**
  17338. * Billboard mode will only apply to Y axis
  17339. */
  17340. static readonly BILLBOARDMODE_Y: number;
  17341. /**
  17342. * Billboard mode will apply to all axes
  17343. */
  17344. static readonly BILLBOARDMODE_ALL: number;
  17345. /**
  17346. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17347. */
  17348. static readonly BILLBOARDMODE_STRETCHED: number;
  17349. /**
  17350. * This function can be defined to provide custom update for active particles.
  17351. * This function will be called instead of regular update (age, position, color, etc.).
  17352. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17353. */
  17354. updateFunction: (particles: Particle[]) => void;
  17355. private _emitterWorldMatrix;
  17356. /**
  17357. * This function can be defined to specify initial direction for every new particle.
  17358. * It by default use the emitterType defined function
  17359. */
  17360. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17361. /**
  17362. * This function can be defined to specify initial position for every new particle.
  17363. * It by default use the emitterType defined function
  17364. */
  17365. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17366. /**
  17367. * @hidden
  17368. */
  17369. _inheritedVelocityOffset: Vector3;
  17370. /**
  17371. * An event triggered when the system is disposed
  17372. */
  17373. onDisposeObservable: Observable<ParticleSystem>;
  17374. private _onDisposeObserver;
  17375. /**
  17376. * Sets a callback that will be triggered when the system is disposed
  17377. */
  17378. set onDispose(callback: () => void);
  17379. private _particles;
  17380. private _epsilon;
  17381. private _capacity;
  17382. private _stockParticles;
  17383. private _newPartsExcess;
  17384. private _vertexData;
  17385. private _vertexBuffer;
  17386. private _vertexBuffers;
  17387. private _spriteBuffer;
  17388. private _indexBuffer;
  17389. private _effect;
  17390. private _customEffect;
  17391. private _cachedDefines;
  17392. private _scaledColorStep;
  17393. private _colorDiff;
  17394. private _scaledDirection;
  17395. private _scaledGravity;
  17396. private _currentRenderId;
  17397. private _alive;
  17398. private _useInstancing;
  17399. private _started;
  17400. private _stopped;
  17401. private _actualFrame;
  17402. private _scaledUpdateSpeed;
  17403. private _vertexBufferSize;
  17404. /** @hidden */
  17405. _currentEmitRateGradient: Nullable<FactorGradient>;
  17406. /** @hidden */
  17407. _currentEmitRate1: number;
  17408. /** @hidden */
  17409. _currentEmitRate2: number;
  17410. /** @hidden */
  17411. _currentStartSizeGradient: Nullable<FactorGradient>;
  17412. /** @hidden */
  17413. _currentStartSize1: number;
  17414. /** @hidden */
  17415. _currentStartSize2: number;
  17416. private readonly _rawTextureWidth;
  17417. private _rampGradientsTexture;
  17418. private _useRampGradients;
  17419. /** Gets or sets a boolean indicating that ramp gradients must be used
  17420. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17421. */
  17422. get useRampGradients(): boolean;
  17423. set useRampGradients(value: boolean);
  17424. /**
  17425. * 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.
  17426. * 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: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. get particles(): Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * 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.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @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.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module BABYLON {
  17745. /**
  17746. * A particle represents one of the element emitted by a particle system.
  17747. * This is mainly define by its coordinates, direction, velocity and age.
  17748. */
  17749. export class Particle {
  17750. /**
  17751. * The particle system the particle belongs to.
  17752. */
  17753. particleSystem: ParticleSystem;
  17754. private static _Count;
  17755. /**
  17756. * Unique ID of the particle
  17757. */
  17758. id: number;
  17759. /**
  17760. * The world position of the particle in the scene.
  17761. */
  17762. position: Vector3;
  17763. /**
  17764. * The world direction of the particle in the scene.
  17765. */
  17766. direction: Vector3;
  17767. /**
  17768. * The color of the particle.
  17769. */
  17770. color: Color4;
  17771. /**
  17772. * The color change of the particle per step.
  17773. */
  17774. colorStep: Color4;
  17775. /**
  17776. * Defines how long will the life of the particle be.
  17777. */
  17778. lifeTime: number;
  17779. /**
  17780. * The current age of the particle.
  17781. */
  17782. age: number;
  17783. /**
  17784. * The current size of the particle.
  17785. */
  17786. size: number;
  17787. /**
  17788. * The current scale of the particle.
  17789. */
  17790. scale: Vector2;
  17791. /**
  17792. * The current angle of the particle.
  17793. */
  17794. angle: number;
  17795. /**
  17796. * Defines how fast is the angle changing.
  17797. */
  17798. angularSpeed: number;
  17799. /**
  17800. * Defines the cell index used by the particle to be rendered from a sprite.
  17801. */
  17802. cellIndex: number;
  17803. /**
  17804. * The information required to support color remapping
  17805. */
  17806. remapData: Vector4;
  17807. /** @hidden */
  17808. _randomCellOffset?: number;
  17809. /** @hidden */
  17810. _initialDirection: Nullable<Vector3>;
  17811. /** @hidden */
  17812. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17813. /** @hidden */
  17814. _initialStartSpriteCellID: number;
  17815. /** @hidden */
  17816. _initialEndSpriteCellID: number;
  17817. /** @hidden */
  17818. _currentColorGradient: Nullable<ColorGradient>;
  17819. /** @hidden */
  17820. _currentColor1: Color4;
  17821. /** @hidden */
  17822. _currentColor2: Color4;
  17823. /** @hidden */
  17824. _currentSizeGradient: Nullable<FactorGradient>;
  17825. /** @hidden */
  17826. _currentSize1: number;
  17827. /** @hidden */
  17828. _currentSize2: number;
  17829. /** @hidden */
  17830. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentAngularSpeed1: number;
  17833. /** @hidden */
  17834. _currentAngularSpeed2: number;
  17835. /** @hidden */
  17836. _currentVelocityGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentVelocity1: number;
  17839. /** @hidden */
  17840. _currentVelocity2: number;
  17841. /** @hidden */
  17842. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentLimitVelocity1: number;
  17845. /** @hidden */
  17846. _currentLimitVelocity2: number;
  17847. /** @hidden */
  17848. _currentDragGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentDrag1: number;
  17851. /** @hidden */
  17852. _currentDrag2: number;
  17853. /** @hidden */
  17854. _randomNoiseCoordinates1: Vector3;
  17855. /** @hidden */
  17856. _randomNoiseCoordinates2: Vector3;
  17857. /**
  17858. * Creates a new instance Particle
  17859. * @param particleSystem the particle system the particle belongs to
  17860. */
  17861. constructor(
  17862. /**
  17863. * The particle system the particle belongs to.
  17864. */
  17865. particleSystem: ParticleSystem);
  17866. private updateCellInfoFromSystem;
  17867. /**
  17868. * Defines how the sprite cell index is updated for the particle
  17869. */
  17870. updateCellIndex(): void;
  17871. /** @hidden */
  17872. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17873. /** @hidden */
  17874. _inheritParticleInfoToSubEmitters(): void;
  17875. /** @hidden */
  17876. _reset(): void;
  17877. /**
  17878. * Copy the properties of particle to another one.
  17879. * @param other the particle to copy the information to.
  17880. */
  17881. copyTo(other: Particle): void;
  17882. }
  17883. }
  17884. declare module BABYLON {
  17885. /**
  17886. * Particle emitter represents a volume emitting particles.
  17887. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17888. */
  17889. export interface IParticleEmitterType {
  17890. /**
  17891. * Called by the particle System when the direction is computed for the created particle.
  17892. * @param worldMatrix is the world matrix of the particle system
  17893. * @param directionToUpdate is the direction vector to update with the result
  17894. * @param particle is the particle we are computed the direction for
  17895. */
  17896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17897. /**
  17898. * Called by the particle System when the position is computed for the created particle.
  17899. * @param worldMatrix is the world matrix of the particle system
  17900. * @param positionToUpdate is the position vector to update with the result
  17901. * @param particle is the particle we are computed the position for
  17902. */
  17903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17904. /**
  17905. * Clones the current emitter and returns a copy of it
  17906. * @returns the new emitter
  17907. */
  17908. clone(): IParticleEmitterType;
  17909. /**
  17910. * Called by the GPUParticleSystem to setup the update shader
  17911. * @param effect defines the update shader
  17912. */
  17913. applyToShader(effect: Effect): void;
  17914. /**
  17915. * Returns a string to use to update the GPU particles update shader
  17916. * @returns the effect defines string
  17917. */
  17918. getEffectDefines(): string;
  17919. /**
  17920. * Returns a string representing the class name
  17921. * @returns a string containing the class name
  17922. */
  17923. getClassName(): string;
  17924. /**
  17925. * Serializes the particle system to a JSON object.
  17926. * @returns the JSON object
  17927. */
  17928. serialize(): any;
  17929. /**
  17930. * Parse properties from a JSON object
  17931. * @param serializationObject defines the JSON object
  17932. */
  17933. parse(serializationObject: any): void;
  17934. }
  17935. }
  17936. declare module BABYLON {
  17937. /**
  17938. * Particle emitter emitting particles from the inside of a box.
  17939. * It emits the particles randomly between 2 given directions.
  17940. */
  17941. export class BoxParticleEmitter implements IParticleEmitterType {
  17942. /**
  17943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17944. */
  17945. direction1: Vector3;
  17946. /**
  17947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17948. */
  17949. direction2: Vector3;
  17950. /**
  17951. * 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.
  17952. */
  17953. minEmitBox: Vector3;
  17954. /**
  17955. * 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.
  17956. */
  17957. maxEmitBox: Vector3;
  17958. /**
  17959. * Creates a new instance BoxParticleEmitter
  17960. */
  17961. constructor();
  17962. /**
  17963. * Called by the particle System when the direction is computed for the created particle.
  17964. * @param worldMatrix is the world matrix of the particle system
  17965. * @param directionToUpdate is the direction vector to update with the result
  17966. * @param particle is the particle we are computed the direction for
  17967. */
  17968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17969. /**
  17970. * Called by the particle System when the position is computed for the created particle.
  17971. * @param worldMatrix is the world matrix of the particle system
  17972. * @param positionToUpdate is the position vector to update with the result
  17973. * @param particle is the particle we are computed the position for
  17974. */
  17975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17976. /**
  17977. * Clones the current emitter and returns a copy of it
  17978. * @returns the new emitter
  17979. */
  17980. clone(): BoxParticleEmitter;
  17981. /**
  17982. * Called by the GPUParticleSystem to setup the update shader
  17983. * @param effect defines the update shader
  17984. */
  17985. applyToShader(effect: Effect): void;
  17986. /**
  17987. * Returns a string to use to update the GPU particles update shader
  17988. * @returns a string containng the defines string
  17989. */
  17990. getEffectDefines(): string;
  17991. /**
  17992. * Returns the string "BoxParticleEmitter"
  17993. * @returns a string containing the class name
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * Serializes the particle system to a JSON object.
  17998. * @returns the JSON object
  17999. */
  18000. serialize(): any;
  18001. /**
  18002. * Parse properties from a JSON object
  18003. * @param serializationObject defines the JSON object
  18004. */
  18005. parse(serializationObject: any): void;
  18006. }
  18007. }
  18008. declare module BABYLON {
  18009. /**
  18010. * Particle emitter emitting particles from the inside of a cone.
  18011. * It emits the particles alongside the cone volume from the base to the particle.
  18012. * The emission direction might be randomized.
  18013. */
  18014. export class ConeParticleEmitter implements IParticleEmitterType {
  18015. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18016. directionRandomizer: number;
  18017. private _radius;
  18018. private _angle;
  18019. private _height;
  18020. /**
  18021. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18022. */
  18023. radiusRange: number;
  18024. /**
  18025. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18026. */
  18027. heightRange: number;
  18028. /**
  18029. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18030. */
  18031. emitFromSpawnPointOnly: boolean;
  18032. /**
  18033. * Gets or sets the radius of the emission cone
  18034. */
  18035. get radius(): number;
  18036. set radius(value: number);
  18037. /**
  18038. * Gets or sets the angle of the emission cone
  18039. */
  18040. get angle(): number;
  18041. set angle(value: number);
  18042. private _buildHeight;
  18043. /**
  18044. * Creates a new instance ConeParticleEmitter
  18045. * @param radius the radius of the emission cone (1 by default)
  18046. * @param angle the cone base angle (PI by default)
  18047. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18048. */
  18049. constructor(radius?: number, angle?: number,
  18050. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18051. directionRandomizer?: number);
  18052. /**
  18053. * Called by the particle System when the direction is computed for the created particle.
  18054. * @param worldMatrix is the world matrix of the particle system
  18055. * @param directionToUpdate is the direction vector to update with the result
  18056. * @param particle is the particle we are computed the direction for
  18057. */
  18058. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18059. /**
  18060. * Called by the particle System when the position is computed for the created particle.
  18061. * @param worldMatrix is the world matrix of the particle system
  18062. * @param positionToUpdate is the position vector to update with the result
  18063. * @param particle is the particle we are computed the position for
  18064. */
  18065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18066. /**
  18067. * Clones the current emitter and returns a copy of it
  18068. * @returns the new emitter
  18069. */
  18070. clone(): ConeParticleEmitter;
  18071. /**
  18072. * Called by the GPUParticleSystem to setup the update shader
  18073. * @param effect defines the update shader
  18074. */
  18075. applyToShader(effect: Effect): void;
  18076. /**
  18077. * Returns a string to use to update the GPU particles update shader
  18078. * @returns a string containng the defines string
  18079. */
  18080. getEffectDefines(): string;
  18081. /**
  18082. * Returns the string "ConeParticleEmitter"
  18083. * @returns a string containing the class name
  18084. */
  18085. getClassName(): string;
  18086. /**
  18087. * Serializes the particle system to a JSON object.
  18088. * @returns the JSON object
  18089. */
  18090. serialize(): any;
  18091. /**
  18092. * Parse properties from a JSON object
  18093. * @param serializationObject defines the JSON object
  18094. */
  18095. parse(serializationObject: any): void;
  18096. }
  18097. }
  18098. declare module BABYLON {
  18099. /**
  18100. * Particle emitter emitting particles from the inside of a cylinder.
  18101. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18102. */
  18103. export class CylinderParticleEmitter implements IParticleEmitterType {
  18104. /**
  18105. * The radius of the emission cylinder.
  18106. */
  18107. radius: number;
  18108. /**
  18109. * The height of the emission cylinder.
  18110. */
  18111. height: number;
  18112. /**
  18113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18114. */
  18115. radiusRange: number;
  18116. /**
  18117. * How much to randomize the particle direction [0-1].
  18118. */
  18119. directionRandomizer: number;
  18120. /**
  18121. * Creates a new instance CylinderParticleEmitter
  18122. * @param radius the radius of the emission cylinder (1 by default)
  18123. * @param height the height of the emission cylinder (1 by default)
  18124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18126. */
  18127. constructor(
  18128. /**
  18129. * The radius of the emission cylinder.
  18130. */
  18131. radius?: number,
  18132. /**
  18133. * The height of the emission cylinder.
  18134. */
  18135. height?: number,
  18136. /**
  18137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18138. */
  18139. radiusRange?: number,
  18140. /**
  18141. * How much to randomize the particle direction [0-1].
  18142. */
  18143. directionRandomizer?: number);
  18144. /**
  18145. * Called by the particle System when the direction is computed for the created particle.
  18146. * @param worldMatrix is the world matrix of the particle system
  18147. * @param directionToUpdate is the direction vector to update with the result
  18148. * @param particle is the particle we are computed the direction for
  18149. */
  18150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18151. /**
  18152. * Called by the particle System when the position is computed for the created particle.
  18153. * @param worldMatrix is the world matrix of the particle system
  18154. * @param positionToUpdate is the position vector to update with the result
  18155. * @param particle is the particle we are computed the position for
  18156. */
  18157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18158. /**
  18159. * Clones the current emitter and returns a copy of it
  18160. * @returns the new emitter
  18161. */
  18162. clone(): CylinderParticleEmitter;
  18163. /**
  18164. * Called by the GPUParticleSystem to setup the update shader
  18165. * @param effect defines the update shader
  18166. */
  18167. applyToShader(effect: Effect): void;
  18168. /**
  18169. * Returns a string to use to update the GPU particles update shader
  18170. * @returns a string containng the defines string
  18171. */
  18172. getEffectDefines(): string;
  18173. /**
  18174. * Returns the string "CylinderParticleEmitter"
  18175. * @returns a string containing the class name
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Serializes the particle system to a JSON object.
  18180. * @returns the JSON object
  18181. */
  18182. serialize(): any;
  18183. /**
  18184. * Parse properties from a JSON object
  18185. * @param serializationObject defines the JSON object
  18186. */
  18187. parse(serializationObject: any): void;
  18188. }
  18189. /**
  18190. * Particle emitter emitting particles from the inside of a cylinder.
  18191. * It emits the particles randomly between two vectors.
  18192. */
  18193. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18194. /**
  18195. * The min limit of the emission direction.
  18196. */
  18197. direction1: Vector3;
  18198. /**
  18199. * The max limit of the emission direction.
  18200. */
  18201. direction2: Vector3;
  18202. /**
  18203. * Creates a new instance CylinderDirectedParticleEmitter
  18204. * @param radius the radius of the emission cylinder (1 by default)
  18205. * @param height the height of the emission cylinder (1 by default)
  18206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18207. * @param direction1 the min limit of the emission direction (up vector by default)
  18208. * @param direction2 the max limit of the emission direction (up vector by default)
  18209. */
  18210. constructor(radius?: number, height?: number, radiusRange?: number,
  18211. /**
  18212. * The min limit of the emission direction.
  18213. */
  18214. direction1?: Vector3,
  18215. /**
  18216. * The max limit of the emission direction.
  18217. */
  18218. direction2?: Vector3);
  18219. /**
  18220. * Called by the particle System when the direction is computed for the created particle.
  18221. * @param worldMatrix is the world matrix of the particle system
  18222. * @param directionToUpdate is the direction vector to update with the result
  18223. * @param particle is the particle we are computed the direction for
  18224. */
  18225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18226. /**
  18227. * Clones the current emitter and returns a copy of it
  18228. * @returns the new emitter
  18229. */
  18230. clone(): CylinderDirectedParticleEmitter;
  18231. /**
  18232. * Called by the GPUParticleSystem to setup the update shader
  18233. * @param effect defines the update shader
  18234. */
  18235. applyToShader(effect: Effect): void;
  18236. /**
  18237. * Returns a string to use to update the GPU particles update shader
  18238. * @returns a string containng the defines string
  18239. */
  18240. getEffectDefines(): string;
  18241. /**
  18242. * Returns the string "CylinderDirectedParticleEmitter"
  18243. * @returns a string containing the class name
  18244. */
  18245. getClassName(): string;
  18246. /**
  18247. * Serializes the particle system to a JSON object.
  18248. * @returns the JSON object
  18249. */
  18250. serialize(): any;
  18251. /**
  18252. * Parse properties from a JSON object
  18253. * @param serializationObject defines the JSON object
  18254. */
  18255. parse(serializationObject: any): void;
  18256. }
  18257. }
  18258. declare module BABYLON {
  18259. /**
  18260. * Particle emitter emitting particles from the inside of a hemisphere.
  18261. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18262. */
  18263. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18264. /**
  18265. * The radius of the emission hemisphere.
  18266. */
  18267. radius: number;
  18268. /**
  18269. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18270. */
  18271. radiusRange: number;
  18272. /**
  18273. * How much to randomize the particle direction [0-1].
  18274. */
  18275. directionRandomizer: number;
  18276. /**
  18277. * Creates a new instance HemisphericParticleEmitter
  18278. * @param radius the radius of the emission hemisphere (1 by default)
  18279. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18280. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18281. */
  18282. constructor(
  18283. /**
  18284. * The radius of the emission hemisphere.
  18285. */
  18286. radius?: number,
  18287. /**
  18288. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18289. */
  18290. radiusRange?: number,
  18291. /**
  18292. * How much to randomize the particle direction [0-1].
  18293. */
  18294. directionRandomizer?: number);
  18295. /**
  18296. * Called by the particle System when the direction is computed for the created particle.
  18297. * @param worldMatrix is the world matrix of the particle system
  18298. * @param directionToUpdate is the direction vector to update with the result
  18299. * @param particle is the particle we are computed the direction for
  18300. */
  18301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18302. /**
  18303. * Called by the particle System when the position is computed for the created particle.
  18304. * @param worldMatrix is the world matrix of the particle system
  18305. * @param positionToUpdate is the position vector to update with the result
  18306. * @param particle is the particle we are computed the position for
  18307. */
  18308. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18309. /**
  18310. * Clones the current emitter and returns a copy of it
  18311. * @returns the new emitter
  18312. */
  18313. clone(): HemisphericParticleEmitter;
  18314. /**
  18315. * Called by the GPUParticleSystem to setup the update shader
  18316. * @param effect defines the update shader
  18317. */
  18318. applyToShader(effect: Effect): void;
  18319. /**
  18320. * Returns a string to use to update the GPU particles update shader
  18321. * @returns a string containng the defines string
  18322. */
  18323. getEffectDefines(): string;
  18324. /**
  18325. * Returns the string "HemisphericParticleEmitter"
  18326. * @returns a string containing the class name
  18327. */
  18328. getClassName(): string;
  18329. /**
  18330. * Serializes the particle system to a JSON object.
  18331. * @returns the JSON object
  18332. */
  18333. serialize(): any;
  18334. /**
  18335. * Parse properties from a JSON object
  18336. * @param serializationObject defines the JSON object
  18337. */
  18338. parse(serializationObject: any): void;
  18339. }
  18340. }
  18341. declare module BABYLON {
  18342. /**
  18343. * Particle emitter emitting particles from a point.
  18344. * It emits the particles randomly between 2 given directions.
  18345. */
  18346. export class PointParticleEmitter implements IParticleEmitterType {
  18347. /**
  18348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18349. */
  18350. direction1: Vector3;
  18351. /**
  18352. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18353. */
  18354. direction2: Vector3;
  18355. /**
  18356. * Creates a new instance PointParticleEmitter
  18357. */
  18358. constructor();
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Called by the particle System when the position is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param positionToUpdate is the position vector to update with the result
  18370. * @param particle is the particle we are computed the position for
  18371. */
  18372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Clones the current emitter and returns a copy of it
  18375. * @returns the new emitter
  18376. */
  18377. clone(): PointParticleEmitter;
  18378. /**
  18379. * Called by the GPUParticleSystem to setup the update shader
  18380. * @param effect defines the update shader
  18381. */
  18382. applyToShader(effect: Effect): void;
  18383. /**
  18384. * Returns a string to use to update the GPU particles update shader
  18385. * @returns a string containng the defines string
  18386. */
  18387. getEffectDefines(): string;
  18388. /**
  18389. * Returns the string "PointParticleEmitter"
  18390. * @returns a string containing the class name
  18391. */
  18392. getClassName(): string;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Parse properties from a JSON object
  18400. * @param serializationObject defines the JSON object
  18401. */
  18402. parse(serializationObject: any): void;
  18403. }
  18404. }
  18405. declare module BABYLON {
  18406. /**
  18407. * Particle emitter emitting particles from the inside of a sphere.
  18408. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18409. */
  18410. export class SphereParticleEmitter implements IParticleEmitterType {
  18411. /**
  18412. * The radius of the emission sphere.
  18413. */
  18414. radius: number;
  18415. /**
  18416. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18417. */
  18418. radiusRange: number;
  18419. /**
  18420. * How much to randomize the particle direction [0-1].
  18421. */
  18422. directionRandomizer: number;
  18423. /**
  18424. * Creates a new instance SphereParticleEmitter
  18425. * @param radius the radius of the emission sphere (1 by default)
  18426. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18427. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18428. */
  18429. constructor(
  18430. /**
  18431. * The radius of the emission sphere.
  18432. */
  18433. radius?: number,
  18434. /**
  18435. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18436. */
  18437. radiusRange?: number,
  18438. /**
  18439. * How much to randomize the particle direction [0-1].
  18440. */
  18441. directionRandomizer?: number);
  18442. /**
  18443. * Called by the particle System when the direction is computed for the created particle.
  18444. * @param worldMatrix is the world matrix of the particle system
  18445. * @param directionToUpdate is the direction vector to update with the result
  18446. * @param particle is the particle we are computed the direction for
  18447. */
  18448. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18449. /**
  18450. * Called by the particle System when the position is computed for the created particle.
  18451. * @param worldMatrix is the world matrix of the particle system
  18452. * @param positionToUpdate is the position vector to update with the result
  18453. * @param particle is the particle we are computed the position for
  18454. */
  18455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18456. /**
  18457. * Clones the current emitter and returns a copy of it
  18458. * @returns the new emitter
  18459. */
  18460. clone(): SphereParticleEmitter;
  18461. /**
  18462. * Called by the GPUParticleSystem to setup the update shader
  18463. * @param effect defines the update shader
  18464. */
  18465. applyToShader(effect: Effect): void;
  18466. /**
  18467. * Returns a string to use to update the GPU particles update shader
  18468. * @returns a string containng the defines string
  18469. */
  18470. getEffectDefines(): string;
  18471. /**
  18472. * Returns the string "SphereParticleEmitter"
  18473. * @returns a string containing the class name
  18474. */
  18475. getClassName(): string;
  18476. /**
  18477. * Serializes the particle system to a JSON object.
  18478. * @returns the JSON object
  18479. */
  18480. serialize(): any;
  18481. /**
  18482. * Parse properties from a JSON object
  18483. * @param serializationObject defines the JSON object
  18484. */
  18485. parse(serializationObject: any): void;
  18486. }
  18487. /**
  18488. * Particle emitter emitting particles from the inside of a sphere.
  18489. * It emits the particles randomly between two vectors.
  18490. */
  18491. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18492. /**
  18493. * The min limit of the emission direction.
  18494. */
  18495. direction1: Vector3;
  18496. /**
  18497. * The max limit of the emission direction.
  18498. */
  18499. direction2: Vector3;
  18500. /**
  18501. * Creates a new instance SphereDirectedParticleEmitter
  18502. * @param radius the radius of the emission sphere (1 by default)
  18503. * @param direction1 the min limit of the emission direction (up vector by default)
  18504. * @param direction2 the max limit of the emission direction (up vector by default)
  18505. */
  18506. constructor(radius?: number,
  18507. /**
  18508. * The min limit of the emission direction.
  18509. */
  18510. direction1?: Vector3,
  18511. /**
  18512. * The max limit of the emission direction.
  18513. */
  18514. direction2?: Vector3);
  18515. /**
  18516. * Called by the particle System when the direction is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param directionToUpdate is the direction vector to update with the result
  18519. * @param particle is the particle we are computed the direction for
  18520. */
  18521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): SphereDirectedParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "SphereDirectedParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. }
  18554. declare module BABYLON {
  18555. /**
  18556. * Interface representing a particle system in Babylon.js.
  18557. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18558. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18559. */
  18560. export interface IParticleSystem {
  18561. /**
  18562. * List of animations used by the particle system.
  18563. */
  18564. animations: Animation[];
  18565. /**
  18566. * The id of the Particle system.
  18567. */
  18568. id: string;
  18569. /**
  18570. * The name of the Particle system.
  18571. */
  18572. name: string;
  18573. /**
  18574. * The emitter represents the Mesh or position we are attaching the particle system to.
  18575. */
  18576. emitter: Nullable<AbstractMesh | Vector3>;
  18577. /**
  18578. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18579. */
  18580. isBillboardBased: boolean;
  18581. /**
  18582. * The rendering group used by the Particle system to chose when to render.
  18583. */
  18584. renderingGroupId: number;
  18585. /**
  18586. * The layer mask we are rendering the particles through.
  18587. */
  18588. layerMask: number;
  18589. /**
  18590. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18591. */
  18592. updateSpeed: number;
  18593. /**
  18594. * The amount of time the particle system is running (depends of the overall update speed).
  18595. */
  18596. targetStopDuration: number;
  18597. /**
  18598. * The texture used to render each particle. (this can be a spritesheet)
  18599. */
  18600. particleTexture: Nullable<Texture>;
  18601. /**
  18602. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18603. */
  18604. blendMode: number;
  18605. /**
  18606. * Minimum life time of emitting particles.
  18607. */
  18608. minLifeTime: number;
  18609. /**
  18610. * Maximum life time of emitting particles.
  18611. */
  18612. maxLifeTime: number;
  18613. /**
  18614. * Minimum Size of emitting particles.
  18615. */
  18616. minSize: number;
  18617. /**
  18618. * Maximum Size of emitting particles.
  18619. */
  18620. maxSize: number;
  18621. /**
  18622. * Minimum scale of emitting particles on X axis.
  18623. */
  18624. minScaleX: number;
  18625. /**
  18626. * Maximum scale of emitting particles on X axis.
  18627. */
  18628. maxScaleX: number;
  18629. /**
  18630. * Minimum scale of emitting particles on Y axis.
  18631. */
  18632. minScaleY: number;
  18633. /**
  18634. * Maximum scale of emitting particles on Y axis.
  18635. */
  18636. maxScaleY: number;
  18637. /**
  18638. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18639. */
  18640. color1: Color4;
  18641. /**
  18642. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18643. */
  18644. color2: Color4;
  18645. /**
  18646. * Color the particle will have at the end of its lifetime.
  18647. */
  18648. colorDead: Color4;
  18649. /**
  18650. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18651. */
  18652. emitRate: number;
  18653. /**
  18654. * You can use gravity if you want to give an orientation to your particles.
  18655. */
  18656. gravity: Vector3;
  18657. /**
  18658. * Minimum power of emitting particles.
  18659. */
  18660. minEmitPower: number;
  18661. /**
  18662. * Maximum power of emitting particles.
  18663. */
  18664. maxEmitPower: number;
  18665. /**
  18666. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18667. */
  18668. minAngularSpeed: number;
  18669. /**
  18670. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18671. */
  18672. maxAngularSpeed: number;
  18673. /**
  18674. * Gets or sets the minimal initial rotation in radians.
  18675. */
  18676. minInitialRotation: number;
  18677. /**
  18678. * Gets or sets the maximal initial rotation in radians.
  18679. */
  18680. maxInitialRotation: number;
  18681. /**
  18682. * The particle emitter type defines the emitter used by the particle system.
  18683. * It can be for example box, sphere, or cone...
  18684. */
  18685. particleEmitterType: Nullable<IParticleEmitterType>;
  18686. /**
  18687. * Defines the delay in milliseconds before starting the system (0 by default)
  18688. */
  18689. startDelay: number;
  18690. /**
  18691. * 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
  18692. */
  18693. preWarmCycles: number;
  18694. /**
  18695. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18696. */
  18697. preWarmStepOffset: number;
  18698. /**
  18699. * 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)
  18700. */
  18701. spriteCellChangeSpeed: number;
  18702. /**
  18703. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18704. */
  18705. startSpriteCellID: number;
  18706. /**
  18707. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18708. */
  18709. endSpriteCellID: number;
  18710. /**
  18711. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18712. */
  18713. spriteCellWidth: number;
  18714. /**
  18715. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18716. */
  18717. spriteCellHeight: number;
  18718. /**
  18719. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18720. */
  18721. spriteRandomStartCell: boolean;
  18722. /**
  18723. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18724. */
  18725. isAnimationSheetEnabled: boolean;
  18726. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18727. translationPivot: Vector2;
  18728. /**
  18729. * Gets or sets a texture used to add random noise to particle positions
  18730. */
  18731. noiseTexture: Nullable<BaseTexture>;
  18732. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18733. noiseStrength: Vector3;
  18734. /**
  18735. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18736. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18737. */
  18738. billboardMode: number;
  18739. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18740. limitVelocityDamping: number;
  18741. /**
  18742. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18743. */
  18744. beginAnimationOnStart: boolean;
  18745. /**
  18746. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18747. */
  18748. beginAnimationFrom: number;
  18749. /**
  18750. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18751. */
  18752. beginAnimationTo: number;
  18753. /**
  18754. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18755. */
  18756. beginAnimationLoop: boolean;
  18757. /**
  18758. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18759. */
  18760. disposeOnStop: boolean;
  18761. /**
  18762. * Gets the maximum number of particles active at the same time.
  18763. * @returns The max number of active particles.
  18764. */
  18765. getCapacity(): number;
  18766. /**
  18767. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18768. * @returns True if it has been started, otherwise false.
  18769. */
  18770. isStarted(): boolean;
  18771. /**
  18772. * Animates the particle system for this frame.
  18773. */
  18774. animate(): void;
  18775. /**
  18776. * Renders the particle system in its current state.
  18777. * @returns the current number of particles
  18778. */
  18779. render(): number;
  18780. /**
  18781. * Dispose the particle system and frees its associated resources.
  18782. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18783. */
  18784. dispose(disposeTexture?: boolean): void;
  18785. /**
  18786. * Clones the particle system.
  18787. * @param name The name of the cloned object
  18788. * @param newEmitter The new emitter to use
  18789. * @returns the cloned particle system
  18790. */
  18791. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18792. /**
  18793. * Serializes the particle system to a JSON object.
  18794. * @returns the JSON object
  18795. */
  18796. serialize(): any;
  18797. /**
  18798. * Rebuild the particle system
  18799. */
  18800. rebuild(): void;
  18801. /**
  18802. * Starts the particle system and begins to emit
  18803. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. start(delay?: number): void;
  18806. /**
  18807. * Stops the particle system.
  18808. */
  18809. stop(): void;
  18810. /**
  18811. * Remove all active particles
  18812. */
  18813. reset(): void;
  18814. /**
  18815. * Is this system ready to be used/rendered
  18816. * @return true if the system is ready
  18817. */
  18818. isReady(): boolean;
  18819. /**
  18820. * Adds a new color gradient
  18821. * @param gradient defines the gradient to use (between 0 and 1)
  18822. * @param color1 defines the color to affect to the specified gradient
  18823. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18824. * @returns the current particle system
  18825. */
  18826. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18827. /**
  18828. * Remove a specific color gradient
  18829. * @param gradient defines the gradient to remove
  18830. * @returns the current particle system
  18831. */
  18832. removeColorGradient(gradient: number): IParticleSystem;
  18833. /**
  18834. * Adds a new size gradient
  18835. * @param gradient defines the gradient to use (between 0 and 1)
  18836. * @param factor defines the size factor to affect to the specified gradient
  18837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18838. * @returns the current particle system
  18839. */
  18840. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18841. /**
  18842. * Remove a specific size gradient
  18843. * @param gradient defines the gradient to remove
  18844. * @returns the current particle system
  18845. */
  18846. removeSizeGradient(gradient: number): IParticleSystem;
  18847. /**
  18848. * Gets the current list of color gradients.
  18849. * You must use addColorGradient and removeColorGradient to udpate this list
  18850. * @returns the list of color gradients
  18851. */
  18852. getColorGradients(): Nullable<Array<ColorGradient>>;
  18853. /**
  18854. * Gets the current list of size gradients.
  18855. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18856. * @returns the list of size gradients
  18857. */
  18858. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18859. /**
  18860. * Gets the current list of angular speed gradients.
  18861. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18862. * @returns the list of angular speed gradients
  18863. */
  18864. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18865. /**
  18866. * Adds a new angular speed gradient
  18867. * @param gradient defines the gradient to use (between 0 and 1)
  18868. * @param factor defines the angular speed to affect to the specified gradient
  18869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18870. * @returns the current particle system
  18871. */
  18872. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18873. /**
  18874. * Remove a specific angular speed gradient
  18875. * @param gradient defines the gradient to remove
  18876. * @returns the current particle system
  18877. */
  18878. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18879. /**
  18880. * Gets the current list of velocity gradients.
  18881. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18882. * @returns the list of velocity gradients
  18883. */
  18884. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18885. /**
  18886. * Adds a new velocity gradient
  18887. * @param gradient defines the gradient to use (between 0 and 1)
  18888. * @param factor defines the velocity to affect to the specified gradient
  18889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18890. * @returns the current particle system
  18891. */
  18892. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18893. /**
  18894. * Remove a specific velocity gradient
  18895. * @param gradient defines the gradient to remove
  18896. * @returns the current particle system
  18897. */
  18898. removeVelocityGradient(gradient: number): IParticleSystem;
  18899. /**
  18900. * Gets the current list of limit velocity gradients.
  18901. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18902. * @returns the list of limit velocity gradients
  18903. */
  18904. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18905. /**
  18906. * Adds a new limit velocity gradient
  18907. * @param gradient defines the gradient to use (between 0 and 1)
  18908. * @param factor defines the limit velocity to affect to the specified gradient
  18909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18910. * @returns the current particle system
  18911. */
  18912. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18913. /**
  18914. * Remove a specific limit velocity gradient
  18915. * @param gradient defines the gradient to remove
  18916. * @returns the current particle system
  18917. */
  18918. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18919. /**
  18920. * Adds a new drag gradient
  18921. * @param gradient defines the gradient to use (between 0 and 1)
  18922. * @param factor defines the drag to affect to the specified gradient
  18923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18924. * @returns the current particle system
  18925. */
  18926. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18927. /**
  18928. * Remove a specific drag gradient
  18929. * @param gradient defines the gradient to remove
  18930. * @returns the current particle system
  18931. */
  18932. removeDragGradient(gradient: number): IParticleSystem;
  18933. /**
  18934. * Gets the current list of drag gradients.
  18935. * You must use addDragGradient and removeDragGradient to udpate this list
  18936. * @returns the list of drag gradients
  18937. */
  18938. getDragGradients(): Nullable<Array<FactorGradient>>;
  18939. /**
  18940. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18941. * @param gradient defines the gradient to use (between 0 and 1)
  18942. * @param factor defines the emit rate to affect to the specified gradient
  18943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18944. * @returns the current particle system
  18945. */
  18946. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18947. /**
  18948. * Remove a specific emit rate gradient
  18949. * @param gradient defines the gradient to remove
  18950. * @returns the current particle system
  18951. */
  18952. removeEmitRateGradient(gradient: number): IParticleSystem;
  18953. /**
  18954. * Gets the current list of emit rate gradients.
  18955. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18956. * @returns the list of emit rate gradients
  18957. */
  18958. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18959. /**
  18960. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18961. * @param gradient defines the gradient to use (between 0 and 1)
  18962. * @param factor defines the start size to affect to the specified gradient
  18963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18964. * @returns the current particle system
  18965. */
  18966. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18967. /**
  18968. * Remove a specific start size gradient
  18969. * @param gradient defines the gradient to remove
  18970. * @returns the current particle system
  18971. */
  18972. removeStartSizeGradient(gradient: number): IParticleSystem;
  18973. /**
  18974. * Gets the current list of start size gradients.
  18975. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18976. * @returns the list of start size gradients
  18977. */
  18978. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18979. /**
  18980. * Adds a new life time gradient
  18981. * @param gradient defines the gradient to use (between 0 and 1)
  18982. * @param factor defines the life time factor to affect to the specified gradient
  18983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18984. * @returns the current particle system
  18985. */
  18986. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18987. /**
  18988. * Remove a specific life time gradient
  18989. * @param gradient defines the gradient to remove
  18990. * @returns the current particle system
  18991. */
  18992. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18993. /**
  18994. * Gets the current list of life time gradients.
  18995. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18996. * @returns the list of life time gradients
  18997. */
  18998. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18999. /**
  19000. * Gets the current list of color gradients.
  19001. * You must use addColorGradient and removeColorGradient to udpate this list
  19002. * @returns the list of color gradients
  19003. */
  19004. getColorGradients(): Nullable<Array<ColorGradient>>;
  19005. /**
  19006. * Adds a new ramp gradient used to remap particle colors
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param color defines the color to affect to the specified gradient
  19009. * @returns the current particle system
  19010. */
  19011. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19012. /**
  19013. * Gets the current list of ramp gradients.
  19014. * You must use addRampGradient and removeRampGradient to udpate this list
  19015. * @returns the list of ramp gradients
  19016. */
  19017. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19018. /** Gets or sets a boolean indicating that ramp gradients must be used
  19019. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19020. */
  19021. useRampGradients: boolean;
  19022. /**
  19023. * Adds a new color remap gradient
  19024. * @param gradient defines the gradient to use (between 0 and 1)
  19025. * @param min defines the color remap minimal range
  19026. * @param max defines the color remap maximal range
  19027. * @returns the current particle system
  19028. */
  19029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19030. /**
  19031. * Gets the current list of color remap gradients.
  19032. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19033. * @returns the list of color remap gradients
  19034. */
  19035. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19036. /**
  19037. * Adds a new alpha remap gradient
  19038. * @param gradient defines the gradient to use (between 0 and 1)
  19039. * @param min defines the alpha remap minimal range
  19040. * @param max defines the alpha remap maximal range
  19041. * @returns the current particle system
  19042. */
  19043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19044. /**
  19045. * Gets the current list of alpha remap gradients.
  19046. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19047. * @returns the list of alpha remap gradients
  19048. */
  19049. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19050. /**
  19051. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19054. * @returns the emitter
  19055. */
  19056. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19057. /**
  19058. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19059. * @param radius The radius of the hemisphere to emit from
  19060. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19061. * @returns the emitter
  19062. */
  19063. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19064. /**
  19065. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19066. * @param radius The radius of the sphere to emit from
  19067. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19068. * @returns the emitter
  19069. */
  19070. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19071. /**
  19072. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19073. * @param radius The radius of the sphere to emit from
  19074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19076. * @returns the emitter
  19077. */
  19078. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19079. /**
  19080. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19081. * @param radius The radius of the emission cylinder
  19082. * @param height The height of the emission cylinder
  19083. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19084. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19085. * @returns the emitter
  19086. */
  19087. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19088. /**
  19089. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19090. * @param radius The radius of the cylinder to emit from
  19091. * @param height The height of the emission cylinder
  19092. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19093. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19094. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19095. * @returns the emitter
  19096. */
  19097. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19098. /**
  19099. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19100. * @param radius The radius of the cone to emit from
  19101. * @param angle The base angle of the cone
  19102. * @returns the emitter
  19103. */
  19104. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19105. /**
  19106. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19107. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19108. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19109. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19110. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19111. * @returns the emitter
  19112. */
  19113. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19114. /**
  19115. * Get hosting scene
  19116. * @returns the scene
  19117. */
  19118. getScene(): Scene;
  19119. }
  19120. }
  19121. declare module BABYLON {
  19122. /**
  19123. * Creates an instance based on a source mesh.
  19124. */
  19125. export class InstancedMesh extends AbstractMesh {
  19126. private _sourceMesh;
  19127. private _currentLOD;
  19128. /** @hidden */
  19129. _indexInSourceMeshInstanceArray: number;
  19130. constructor(name: string, source: Mesh);
  19131. /**
  19132. * Returns the string "InstancedMesh".
  19133. */
  19134. getClassName(): string;
  19135. /** Gets the list of lights affecting that mesh */
  19136. get lightSources(): Light[];
  19137. _resyncLightSources(): void;
  19138. _resyncLightSource(light: Light): void;
  19139. _removeLightSource(light: Light, dispose: boolean): void;
  19140. /**
  19141. * If the source mesh receives shadows
  19142. */
  19143. get receiveShadows(): boolean;
  19144. /**
  19145. * The material of the source mesh
  19146. */
  19147. get material(): Nullable<Material>;
  19148. /**
  19149. * Visibility of the source mesh
  19150. */
  19151. get visibility(): number;
  19152. /**
  19153. * Skeleton of the source mesh
  19154. */
  19155. get skeleton(): Nullable<Skeleton>;
  19156. /**
  19157. * Rendering ground id of the source mesh
  19158. */
  19159. get renderingGroupId(): number;
  19160. set renderingGroupId(value: number);
  19161. /**
  19162. * Returns the total number of vertices (integer).
  19163. */
  19164. getTotalVertices(): number;
  19165. /**
  19166. * Returns a positive integer : the total number of indices in this mesh geometry.
  19167. * @returns the numner of indices or zero if the mesh has no geometry.
  19168. */
  19169. getTotalIndices(): number;
  19170. /**
  19171. * The source mesh of the instance
  19172. */
  19173. get sourceMesh(): Mesh;
  19174. /**
  19175. * Is this node ready to be used/rendered
  19176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19177. * @return {boolean} is it ready
  19178. */
  19179. isReady(completeCheck?: boolean): boolean;
  19180. /**
  19181. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19182. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19183. * @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.
  19184. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19185. */
  19186. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19187. /**
  19188. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19189. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19190. * The `data` are either a numeric array either a Float32Array.
  19191. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19192. * 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).
  19193. * Note that a new underlying VertexBuffer object is created each call.
  19194. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19195. *
  19196. * Possible `kind` values :
  19197. * - VertexBuffer.PositionKind
  19198. * - VertexBuffer.UVKind
  19199. * - VertexBuffer.UV2Kind
  19200. * - VertexBuffer.UV3Kind
  19201. * - VertexBuffer.UV4Kind
  19202. * - VertexBuffer.UV5Kind
  19203. * - VertexBuffer.UV6Kind
  19204. * - VertexBuffer.ColorKind
  19205. * - VertexBuffer.MatricesIndicesKind
  19206. * - VertexBuffer.MatricesIndicesExtraKind
  19207. * - VertexBuffer.MatricesWeightsKind
  19208. * - VertexBuffer.MatricesWeightsExtraKind
  19209. *
  19210. * Returns the Mesh.
  19211. */
  19212. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19213. /**
  19214. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19215. * If the mesh has no geometry, it is simply returned as it is.
  19216. * The `data` are either a numeric array either a Float32Array.
  19217. * No new underlying VertexBuffer object is created.
  19218. * 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.
  19219. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19220. *
  19221. * Possible `kind` values :
  19222. * - VertexBuffer.PositionKind
  19223. * - VertexBuffer.UVKind
  19224. * - VertexBuffer.UV2Kind
  19225. * - VertexBuffer.UV3Kind
  19226. * - VertexBuffer.UV4Kind
  19227. * - VertexBuffer.UV5Kind
  19228. * - VertexBuffer.UV6Kind
  19229. * - VertexBuffer.ColorKind
  19230. * - VertexBuffer.MatricesIndicesKind
  19231. * - VertexBuffer.MatricesIndicesExtraKind
  19232. * - VertexBuffer.MatricesWeightsKind
  19233. * - VertexBuffer.MatricesWeightsExtraKind
  19234. *
  19235. * Returns the Mesh.
  19236. */
  19237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19238. /**
  19239. * Sets the mesh indices.
  19240. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19241. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19242. * This method creates a new index buffer each call.
  19243. * Returns the Mesh.
  19244. */
  19245. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19246. /**
  19247. * Boolean : True if the mesh owns the requested kind of data.
  19248. */
  19249. isVerticesDataPresent(kind: string): boolean;
  19250. /**
  19251. * Returns an array of indices (IndicesArray).
  19252. */
  19253. getIndices(): Nullable<IndicesArray>;
  19254. get _positions(): Nullable<Vector3[]>;
  19255. /**
  19256. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19257. * This means the mesh underlying bounding box and sphere are recomputed.
  19258. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19259. * @returns the current mesh
  19260. */
  19261. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19262. /** @hidden */
  19263. _preActivate(): InstancedMesh;
  19264. /** @hidden */
  19265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19266. /** @hidden */
  19267. _postActivate(): void;
  19268. getWorldMatrix(): Matrix;
  19269. get isAnInstance(): boolean;
  19270. /**
  19271. * Returns the current associated LOD AbstractMesh.
  19272. */
  19273. getLOD(camera: Camera): AbstractMesh;
  19274. /** @hidden */
  19275. _syncSubMeshes(): InstancedMesh;
  19276. /** @hidden */
  19277. _generatePointsArray(): boolean;
  19278. /**
  19279. * Creates a new InstancedMesh from the current mesh.
  19280. * - name (string) : the cloned mesh name
  19281. * - newParent (optional Node) : the optional Node to parent the clone to.
  19282. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19283. *
  19284. * Returns the clone.
  19285. */
  19286. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19287. /**
  19288. * Disposes the InstancedMesh.
  19289. * Returns nothing.
  19290. */
  19291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19292. }
  19293. interface Mesh {
  19294. /**
  19295. * Register a custom buffer that will be instanced
  19296. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19297. * @param kind defines the buffer kind
  19298. * @param stride defines the stride in floats
  19299. */
  19300. registerInstancedBuffer(kind: string, stride: number): void;
  19301. /** @hidden */
  19302. _userInstancedBuffersStorage: {
  19303. data: {
  19304. [key: string]: Float32Array;
  19305. };
  19306. sizes: {
  19307. [key: string]: number;
  19308. };
  19309. vertexBuffers: {
  19310. [key: string]: Nullable<VertexBuffer>;
  19311. };
  19312. strides: {
  19313. [key: string]: number;
  19314. };
  19315. };
  19316. }
  19317. interface AbstractMesh {
  19318. /**
  19319. * Object used to store instanced buffers defined by user
  19320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19321. */
  19322. instancedBuffers: {
  19323. [key: string]: any;
  19324. };
  19325. }
  19326. }
  19327. declare module BABYLON {
  19328. /**
  19329. * Defines the options associated with the creation of a shader material.
  19330. */
  19331. export interface IShaderMaterialOptions {
  19332. /**
  19333. * Does the material work in alpha blend mode
  19334. */
  19335. needAlphaBlending: boolean;
  19336. /**
  19337. * Does the material work in alpha test mode
  19338. */
  19339. needAlphaTesting: boolean;
  19340. /**
  19341. * The list of attribute names used in the shader
  19342. */
  19343. attributes: string[];
  19344. /**
  19345. * The list of unifrom names used in the shader
  19346. */
  19347. uniforms: string[];
  19348. /**
  19349. * The list of UBO names used in the shader
  19350. */
  19351. uniformBuffers: string[];
  19352. /**
  19353. * The list of sampler names used in the shader
  19354. */
  19355. samplers: string[];
  19356. /**
  19357. * The list of defines used in the shader
  19358. */
  19359. defines: string[];
  19360. }
  19361. /**
  19362. * 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.
  19363. *
  19364. * This returned material effects how the mesh will look based on the code in the shaders.
  19365. *
  19366. * @see http://doc.babylonjs.com/how_to/shader_material
  19367. */
  19368. export class ShaderMaterial extends Material {
  19369. private _shaderPath;
  19370. private _options;
  19371. private _textures;
  19372. private _textureArrays;
  19373. private _floats;
  19374. private _ints;
  19375. private _floatsArrays;
  19376. private _colors3;
  19377. private _colors3Arrays;
  19378. private _colors4;
  19379. private _colors4Arrays;
  19380. private _vectors2;
  19381. private _vectors3;
  19382. private _vectors4;
  19383. private _matrices;
  19384. private _matrixArrays;
  19385. private _matrices3x3;
  19386. private _matrices2x2;
  19387. private _vectors2Arrays;
  19388. private _vectors3Arrays;
  19389. private _vectors4Arrays;
  19390. private _cachedWorldViewMatrix;
  19391. private _cachedWorldViewProjectionMatrix;
  19392. private _renderId;
  19393. private _multiview;
  19394. /**
  19395. * Instantiate a new shader material.
  19396. * 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.
  19397. * This returned material effects how the mesh will look based on the code in the shaders.
  19398. * @see http://doc.babylonjs.com/how_to/shader_material
  19399. * @param name Define the name of the material in the scene
  19400. * @param scene Define the scene the material belongs to
  19401. * @param shaderPath Defines the route to the shader code in one of three ways:
  19402. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19403. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19404. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19405. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19406. * @param options Define the options used to create the shader
  19407. */
  19408. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19409. /**
  19410. * Gets the shader path used to define the shader code
  19411. * It can be modified to trigger a new compilation
  19412. */
  19413. get shaderPath(): any;
  19414. /**
  19415. * Sets the shader path used to define the shader code
  19416. * It can be modified to trigger a new compilation
  19417. */
  19418. set shaderPath(shaderPath: any);
  19419. /**
  19420. * Gets the options used to compile the shader.
  19421. * They can be modified to trigger a new compilation
  19422. */
  19423. get options(): IShaderMaterialOptions;
  19424. /**
  19425. * Gets the current class name of the material e.g. "ShaderMaterial"
  19426. * Mainly use in serialization.
  19427. * @returns the class name
  19428. */
  19429. getClassName(): string;
  19430. /**
  19431. * Specifies if the material will require alpha blending
  19432. * @returns a boolean specifying if alpha blending is needed
  19433. */
  19434. needAlphaBlending(): boolean;
  19435. /**
  19436. * Specifies if this material should be rendered in alpha test mode
  19437. * @returns a boolean specifying if an alpha test is needed.
  19438. */
  19439. needAlphaTesting(): boolean;
  19440. private _checkUniform;
  19441. /**
  19442. * Set a texture in the shader.
  19443. * @param name Define the name of the uniform samplers as defined in the shader
  19444. * @param texture Define the texture to bind to this sampler
  19445. * @return the material itself allowing "fluent" like uniform updates
  19446. */
  19447. setTexture(name: string, texture: Texture): ShaderMaterial;
  19448. /**
  19449. * Set a texture array in the shader.
  19450. * @param name Define the name of the uniform sampler array as defined in the shader
  19451. * @param textures Define the list of textures to bind to this sampler
  19452. * @return the material itself allowing "fluent" like uniform updates
  19453. */
  19454. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19455. /**
  19456. * Set a float in the shader.
  19457. * @param name Define the name of the uniform as defined in the shader
  19458. * @param value Define the value to give to the uniform
  19459. * @return the material itself allowing "fluent" like uniform updates
  19460. */
  19461. setFloat(name: string, value: number): ShaderMaterial;
  19462. /**
  19463. * Set a int in the shader.
  19464. * @param name Define the name of the uniform as defined in the shader
  19465. * @param value Define the value to give to the uniform
  19466. * @return the material itself allowing "fluent" like uniform updates
  19467. */
  19468. setInt(name: string, value: number): ShaderMaterial;
  19469. /**
  19470. * Set an array of floats in the shader.
  19471. * @param name Define the name of the uniform as defined in the shader
  19472. * @param value Define the value to give to the uniform
  19473. * @return the material itself allowing "fluent" like uniform updates
  19474. */
  19475. setFloats(name: string, value: number[]): ShaderMaterial;
  19476. /**
  19477. * Set a vec3 in the shader from a Color3.
  19478. * @param name Define the name of the uniform as defined in the shader
  19479. * @param value Define the value to give to the uniform
  19480. * @return the material itself allowing "fluent" like uniform updates
  19481. */
  19482. setColor3(name: string, value: Color3): ShaderMaterial;
  19483. /**
  19484. * Set a vec3 array in the shader from a Color3 array.
  19485. * @param name Define the name of the uniform as defined in the shader
  19486. * @param value Define the value to give to the uniform
  19487. * @return the material itself allowing "fluent" like uniform updates
  19488. */
  19489. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19490. /**
  19491. * Set a vec4 in the shader from a Color4.
  19492. * @param name Define the name of the uniform as defined in the shader
  19493. * @param value Define the value to give to the uniform
  19494. * @return the material itself allowing "fluent" like uniform updates
  19495. */
  19496. setColor4(name: string, value: Color4): ShaderMaterial;
  19497. /**
  19498. * Set a vec4 array in the shader from a Color4 array.
  19499. * @param name Define the name of the uniform as defined in the shader
  19500. * @param value Define the value to give to the uniform
  19501. * @return the material itself allowing "fluent" like uniform updates
  19502. */
  19503. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19504. /**
  19505. * Set a vec2 in the shader from a Vector2.
  19506. * @param name Define the name of the uniform as defined in the shader
  19507. * @param value Define the value to give to the uniform
  19508. * @return the material itself allowing "fluent" like uniform updates
  19509. */
  19510. setVector2(name: string, value: Vector2): ShaderMaterial;
  19511. /**
  19512. * Set a vec3 in the shader from a Vector3.
  19513. * @param name Define the name of the uniform as defined in the shader
  19514. * @param value Define the value to give to the uniform
  19515. * @return the material itself allowing "fluent" like uniform updates
  19516. */
  19517. setVector3(name: string, value: Vector3): ShaderMaterial;
  19518. /**
  19519. * Set a vec4 in the shader from a Vector4.
  19520. * @param name Define the name of the uniform as defined in the shader
  19521. * @param value Define the value to give to the uniform
  19522. * @return the material itself allowing "fluent" like uniform updates
  19523. */
  19524. setVector4(name: string, value: Vector4): ShaderMaterial;
  19525. /**
  19526. * Set a mat4 in the shader from a Matrix.
  19527. * @param name Define the name of the uniform as defined in the shader
  19528. * @param value Define the value to give to the uniform
  19529. * @return the material itself allowing "fluent" like uniform updates
  19530. */
  19531. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19532. /**
  19533. * Set a float32Array in the shader from a matrix array.
  19534. * @param name Define the name of the uniform as defined in the shader
  19535. * @param value Define the value to give to the uniform
  19536. * @return the material itself allowing "fluent" like uniform updates
  19537. */
  19538. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19539. /**
  19540. * Set a mat3 in the shader from a Float32Array.
  19541. * @param name Define the name of the uniform as defined in the shader
  19542. * @param value Define the value to give to the uniform
  19543. * @return the material itself allowing "fluent" like uniform updates
  19544. */
  19545. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19546. /**
  19547. * Set a mat2 in the shader from a Float32Array.
  19548. * @param name Define the name of the uniform as defined in the shader
  19549. * @param value Define the value to give to the uniform
  19550. * @return the material itself allowing "fluent" like uniform updates
  19551. */
  19552. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19553. /**
  19554. * Set a vec2 array in the shader from a number array.
  19555. * @param name Define the name of the uniform as defined in the shader
  19556. * @param value Define the value to give to the uniform
  19557. * @return the material itself allowing "fluent" like uniform updates
  19558. */
  19559. setArray2(name: string, value: number[]): ShaderMaterial;
  19560. /**
  19561. * Set a vec3 array in the shader from a number array.
  19562. * @param name Define the name of the uniform as defined in the shader
  19563. * @param value Define the value to give to the uniform
  19564. * @return the material itself allowing "fluent" like uniform updates
  19565. */
  19566. setArray3(name: string, value: number[]): ShaderMaterial;
  19567. /**
  19568. * Set a vec4 array in the shader from a number array.
  19569. * @param name Define the name of the uniform as defined in the shader
  19570. * @param value Define the value to give to the uniform
  19571. * @return the material itself allowing "fluent" like uniform updates
  19572. */
  19573. setArray4(name: string, value: number[]): ShaderMaterial;
  19574. private _checkCache;
  19575. /**
  19576. * Specifies that the submesh is ready to be used
  19577. * @param mesh defines the mesh to check
  19578. * @param subMesh defines which submesh to check
  19579. * @param useInstances specifies that instances should be used
  19580. * @returns a boolean indicating that the submesh is ready or not
  19581. */
  19582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19583. /**
  19584. * Checks if the material is ready to render the requested mesh
  19585. * @param mesh Define the mesh to render
  19586. * @param useInstances Define whether or not the material is used with instances
  19587. * @returns true if ready, otherwise false
  19588. */
  19589. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19590. /**
  19591. * Binds the world matrix to the material
  19592. * @param world defines the world transformation matrix
  19593. */
  19594. bindOnlyWorldMatrix(world: Matrix): void;
  19595. /**
  19596. * Binds the material to the mesh
  19597. * @param world defines the world transformation matrix
  19598. * @param mesh defines the mesh to bind the material to
  19599. */
  19600. bind(world: Matrix, mesh?: Mesh): void;
  19601. /**
  19602. * Gets the active textures from the material
  19603. * @returns an array of textures
  19604. */
  19605. getActiveTextures(): BaseTexture[];
  19606. /**
  19607. * Specifies if the material uses a texture
  19608. * @param texture defines the texture to check against the material
  19609. * @returns a boolean specifying if the material uses the texture
  19610. */
  19611. hasTexture(texture: BaseTexture): boolean;
  19612. /**
  19613. * Makes a duplicate of the material, and gives it a new name
  19614. * @param name defines the new name for the duplicated material
  19615. * @returns the cloned material
  19616. */
  19617. clone(name: string): ShaderMaterial;
  19618. /**
  19619. * Disposes the material
  19620. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19621. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19622. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19623. */
  19624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19625. /**
  19626. * Serializes this material in a JSON representation
  19627. * @returns the serialized material object
  19628. */
  19629. serialize(): any;
  19630. /**
  19631. * Creates a shader material from parsed shader material data
  19632. * @param source defines the JSON represnetation of the material
  19633. * @param scene defines the hosting scene
  19634. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19635. * @returns a new material
  19636. */
  19637. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /** @hidden */
  19642. export var colorPixelShader: {
  19643. name: string;
  19644. shader: string;
  19645. };
  19646. }
  19647. declare module BABYLON {
  19648. /** @hidden */
  19649. export var colorVertexShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module BABYLON {
  19655. /**
  19656. * Line mesh
  19657. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19658. */
  19659. export class LinesMesh extends Mesh {
  19660. /**
  19661. * If vertex color should be applied to the mesh
  19662. */
  19663. readonly useVertexColor?: boolean | undefined;
  19664. /**
  19665. * If vertex alpha should be applied to the mesh
  19666. */
  19667. readonly useVertexAlpha?: boolean | undefined;
  19668. /**
  19669. * Color of the line (Default: White)
  19670. */
  19671. color: Color3;
  19672. /**
  19673. * Alpha of the line (Default: 1)
  19674. */
  19675. alpha: number;
  19676. /**
  19677. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19678. * This margin is expressed in world space coordinates, so its value may vary.
  19679. * Default value is 0.1
  19680. */
  19681. intersectionThreshold: number;
  19682. private _colorShader;
  19683. private color4;
  19684. /**
  19685. * Creates a new LinesMesh
  19686. * @param name defines the name
  19687. * @param scene defines the hosting scene
  19688. * @param parent defines the parent mesh if any
  19689. * @param source defines the optional source LinesMesh used to clone data from
  19690. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19691. * When false, achieved by calling a clone(), also passing False.
  19692. * This will make creation of children, recursive.
  19693. * @param useVertexColor defines if this LinesMesh supports vertex color
  19694. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19695. */
  19696. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19697. /**
  19698. * If vertex color should be applied to the mesh
  19699. */
  19700. useVertexColor?: boolean | undefined,
  19701. /**
  19702. * If vertex alpha should be applied to the mesh
  19703. */
  19704. useVertexAlpha?: boolean | undefined);
  19705. private _addClipPlaneDefine;
  19706. private _removeClipPlaneDefine;
  19707. isReady(): boolean;
  19708. /**
  19709. * Returns the string "LineMesh"
  19710. */
  19711. getClassName(): string;
  19712. /**
  19713. * @hidden
  19714. */
  19715. get material(): Material;
  19716. /**
  19717. * @hidden
  19718. */
  19719. set material(value: Material);
  19720. /**
  19721. * @hidden
  19722. */
  19723. get checkCollisions(): boolean;
  19724. /** @hidden */
  19725. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19726. /** @hidden */
  19727. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19728. /**
  19729. * Disposes of the line mesh
  19730. * @param doNotRecurse If children should be disposed
  19731. */
  19732. dispose(doNotRecurse?: boolean): void;
  19733. /**
  19734. * Returns a new LineMesh object cloned from the current one.
  19735. */
  19736. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19737. /**
  19738. * Creates a new InstancedLinesMesh object from the mesh model.
  19739. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19740. * @param name defines the name of the new instance
  19741. * @returns a new InstancedLinesMesh
  19742. */
  19743. createInstance(name: string): InstancedLinesMesh;
  19744. }
  19745. /**
  19746. * Creates an instance based on a source LinesMesh
  19747. */
  19748. export class InstancedLinesMesh extends InstancedMesh {
  19749. /**
  19750. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19751. * This margin is expressed in world space coordinates, so its value may vary.
  19752. * Initilized with the intersectionThreshold value of the source LinesMesh
  19753. */
  19754. intersectionThreshold: number;
  19755. constructor(name: string, source: LinesMesh);
  19756. /**
  19757. * Returns the string "InstancedLinesMesh".
  19758. */
  19759. getClassName(): string;
  19760. }
  19761. }
  19762. declare module BABYLON {
  19763. /** @hidden */
  19764. export var linePixelShader: {
  19765. name: string;
  19766. shader: string;
  19767. };
  19768. }
  19769. declare module BABYLON {
  19770. /** @hidden */
  19771. export var lineVertexShader: {
  19772. name: string;
  19773. shader: string;
  19774. };
  19775. }
  19776. declare module BABYLON {
  19777. interface AbstractMesh {
  19778. /**
  19779. * Gets the edgesRenderer associated with the mesh
  19780. */
  19781. edgesRenderer: Nullable<EdgesRenderer>;
  19782. }
  19783. interface LinesMesh {
  19784. /**
  19785. * Enables the edge rendering mode on the mesh.
  19786. * This mode makes the mesh edges visible
  19787. * @param epsilon defines the maximal distance between two angles to detect a face
  19788. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19789. * @returns the currentAbstractMesh
  19790. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19791. */
  19792. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19793. }
  19794. interface InstancedLinesMesh {
  19795. /**
  19796. * Enables the edge rendering mode on the mesh.
  19797. * This mode makes the mesh edges visible
  19798. * @param epsilon defines the maximal distance between two angles to detect a face
  19799. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19800. * @returns the current InstancedLinesMesh
  19801. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19802. */
  19803. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19804. }
  19805. /**
  19806. * Defines the minimum contract an Edges renderer should follow.
  19807. */
  19808. export interface IEdgesRenderer extends IDisposable {
  19809. /**
  19810. * Gets or sets a boolean indicating if the edgesRenderer is active
  19811. */
  19812. isEnabled: boolean;
  19813. /**
  19814. * Renders the edges of the attached mesh,
  19815. */
  19816. render(): void;
  19817. /**
  19818. * Checks wether or not the edges renderer is ready to render.
  19819. * @return true if ready, otherwise false.
  19820. */
  19821. isReady(): boolean;
  19822. }
  19823. /**
  19824. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19825. */
  19826. export class EdgesRenderer implements IEdgesRenderer {
  19827. /**
  19828. * Define the size of the edges with an orthographic camera
  19829. */
  19830. edgesWidthScalerForOrthographic: number;
  19831. /**
  19832. * Define the size of the edges with a perspective camera
  19833. */
  19834. edgesWidthScalerForPerspective: number;
  19835. protected _source: AbstractMesh;
  19836. protected _linesPositions: number[];
  19837. protected _linesNormals: number[];
  19838. protected _linesIndices: number[];
  19839. protected _epsilon: number;
  19840. protected _indicesCount: number;
  19841. protected _lineShader: ShaderMaterial;
  19842. protected _ib: DataBuffer;
  19843. protected _buffers: {
  19844. [key: string]: Nullable<VertexBuffer>;
  19845. };
  19846. protected _checkVerticesInsteadOfIndices: boolean;
  19847. private _meshRebuildObserver;
  19848. private _meshDisposeObserver;
  19849. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19850. isEnabled: boolean;
  19851. /**
  19852. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19853. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19854. * @param source Mesh used to create edges
  19855. * @param epsilon sum of angles in adjacency to check for edge
  19856. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19857. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19858. */
  19859. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19860. protected _prepareRessources(): void;
  19861. /** @hidden */
  19862. _rebuild(): void;
  19863. /**
  19864. * Releases the required resources for the edges renderer
  19865. */
  19866. dispose(): void;
  19867. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19868. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19869. /**
  19870. * Checks if the pair of p0 and p1 is en edge
  19871. * @param faceIndex
  19872. * @param edge
  19873. * @param faceNormals
  19874. * @param p0
  19875. * @param p1
  19876. * @private
  19877. */
  19878. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19879. /**
  19880. * push line into the position, normal and index buffer
  19881. * @protected
  19882. */
  19883. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19884. /**
  19885. * Generates lines edges from adjacencjes
  19886. * @private
  19887. */
  19888. _generateEdgesLines(): void;
  19889. /**
  19890. * Checks wether or not the edges renderer is ready to render.
  19891. * @return true if ready, otherwise false.
  19892. */
  19893. isReady(): boolean;
  19894. /**
  19895. * Renders the edges of the attached mesh,
  19896. */
  19897. render(): void;
  19898. }
  19899. /**
  19900. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19901. */
  19902. export class LineEdgesRenderer extends EdgesRenderer {
  19903. /**
  19904. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19905. * @param source LineMesh used to generate edges
  19906. * @param epsilon not important (specified angle for edge detection)
  19907. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19908. */
  19909. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19910. /**
  19911. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19912. */
  19913. _generateEdgesLines(): void;
  19914. }
  19915. }
  19916. declare module BABYLON {
  19917. /**
  19918. * This represents the object necessary to create a rendering group.
  19919. * This is exclusively used and created by the rendering manager.
  19920. * To modify the behavior, you use the available helpers in your scene or meshes.
  19921. * @hidden
  19922. */
  19923. export class RenderingGroup {
  19924. index: number;
  19925. private static _zeroVector;
  19926. private _scene;
  19927. private _opaqueSubMeshes;
  19928. private _transparentSubMeshes;
  19929. private _alphaTestSubMeshes;
  19930. private _depthOnlySubMeshes;
  19931. private _particleSystems;
  19932. private _spriteManagers;
  19933. private _opaqueSortCompareFn;
  19934. private _alphaTestSortCompareFn;
  19935. private _transparentSortCompareFn;
  19936. private _renderOpaque;
  19937. private _renderAlphaTest;
  19938. private _renderTransparent;
  19939. /** @hidden */
  19940. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19941. onBeforeTransparentRendering: () => void;
  19942. /**
  19943. * Set the opaque sort comparison function.
  19944. * If null the sub meshes will be render in the order they were created
  19945. */
  19946. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19947. /**
  19948. * Set the alpha test sort comparison function.
  19949. * If null the sub meshes will be render in the order they were created
  19950. */
  19951. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19952. /**
  19953. * Set the transparent sort comparison function.
  19954. * If null the sub meshes will be render in the order they were created
  19955. */
  19956. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19957. /**
  19958. * Creates a new rendering group.
  19959. * @param index The rendering group index
  19960. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19961. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19962. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19963. */
  19964. 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>);
  19965. /**
  19966. * Render all the sub meshes contained in the group.
  19967. * @param customRenderFunction Used to override the default render behaviour of the group.
  19968. * @returns true if rendered some submeshes.
  19969. */
  19970. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19971. /**
  19972. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19973. * @param subMeshes The submeshes to render
  19974. */
  19975. private renderOpaqueSorted;
  19976. /**
  19977. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19978. * @param subMeshes The submeshes to render
  19979. */
  19980. private renderAlphaTestSorted;
  19981. /**
  19982. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19983. * @param subMeshes The submeshes to render
  19984. */
  19985. private renderTransparentSorted;
  19986. /**
  19987. * Renders the submeshes in a specified order.
  19988. * @param subMeshes The submeshes to sort before render
  19989. * @param sortCompareFn The comparison function use to sort
  19990. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19991. * @param transparent Specifies to activate blending if true
  19992. */
  19993. private static renderSorted;
  19994. /**
  19995. * Renders the submeshes in the order they were dispatched (no sort applied).
  19996. * @param subMeshes The submeshes to render
  19997. */
  19998. private static renderUnsorted;
  19999. /**
  20000. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20001. * are rendered back to front if in the same alpha index.
  20002. *
  20003. * @param a The first submesh
  20004. * @param b The second submesh
  20005. * @returns The result of the comparison
  20006. */
  20007. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20008. /**
  20009. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20010. * are rendered back to front.
  20011. *
  20012. * @param a The first submesh
  20013. * @param b The second submesh
  20014. * @returns The result of the comparison
  20015. */
  20016. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20017. /**
  20018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20019. * are rendered front to back (prevent overdraw).
  20020. *
  20021. * @param a The first submesh
  20022. * @param b The second submesh
  20023. * @returns The result of the comparison
  20024. */
  20025. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20026. /**
  20027. * Resets the different lists of submeshes to prepare a new frame.
  20028. */
  20029. prepare(): void;
  20030. dispose(): void;
  20031. /**
  20032. * Inserts the submesh in its correct queue depending on its material.
  20033. * @param subMesh The submesh to dispatch
  20034. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20035. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20036. */
  20037. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20038. dispatchSprites(spriteManager: ISpriteManager): void;
  20039. dispatchParticles(particleSystem: IParticleSystem): void;
  20040. private _renderParticles;
  20041. private _renderSprites;
  20042. }
  20043. }
  20044. declare module BABYLON {
  20045. /**
  20046. * Interface describing the different options available in the rendering manager
  20047. * regarding Auto Clear between groups.
  20048. */
  20049. export interface IRenderingManagerAutoClearSetup {
  20050. /**
  20051. * Defines whether or not autoclear is enable.
  20052. */
  20053. autoClear: boolean;
  20054. /**
  20055. * Defines whether or not to autoclear the depth buffer.
  20056. */
  20057. depth: boolean;
  20058. /**
  20059. * Defines whether or not to autoclear the stencil buffer.
  20060. */
  20061. stencil: boolean;
  20062. }
  20063. /**
  20064. * This class is used by the onRenderingGroupObservable
  20065. */
  20066. export class RenderingGroupInfo {
  20067. /**
  20068. * The Scene that being rendered
  20069. */
  20070. scene: Scene;
  20071. /**
  20072. * The camera currently used for the rendering pass
  20073. */
  20074. camera: Nullable<Camera>;
  20075. /**
  20076. * The ID of the renderingGroup being processed
  20077. */
  20078. renderingGroupId: number;
  20079. }
  20080. /**
  20081. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20082. * It is enable to manage the different groups as well as the different necessary sort functions.
  20083. * This should not be used directly aside of the few static configurations
  20084. */
  20085. export class RenderingManager {
  20086. /**
  20087. * The max id used for rendering groups (not included)
  20088. */
  20089. static MAX_RENDERINGGROUPS: number;
  20090. /**
  20091. * The min id used for rendering groups (included)
  20092. */
  20093. static MIN_RENDERINGGROUPS: number;
  20094. /**
  20095. * Used to globally prevent autoclearing scenes.
  20096. */
  20097. static AUTOCLEAR: boolean;
  20098. /**
  20099. * @hidden
  20100. */
  20101. _useSceneAutoClearSetup: boolean;
  20102. private _scene;
  20103. private _renderingGroups;
  20104. private _depthStencilBufferAlreadyCleaned;
  20105. private _autoClearDepthStencil;
  20106. private _customOpaqueSortCompareFn;
  20107. private _customAlphaTestSortCompareFn;
  20108. private _customTransparentSortCompareFn;
  20109. private _renderingGroupInfo;
  20110. /**
  20111. * Instantiates a new rendering group for a particular scene
  20112. * @param scene Defines the scene the groups belongs to
  20113. */
  20114. constructor(scene: Scene);
  20115. private _clearDepthStencilBuffer;
  20116. /**
  20117. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20118. * @hidden
  20119. */
  20120. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20121. /**
  20122. * Resets the different information of the group to prepare a new frame
  20123. * @hidden
  20124. */
  20125. reset(): void;
  20126. /**
  20127. * Dispose and release the group and its associated resources.
  20128. * @hidden
  20129. */
  20130. dispose(): void;
  20131. /**
  20132. * Clear the info related to rendering groups preventing retention points during dispose.
  20133. */
  20134. freeRenderingGroups(): void;
  20135. private _prepareRenderingGroup;
  20136. /**
  20137. * Add a sprite manager to the rendering manager in order to render it this frame.
  20138. * @param spriteManager Define the sprite manager to render
  20139. */
  20140. dispatchSprites(spriteManager: ISpriteManager): void;
  20141. /**
  20142. * Add a particle system to the rendering manager in order to render it this frame.
  20143. * @param particleSystem Define the particle system to render
  20144. */
  20145. dispatchParticles(particleSystem: IParticleSystem): void;
  20146. /**
  20147. * Add a submesh to the manager in order to render it this frame
  20148. * @param subMesh The submesh to dispatch
  20149. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20150. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20151. */
  20152. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20153. /**
  20154. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20155. * This allowed control for front to back rendering or reversly depending of the special needs.
  20156. *
  20157. * @param renderingGroupId The rendering group id corresponding to its index
  20158. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20159. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20160. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20161. */
  20162. 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;
  20163. /**
  20164. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20165. *
  20166. * @param renderingGroupId The rendering group id corresponding to its index
  20167. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20168. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20169. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20170. */
  20171. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20172. /**
  20173. * Gets the current auto clear configuration for one rendering group of the rendering
  20174. * manager.
  20175. * @param index the rendering group index to get the information for
  20176. * @returns The auto clear setup for the requested rendering group
  20177. */
  20178. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20179. }
  20180. }
  20181. declare module BABYLON {
  20182. /**
  20183. * This Helps creating a texture that will be created from a camera in your scene.
  20184. * It is basically a dynamic texture that could be used to create special effects for instance.
  20185. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20186. */
  20187. export class RenderTargetTexture extends Texture {
  20188. isCube: boolean;
  20189. /**
  20190. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20191. */
  20192. static readonly REFRESHRATE_RENDER_ONCE: number;
  20193. /**
  20194. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20195. */
  20196. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20197. /**
  20198. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20199. * the central point of your effect and can save a lot of performances.
  20200. */
  20201. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20202. /**
  20203. * Use this predicate to dynamically define the list of mesh you want to render.
  20204. * If set, the renderList property will be overwritten.
  20205. */
  20206. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20207. private _renderList;
  20208. /**
  20209. * Use this list to define the list of mesh you want to render.
  20210. */
  20211. get renderList(): Nullable<Array<AbstractMesh>>;
  20212. set renderList(value: Nullable<Array<AbstractMesh>>);
  20213. private _hookArray;
  20214. /**
  20215. * Define if particles should be rendered in your texture.
  20216. */
  20217. renderParticles: boolean;
  20218. /**
  20219. * Define if sprites should be rendered in your texture.
  20220. */
  20221. renderSprites: boolean;
  20222. /**
  20223. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20224. */
  20225. coordinatesMode: number;
  20226. /**
  20227. * Define the camera used to render the texture.
  20228. */
  20229. activeCamera: Nullable<Camera>;
  20230. /**
  20231. * Override the render function of the texture with your own one.
  20232. */
  20233. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20234. /**
  20235. * Define if camera post processes should be use while rendering the texture.
  20236. */
  20237. useCameraPostProcesses: boolean;
  20238. /**
  20239. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20240. */
  20241. ignoreCameraViewport: boolean;
  20242. private _postProcessManager;
  20243. private _postProcesses;
  20244. private _resizeObserver;
  20245. /**
  20246. * An event triggered when the texture is unbind.
  20247. */
  20248. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20249. /**
  20250. * An event triggered when the texture is unbind.
  20251. */
  20252. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20253. private _onAfterUnbindObserver;
  20254. /**
  20255. * Set a after unbind callback in the texture.
  20256. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20257. */
  20258. set onAfterUnbind(callback: () => void);
  20259. /**
  20260. * An event triggered before rendering the texture
  20261. */
  20262. onBeforeRenderObservable: Observable<number>;
  20263. private _onBeforeRenderObserver;
  20264. /**
  20265. * Set a before render callback in the texture.
  20266. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20267. */
  20268. set onBeforeRender(callback: (faceIndex: number) => void);
  20269. /**
  20270. * An event triggered after rendering the texture
  20271. */
  20272. onAfterRenderObservable: Observable<number>;
  20273. private _onAfterRenderObserver;
  20274. /**
  20275. * Set a after render callback in the texture.
  20276. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20277. */
  20278. set onAfterRender(callback: (faceIndex: number) => void);
  20279. /**
  20280. * An event triggered after the texture clear
  20281. */
  20282. onClearObservable: Observable<Engine>;
  20283. private _onClearObserver;
  20284. /**
  20285. * Set a clear callback in the texture.
  20286. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20287. */
  20288. set onClear(callback: (Engine: Engine) => void);
  20289. /**
  20290. * An event triggered when the texture is resized.
  20291. */
  20292. onResizeObservable: Observable<RenderTargetTexture>;
  20293. /**
  20294. * Define the clear color of the Render Target if it should be different from the scene.
  20295. */
  20296. clearColor: Color4;
  20297. protected _size: number | {
  20298. width: number;
  20299. height: number;
  20300. };
  20301. protected _initialSizeParameter: number | {
  20302. width: number;
  20303. height: number;
  20304. } | {
  20305. ratio: number;
  20306. };
  20307. protected _sizeRatio: Nullable<number>;
  20308. /** @hidden */
  20309. _generateMipMaps: boolean;
  20310. protected _renderingManager: RenderingManager;
  20311. /** @hidden */
  20312. _waitingRenderList: string[];
  20313. protected _doNotChangeAspectRatio: boolean;
  20314. protected _currentRefreshId: number;
  20315. protected _refreshRate: number;
  20316. protected _textureMatrix: Matrix;
  20317. protected _samples: number;
  20318. protected _renderTargetOptions: RenderTargetCreationOptions;
  20319. /**
  20320. * Gets render target creation options that were used.
  20321. */
  20322. get renderTargetOptions(): RenderTargetCreationOptions;
  20323. protected _engine: Engine;
  20324. protected _onRatioRescale(): void;
  20325. /**
  20326. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20327. * It must define where the camera used to render the texture is set
  20328. */
  20329. boundingBoxPosition: Vector3;
  20330. private _boundingBoxSize;
  20331. /**
  20332. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20333. * When defined, the cubemap will switch to local mode
  20334. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20335. * @example https://www.babylonjs-playground.com/#RNASML
  20336. */
  20337. set boundingBoxSize(value: Vector3);
  20338. get boundingBoxSize(): Vector3;
  20339. /**
  20340. * In case the RTT has been created with a depth texture, get the associated
  20341. * depth texture.
  20342. * Otherwise, return null.
  20343. */
  20344. depthStencilTexture: Nullable<InternalTexture>;
  20345. /**
  20346. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20347. * or used a shadow, depth texture...
  20348. * @param name The friendly name of the texture
  20349. * @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)
  20350. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20351. * @param generateMipMaps True if mip maps need to be generated after render.
  20352. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20353. * @param type The type of the buffer in the RTT (int, half float, float...)
  20354. * @param isCube True if a cube texture needs to be created
  20355. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20356. * @param generateDepthBuffer True to generate a depth buffer
  20357. * @param generateStencilBuffer True to generate a stencil buffer
  20358. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20359. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20360. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20361. */
  20362. constructor(name: string, size: number | {
  20363. width: number;
  20364. height: number;
  20365. } | {
  20366. ratio: number;
  20367. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20368. /**
  20369. * Creates a depth stencil texture.
  20370. * This is only available in WebGL 2 or with the depth texture extension available.
  20371. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20372. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20373. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20374. */
  20375. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20376. private _processSizeParameter;
  20377. /**
  20378. * Define the number of samples to use in case of MSAA.
  20379. * It defaults to one meaning no MSAA has been enabled.
  20380. */
  20381. get samples(): number;
  20382. set samples(value: number);
  20383. /**
  20384. * Resets the refresh counter of the texture and start bak from scratch.
  20385. * Could be useful to regenerate the texture if it is setup to render only once.
  20386. */
  20387. resetRefreshCounter(): void;
  20388. /**
  20389. * Define the refresh rate of the texture or the rendering frequency.
  20390. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20391. */
  20392. get refreshRate(): number;
  20393. set refreshRate(value: number);
  20394. /**
  20395. * Adds a post process to the render target rendering passes.
  20396. * @param postProcess define the post process to add
  20397. */
  20398. addPostProcess(postProcess: PostProcess): void;
  20399. /**
  20400. * Clear all the post processes attached to the render target
  20401. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20402. */
  20403. clearPostProcesses(dispose?: boolean): void;
  20404. /**
  20405. * Remove one of the post process from the list of attached post processes to the texture
  20406. * @param postProcess define the post process to remove from the list
  20407. */
  20408. removePostProcess(postProcess: PostProcess): void;
  20409. /** @hidden */
  20410. _shouldRender(): boolean;
  20411. /**
  20412. * Gets the actual render size of the texture.
  20413. * @returns the width of the render size
  20414. */
  20415. getRenderSize(): number;
  20416. /**
  20417. * Gets the actual render width of the texture.
  20418. * @returns the width of the render size
  20419. */
  20420. getRenderWidth(): number;
  20421. /**
  20422. * Gets the actual render height of the texture.
  20423. * @returns the height of the render size
  20424. */
  20425. getRenderHeight(): number;
  20426. /**
  20427. * Get if the texture can be rescaled or not.
  20428. */
  20429. get canRescale(): boolean;
  20430. /**
  20431. * Resize the texture using a ratio.
  20432. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20433. */
  20434. scale(ratio: number): void;
  20435. /**
  20436. * Get the texture reflection matrix used to rotate/transform the reflection.
  20437. * @returns the reflection matrix
  20438. */
  20439. getReflectionTextureMatrix(): Matrix;
  20440. /**
  20441. * Resize the texture to a new desired size.
  20442. * Be carrefull as it will recreate all the data in the new texture.
  20443. * @param size Define the new size. It can be:
  20444. * - a number for squared texture,
  20445. * - an object containing { width: number, height: number }
  20446. * - or an object containing a ratio { ratio: number }
  20447. */
  20448. resize(size: number | {
  20449. width: number;
  20450. height: number;
  20451. } | {
  20452. ratio: number;
  20453. }): void;
  20454. /**
  20455. * Renders all the objects from the render list into the texture.
  20456. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20457. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20458. */
  20459. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20460. private _bestReflectionRenderTargetDimension;
  20461. /**
  20462. * @hidden
  20463. * @param faceIndex face index to bind to if this is a cubetexture
  20464. */
  20465. _bindFrameBuffer(faceIndex?: number): void;
  20466. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20467. private renderToTarget;
  20468. /**
  20469. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20470. * This allowed control for front to back rendering or reversly depending of the special needs.
  20471. *
  20472. * @param renderingGroupId The rendering group id corresponding to its index
  20473. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20474. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20475. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20476. */
  20477. 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;
  20478. /**
  20479. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20480. *
  20481. * @param renderingGroupId The rendering group id corresponding to its index
  20482. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20483. */
  20484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20485. /**
  20486. * Clones the texture.
  20487. * @returns the cloned texture
  20488. */
  20489. clone(): RenderTargetTexture;
  20490. /**
  20491. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20492. * @returns The JSON representation of the texture
  20493. */
  20494. serialize(): any;
  20495. /**
  20496. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20497. */
  20498. disposeFramebufferObjects(): void;
  20499. /**
  20500. * Dispose the texture and release its associated resources.
  20501. */
  20502. dispose(): void;
  20503. /** @hidden */
  20504. _rebuild(): void;
  20505. /**
  20506. * Clear the info related to rendering groups preventing retention point in material dispose.
  20507. */
  20508. freeRenderingGroups(): void;
  20509. /**
  20510. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20511. * @returns the view count
  20512. */
  20513. getViewCount(): number;
  20514. }
  20515. }
  20516. declare module BABYLON {
  20517. /**
  20518. * Options for compiling materials.
  20519. */
  20520. export interface IMaterialCompilationOptions {
  20521. /**
  20522. * Defines whether clip planes are enabled.
  20523. */
  20524. clipPlane: boolean;
  20525. /**
  20526. * Defines whether instances are enabled.
  20527. */
  20528. useInstances: boolean;
  20529. }
  20530. /**
  20531. * Base class for the main features of a material in Babylon.js
  20532. */
  20533. export class Material implements IAnimatable {
  20534. /**
  20535. * Returns the triangle fill mode
  20536. */
  20537. static readonly TriangleFillMode: number;
  20538. /**
  20539. * Returns the wireframe mode
  20540. */
  20541. static readonly WireFrameFillMode: number;
  20542. /**
  20543. * Returns the point fill mode
  20544. */
  20545. static readonly PointFillMode: number;
  20546. /**
  20547. * Returns the point list draw mode
  20548. */
  20549. static readonly PointListDrawMode: number;
  20550. /**
  20551. * Returns the line list draw mode
  20552. */
  20553. static readonly LineListDrawMode: number;
  20554. /**
  20555. * Returns the line loop draw mode
  20556. */
  20557. static readonly LineLoopDrawMode: number;
  20558. /**
  20559. * Returns the line strip draw mode
  20560. */
  20561. static readonly LineStripDrawMode: number;
  20562. /**
  20563. * Returns the triangle strip draw mode
  20564. */
  20565. static readonly TriangleStripDrawMode: number;
  20566. /**
  20567. * Returns the triangle fan draw mode
  20568. */
  20569. static readonly TriangleFanDrawMode: number;
  20570. /**
  20571. * Stores the clock-wise side orientation
  20572. */
  20573. static readonly ClockWiseSideOrientation: number;
  20574. /**
  20575. * Stores the counter clock-wise side orientation
  20576. */
  20577. static readonly CounterClockWiseSideOrientation: number;
  20578. /**
  20579. * The dirty texture flag value
  20580. */
  20581. static readonly TextureDirtyFlag: number;
  20582. /**
  20583. * The dirty light flag value
  20584. */
  20585. static readonly LightDirtyFlag: number;
  20586. /**
  20587. * The dirty fresnel flag value
  20588. */
  20589. static readonly FresnelDirtyFlag: number;
  20590. /**
  20591. * The dirty attribute flag value
  20592. */
  20593. static readonly AttributesDirtyFlag: number;
  20594. /**
  20595. * The dirty misc flag value
  20596. */
  20597. static readonly MiscDirtyFlag: number;
  20598. /**
  20599. * The all dirty flag value
  20600. */
  20601. static readonly AllDirtyFlag: number;
  20602. /**
  20603. * The ID of the material
  20604. */
  20605. id: string;
  20606. /**
  20607. * Gets or sets the unique id of the material
  20608. */
  20609. uniqueId: number;
  20610. /**
  20611. * The name of the material
  20612. */
  20613. name: string;
  20614. /**
  20615. * Gets or sets user defined metadata
  20616. */
  20617. metadata: any;
  20618. /**
  20619. * For internal use only. Please do not use.
  20620. */
  20621. reservedDataStore: any;
  20622. /**
  20623. * Specifies if the ready state should be checked on each call
  20624. */
  20625. checkReadyOnEveryCall: boolean;
  20626. /**
  20627. * Specifies if the ready state should be checked once
  20628. */
  20629. checkReadyOnlyOnce: boolean;
  20630. /**
  20631. * The state of the material
  20632. */
  20633. state: string;
  20634. /**
  20635. * The alpha value of the material
  20636. */
  20637. protected _alpha: number;
  20638. /**
  20639. * List of inspectable custom properties (used by the Inspector)
  20640. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20641. */
  20642. inspectableCustomProperties: IInspectable[];
  20643. /**
  20644. * Sets the alpha value of the material
  20645. */
  20646. set alpha(value: number);
  20647. /**
  20648. * Gets the alpha value of the material
  20649. */
  20650. get alpha(): number;
  20651. /**
  20652. * Specifies if back face culling is enabled
  20653. */
  20654. protected _backFaceCulling: boolean;
  20655. /**
  20656. * Sets the back-face culling state
  20657. */
  20658. set backFaceCulling(value: boolean);
  20659. /**
  20660. * Gets the back-face culling state
  20661. */
  20662. get backFaceCulling(): boolean;
  20663. /**
  20664. * Stores the value for side orientation
  20665. */
  20666. sideOrientation: number;
  20667. /**
  20668. * Callback triggered when the material is compiled
  20669. */
  20670. onCompiled: Nullable<(effect: Effect) => void>;
  20671. /**
  20672. * Callback triggered when an error occurs
  20673. */
  20674. onError: Nullable<(effect: Effect, errors: string) => void>;
  20675. /**
  20676. * Callback triggered to get the render target textures
  20677. */
  20678. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20679. /**
  20680. * Gets a boolean indicating that current material needs to register RTT
  20681. */
  20682. get hasRenderTargetTextures(): boolean;
  20683. /**
  20684. * Specifies if the material should be serialized
  20685. */
  20686. doNotSerialize: boolean;
  20687. /**
  20688. * @hidden
  20689. */
  20690. _storeEffectOnSubMeshes: boolean;
  20691. /**
  20692. * Stores the animations for the material
  20693. */
  20694. animations: Nullable<Array<Animation>>;
  20695. /**
  20696. * An event triggered when the material is disposed
  20697. */
  20698. onDisposeObservable: Observable<Material>;
  20699. /**
  20700. * An observer which watches for dispose events
  20701. */
  20702. private _onDisposeObserver;
  20703. private _onUnBindObservable;
  20704. /**
  20705. * Called during a dispose event
  20706. */
  20707. set onDispose(callback: () => void);
  20708. private _onBindObservable;
  20709. /**
  20710. * An event triggered when the material is bound
  20711. */
  20712. get onBindObservable(): Observable<AbstractMesh>;
  20713. /**
  20714. * An observer which watches for bind events
  20715. */
  20716. private _onBindObserver;
  20717. /**
  20718. * Called during a bind event
  20719. */
  20720. set onBind(callback: (Mesh: AbstractMesh) => void);
  20721. /**
  20722. * An event triggered when the material is unbound
  20723. */
  20724. get onUnBindObservable(): Observable<Material>;
  20725. /**
  20726. * Stores the value of the alpha mode
  20727. */
  20728. private _alphaMode;
  20729. /**
  20730. * Sets the value of the alpha mode.
  20731. *
  20732. * | Value | Type | Description |
  20733. * | --- | --- | --- |
  20734. * | 0 | ALPHA_DISABLE | |
  20735. * | 1 | ALPHA_ADD | |
  20736. * | 2 | ALPHA_COMBINE | |
  20737. * | 3 | ALPHA_SUBTRACT | |
  20738. * | 4 | ALPHA_MULTIPLY | |
  20739. * | 5 | ALPHA_MAXIMIZED | |
  20740. * | 6 | ALPHA_ONEONE | |
  20741. * | 7 | ALPHA_PREMULTIPLIED | |
  20742. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20743. * | 9 | ALPHA_INTERPOLATE | |
  20744. * | 10 | ALPHA_SCREENMODE | |
  20745. *
  20746. */
  20747. set alphaMode(value: number);
  20748. /**
  20749. * Gets the value of the alpha mode
  20750. */
  20751. get alphaMode(): number;
  20752. /**
  20753. * Stores the state of the need depth pre-pass value
  20754. */
  20755. private _needDepthPrePass;
  20756. /**
  20757. * Sets the need depth pre-pass value
  20758. */
  20759. set needDepthPrePass(value: boolean);
  20760. /**
  20761. * Gets the depth pre-pass value
  20762. */
  20763. get needDepthPrePass(): boolean;
  20764. /**
  20765. * Specifies if depth writing should be disabled
  20766. */
  20767. disableDepthWrite: boolean;
  20768. /**
  20769. * Specifies if depth writing should be forced
  20770. */
  20771. forceDepthWrite: boolean;
  20772. /**
  20773. * Specifies the depth function that should be used. 0 means the default engine function
  20774. */
  20775. depthFunction: number;
  20776. /**
  20777. * Specifies if there should be a separate pass for culling
  20778. */
  20779. separateCullingPass: boolean;
  20780. /**
  20781. * Stores the state specifing if fog should be enabled
  20782. */
  20783. private _fogEnabled;
  20784. /**
  20785. * Sets the state for enabling fog
  20786. */
  20787. set fogEnabled(value: boolean);
  20788. /**
  20789. * Gets the value of the fog enabled state
  20790. */
  20791. get fogEnabled(): boolean;
  20792. /**
  20793. * Stores the size of points
  20794. */
  20795. pointSize: number;
  20796. /**
  20797. * Stores the z offset value
  20798. */
  20799. zOffset: number;
  20800. /**
  20801. * Gets a value specifying if wireframe mode is enabled
  20802. */
  20803. get wireframe(): boolean;
  20804. /**
  20805. * Sets the state of wireframe mode
  20806. */
  20807. set wireframe(value: boolean);
  20808. /**
  20809. * Gets the value specifying if point clouds are enabled
  20810. */
  20811. get pointsCloud(): boolean;
  20812. /**
  20813. * Sets the state of point cloud mode
  20814. */
  20815. set pointsCloud(value: boolean);
  20816. /**
  20817. * Gets the material fill mode
  20818. */
  20819. get fillMode(): number;
  20820. /**
  20821. * Sets the material fill mode
  20822. */
  20823. set fillMode(value: number);
  20824. /**
  20825. * @hidden
  20826. * Stores the effects for the material
  20827. */
  20828. _effect: Nullable<Effect>;
  20829. /**
  20830. * @hidden
  20831. * Specifies if the material was previously ready
  20832. */
  20833. _wasPreviouslyReady: boolean;
  20834. /**
  20835. * Specifies if uniform buffers should be used
  20836. */
  20837. private _useUBO;
  20838. /**
  20839. * Stores a reference to the scene
  20840. */
  20841. private _scene;
  20842. /**
  20843. * Stores the fill mode state
  20844. */
  20845. private _fillMode;
  20846. /**
  20847. * Specifies if the depth write state should be cached
  20848. */
  20849. private _cachedDepthWriteState;
  20850. /**
  20851. * Specifies if the depth function state should be cached
  20852. */
  20853. private _cachedDepthFunctionState;
  20854. /**
  20855. * Stores the uniform buffer
  20856. */
  20857. protected _uniformBuffer: UniformBuffer;
  20858. /** @hidden */
  20859. _indexInSceneMaterialArray: number;
  20860. /** @hidden */
  20861. meshMap: Nullable<{
  20862. [id: string]: AbstractMesh | undefined;
  20863. }>;
  20864. /**
  20865. * Creates a material instance
  20866. * @param name defines the name of the material
  20867. * @param scene defines the scene to reference
  20868. * @param doNotAdd specifies if the material should be added to the scene
  20869. */
  20870. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20871. /**
  20872. * Returns a string representation of the current material
  20873. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20874. * @returns a string with material information
  20875. */
  20876. toString(fullDetails?: boolean): string;
  20877. /**
  20878. * Gets the class name of the material
  20879. * @returns a string with the class name of the material
  20880. */
  20881. getClassName(): string;
  20882. /**
  20883. * Specifies if updates for the material been locked
  20884. */
  20885. get isFrozen(): boolean;
  20886. /**
  20887. * Locks updates for the material
  20888. */
  20889. freeze(): void;
  20890. /**
  20891. * Unlocks updates for the material
  20892. */
  20893. unfreeze(): void;
  20894. /**
  20895. * Specifies if the material is ready to be used
  20896. * @param mesh defines the mesh to check
  20897. * @param useInstances specifies if instances should be used
  20898. * @returns a boolean indicating if the material is ready to be used
  20899. */
  20900. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20901. /**
  20902. * Specifies that the submesh is ready to be used
  20903. * @param mesh defines the mesh to check
  20904. * @param subMesh defines which submesh to check
  20905. * @param useInstances specifies that instances should be used
  20906. * @returns a boolean indicating that the submesh is ready or not
  20907. */
  20908. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20909. /**
  20910. * Returns the material effect
  20911. * @returns the effect associated with the material
  20912. */
  20913. getEffect(): Nullable<Effect>;
  20914. /**
  20915. * Returns the current scene
  20916. * @returns a Scene
  20917. */
  20918. getScene(): Scene;
  20919. /**
  20920. * Specifies if the material will require alpha blending
  20921. * @returns a boolean specifying if alpha blending is needed
  20922. */
  20923. needAlphaBlending(): boolean;
  20924. /**
  20925. * Specifies if the mesh will require alpha blending
  20926. * @param mesh defines the mesh to check
  20927. * @returns a boolean specifying if alpha blending is needed for the mesh
  20928. */
  20929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20930. /**
  20931. * Specifies if this material should be rendered in alpha test mode
  20932. * @returns a boolean specifying if an alpha test is needed.
  20933. */
  20934. needAlphaTesting(): boolean;
  20935. /**
  20936. * Gets the texture used for the alpha test
  20937. * @returns the texture to use for alpha testing
  20938. */
  20939. getAlphaTestTexture(): Nullable<BaseTexture>;
  20940. /**
  20941. * Marks the material to indicate that it needs to be re-calculated
  20942. */
  20943. markDirty(): void;
  20944. /** @hidden */
  20945. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20946. /**
  20947. * Binds the material to the mesh
  20948. * @param world defines the world transformation matrix
  20949. * @param mesh defines the mesh to bind the material to
  20950. */
  20951. bind(world: Matrix, mesh?: Mesh): void;
  20952. /**
  20953. * Binds the submesh to the material
  20954. * @param world defines the world transformation matrix
  20955. * @param mesh defines the mesh containing the submesh
  20956. * @param subMesh defines the submesh to bind the material to
  20957. */
  20958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20959. /**
  20960. * Binds the world matrix to the material
  20961. * @param world defines the world transformation matrix
  20962. */
  20963. bindOnlyWorldMatrix(world: Matrix): void;
  20964. /**
  20965. * Binds the scene's uniform buffer to the effect.
  20966. * @param effect defines the effect to bind to the scene uniform buffer
  20967. * @param sceneUbo defines the uniform buffer storing scene data
  20968. */
  20969. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20970. /**
  20971. * Binds the view matrix to the effect
  20972. * @param effect defines the effect to bind the view matrix to
  20973. */
  20974. bindView(effect: Effect): void;
  20975. /**
  20976. * Binds the view projection matrix to the effect
  20977. * @param effect defines the effect to bind the view projection matrix to
  20978. */
  20979. bindViewProjection(effect: Effect): void;
  20980. /**
  20981. * Specifies if material alpha testing should be turned on for the mesh
  20982. * @param mesh defines the mesh to check
  20983. */
  20984. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20985. /**
  20986. * Processes to execute after binding the material to a mesh
  20987. * @param mesh defines the rendered mesh
  20988. */
  20989. protected _afterBind(mesh?: Mesh): void;
  20990. /**
  20991. * Unbinds the material from the mesh
  20992. */
  20993. unbind(): void;
  20994. /**
  20995. * Gets the active textures from the material
  20996. * @returns an array of textures
  20997. */
  20998. getActiveTextures(): BaseTexture[];
  20999. /**
  21000. * Specifies if the material uses a texture
  21001. * @param texture defines the texture to check against the material
  21002. * @returns a boolean specifying if the material uses the texture
  21003. */
  21004. hasTexture(texture: BaseTexture): boolean;
  21005. /**
  21006. * Makes a duplicate of the material, and gives it a new name
  21007. * @param name defines the new name for the duplicated material
  21008. * @returns the cloned material
  21009. */
  21010. clone(name: string): Nullable<Material>;
  21011. /**
  21012. * Gets the meshes bound to the material
  21013. * @returns an array of meshes bound to the material
  21014. */
  21015. getBindedMeshes(): AbstractMesh[];
  21016. /**
  21017. * Force shader compilation
  21018. * @param mesh defines the mesh associated with this material
  21019. * @param onCompiled defines a function to execute once the material is compiled
  21020. * @param options defines the options to configure the compilation
  21021. * @param onError defines a function to execute if the material fails compiling
  21022. */
  21023. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21024. /**
  21025. * Force shader compilation
  21026. * @param mesh defines the mesh that will use this material
  21027. * @param options defines additional options for compiling the shaders
  21028. * @returns a promise that resolves when the compilation completes
  21029. */
  21030. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21031. private static readonly _AllDirtyCallBack;
  21032. private static readonly _ImageProcessingDirtyCallBack;
  21033. private static readonly _TextureDirtyCallBack;
  21034. private static readonly _FresnelDirtyCallBack;
  21035. private static readonly _MiscDirtyCallBack;
  21036. private static readonly _LightsDirtyCallBack;
  21037. private static readonly _AttributeDirtyCallBack;
  21038. private static _FresnelAndMiscDirtyCallBack;
  21039. private static _TextureAndMiscDirtyCallBack;
  21040. private static readonly _DirtyCallbackArray;
  21041. private static readonly _RunDirtyCallBacks;
  21042. /**
  21043. * Marks a define in the material to indicate that it needs to be re-computed
  21044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21045. */
  21046. markAsDirty(flag: number): void;
  21047. /**
  21048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21049. * @param func defines a function which checks material defines against the submeshes
  21050. */
  21051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21052. /**
  21053. * Indicates that we need to re-calculated for all submeshes
  21054. */
  21055. protected _markAllSubMeshesAsAllDirty(): void;
  21056. /**
  21057. * Indicates that image processing needs to be re-calculated for all submeshes
  21058. */
  21059. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21060. /**
  21061. * Indicates that textures need to be re-calculated for all submeshes
  21062. */
  21063. protected _markAllSubMeshesAsTexturesDirty(): void;
  21064. /**
  21065. * Indicates that fresnel needs to be re-calculated for all submeshes
  21066. */
  21067. protected _markAllSubMeshesAsFresnelDirty(): void;
  21068. /**
  21069. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21070. */
  21071. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21072. /**
  21073. * Indicates that lights need to be re-calculated for all submeshes
  21074. */
  21075. protected _markAllSubMeshesAsLightsDirty(): void;
  21076. /**
  21077. * Indicates that attributes need to be re-calculated for all submeshes
  21078. */
  21079. protected _markAllSubMeshesAsAttributesDirty(): void;
  21080. /**
  21081. * Indicates that misc needs to be re-calculated for all submeshes
  21082. */
  21083. protected _markAllSubMeshesAsMiscDirty(): void;
  21084. /**
  21085. * Indicates that textures and misc need to be re-calculated for all submeshes
  21086. */
  21087. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21088. /**
  21089. * Disposes the material
  21090. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21091. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21092. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21093. */
  21094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21095. /** @hidden */
  21096. private releaseVertexArrayObject;
  21097. /**
  21098. * Serializes this material
  21099. * @returns the serialized material object
  21100. */
  21101. serialize(): any;
  21102. /**
  21103. * Creates a material from parsed material data
  21104. * @param parsedMaterial defines parsed material data
  21105. * @param scene defines the hosting scene
  21106. * @param rootUrl defines the root URL to use to load textures
  21107. * @returns a new material
  21108. */
  21109. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21110. }
  21111. }
  21112. declare module BABYLON {
  21113. /**
  21114. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21115. * separate meshes. This can be use to improve performances.
  21116. * @see http://doc.babylonjs.com/how_to/multi_materials
  21117. */
  21118. export class MultiMaterial extends Material {
  21119. private _subMaterials;
  21120. /**
  21121. * Gets or Sets the list of Materials used within the multi material.
  21122. * They need to be ordered according to the submeshes order in the associated mesh
  21123. */
  21124. get subMaterials(): Nullable<Material>[];
  21125. set subMaterials(value: Nullable<Material>[]);
  21126. /**
  21127. * Function used to align with Node.getChildren()
  21128. * @returns the list of Materials used within the multi material
  21129. */
  21130. getChildren(): Nullable<Material>[];
  21131. /**
  21132. * Instantiates a new Multi Material
  21133. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21134. * separate meshes. This can be use to improve performances.
  21135. * @see http://doc.babylonjs.com/how_to/multi_materials
  21136. * @param name Define the name in the scene
  21137. * @param scene Define the scene the material belongs to
  21138. */
  21139. constructor(name: string, scene: Scene);
  21140. private _hookArray;
  21141. /**
  21142. * Get one of the submaterial by its index in the submaterials array
  21143. * @param index The index to look the sub material at
  21144. * @returns The Material if the index has been defined
  21145. */
  21146. getSubMaterial(index: number): Nullable<Material>;
  21147. /**
  21148. * Get the list of active textures for the whole sub materials list.
  21149. * @returns All the textures that will be used during the rendering
  21150. */
  21151. getActiveTextures(): BaseTexture[];
  21152. /**
  21153. * Gets the current class name of the material e.g. "MultiMaterial"
  21154. * Mainly use in serialization.
  21155. * @returns the class name
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Checks if the material is ready to render the requested sub mesh
  21160. * @param mesh Define the mesh the submesh belongs to
  21161. * @param subMesh Define the sub mesh to look readyness for
  21162. * @param useInstances Define whether or not the material is used with instances
  21163. * @returns true if ready, otherwise false
  21164. */
  21165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21166. /**
  21167. * Clones the current material and its related sub materials
  21168. * @param name Define the name of the newly cloned material
  21169. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21170. * @returns the cloned material
  21171. */
  21172. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21173. /**
  21174. * Serializes the materials into a JSON representation.
  21175. * @returns the JSON representation
  21176. */
  21177. serialize(): any;
  21178. /**
  21179. * Dispose the material and release its associated resources
  21180. * @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)
  21181. * @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)
  21182. * @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)
  21183. */
  21184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21185. /**
  21186. * Creates a MultiMaterial from parsed MultiMaterial data.
  21187. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21188. * @param scene defines the hosting scene
  21189. * @returns a new MultiMaterial
  21190. */
  21191. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21192. }
  21193. }
  21194. declare module BABYLON {
  21195. /**
  21196. * Base class for submeshes
  21197. */
  21198. export class BaseSubMesh {
  21199. /** @hidden */
  21200. _materialDefines: Nullable<MaterialDefines>;
  21201. /** @hidden */
  21202. _materialEffect: Nullable<Effect>;
  21203. /**
  21204. * Gets material defines used by the effect associated to the sub mesh
  21205. */
  21206. get materialDefines(): Nullable<MaterialDefines>;
  21207. /**
  21208. * Sets material defines used by the effect associated to the sub mesh
  21209. */
  21210. set materialDefines(defines: Nullable<MaterialDefines>);
  21211. /**
  21212. * Gets associated effect
  21213. */
  21214. get effect(): Nullable<Effect>;
  21215. /**
  21216. * Sets associated effect (effect used to render this submesh)
  21217. * @param effect defines the effect to associate with
  21218. * @param defines defines the set of defines used to compile this effect
  21219. */
  21220. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21221. }
  21222. /**
  21223. * Defines a subdivision inside a mesh
  21224. */
  21225. export class SubMesh extends BaseSubMesh implements ICullable {
  21226. /** the material index to use */
  21227. materialIndex: number;
  21228. /** vertex index start */
  21229. verticesStart: number;
  21230. /** vertices count */
  21231. verticesCount: number;
  21232. /** index start */
  21233. indexStart: number;
  21234. /** indices count */
  21235. indexCount: number;
  21236. /** @hidden */
  21237. _linesIndexCount: number;
  21238. private _mesh;
  21239. private _renderingMesh;
  21240. private _boundingInfo;
  21241. private _linesIndexBuffer;
  21242. /** @hidden */
  21243. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21244. /** @hidden */
  21245. _trianglePlanes: Plane[];
  21246. /** @hidden */
  21247. _lastColliderTransformMatrix: Nullable<Matrix>;
  21248. /** @hidden */
  21249. _renderId: number;
  21250. /** @hidden */
  21251. _alphaIndex: number;
  21252. /** @hidden */
  21253. _distanceToCamera: number;
  21254. /** @hidden */
  21255. _id: number;
  21256. private _currentMaterial;
  21257. /**
  21258. * Add a new submesh to a mesh
  21259. * @param materialIndex defines the material index to use
  21260. * @param verticesStart defines vertex index start
  21261. * @param verticesCount defines vertices count
  21262. * @param indexStart defines index start
  21263. * @param indexCount defines indices count
  21264. * @param mesh defines the parent mesh
  21265. * @param renderingMesh defines an optional rendering mesh
  21266. * @param createBoundingBox defines if bounding box should be created for this submesh
  21267. * @returns the new submesh
  21268. */
  21269. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21270. /**
  21271. * Creates a new submesh
  21272. * @param materialIndex defines the material index to use
  21273. * @param verticesStart defines vertex index start
  21274. * @param verticesCount defines vertices count
  21275. * @param indexStart defines index start
  21276. * @param indexCount defines indices count
  21277. * @param mesh defines the parent mesh
  21278. * @param renderingMesh defines an optional rendering mesh
  21279. * @param createBoundingBox defines if bounding box should be created for this submesh
  21280. */
  21281. constructor(
  21282. /** the material index to use */
  21283. materialIndex: number,
  21284. /** vertex index start */
  21285. verticesStart: number,
  21286. /** vertices count */
  21287. verticesCount: number,
  21288. /** index start */
  21289. indexStart: number,
  21290. /** indices count */
  21291. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21292. /**
  21293. * Returns true if this submesh covers the entire parent mesh
  21294. * @ignorenaming
  21295. */
  21296. get IsGlobal(): boolean;
  21297. /**
  21298. * Returns the submesh BoudingInfo object
  21299. * @returns current bounding info (or mesh's one if the submesh is global)
  21300. */
  21301. getBoundingInfo(): BoundingInfo;
  21302. /**
  21303. * Sets the submesh BoundingInfo
  21304. * @param boundingInfo defines the new bounding info to use
  21305. * @returns the SubMesh
  21306. */
  21307. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21308. /**
  21309. * Returns the mesh of the current submesh
  21310. * @return the parent mesh
  21311. */
  21312. getMesh(): AbstractMesh;
  21313. /**
  21314. * Returns the rendering mesh of the submesh
  21315. * @returns the rendering mesh (could be different from parent mesh)
  21316. */
  21317. getRenderingMesh(): Mesh;
  21318. /**
  21319. * Returns the submesh material
  21320. * @returns null or the current material
  21321. */
  21322. getMaterial(): Nullable<Material>;
  21323. /**
  21324. * Sets a new updated BoundingInfo object to the submesh
  21325. * @param data defines an optional position array to use to determine the bounding info
  21326. * @returns the SubMesh
  21327. */
  21328. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21329. /** @hidden */
  21330. _checkCollision(collider: Collider): boolean;
  21331. /**
  21332. * Updates the submesh BoundingInfo
  21333. * @param world defines the world matrix to use to update the bounding info
  21334. * @returns the submesh
  21335. */
  21336. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21337. /**
  21338. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21339. * @param frustumPlanes defines the frustum planes
  21340. * @returns true if the submesh is intersecting with the frustum
  21341. */
  21342. isInFrustum(frustumPlanes: Plane[]): boolean;
  21343. /**
  21344. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21345. * @param frustumPlanes defines the frustum planes
  21346. * @returns true if the submesh is inside the frustum
  21347. */
  21348. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21349. /**
  21350. * Renders the submesh
  21351. * @param enableAlphaMode defines if alpha needs to be used
  21352. * @returns the submesh
  21353. */
  21354. render(enableAlphaMode: boolean): SubMesh;
  21355. /**
  21356. * @hidden
  21357. */
  21358. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21359. /**
  21360. * Checks if the submesh intersects with a ray
  21361. * @param ray defines the ray to test
  21362. * @returns true is the passed ray intersects the submesh bounding box
  21363. */
  21364. canIntersects(ray: Ray): boolean;
  21365. /**
  21366. * Intersects current submesh with a ray
  21367. * @param ray defines the ray to test
  21368. * @param positions defines mesh's positions array
  21369. * @param indices defines mesh's indices array
  21370. * @param fastCheck defines if only bounding info should be used
  21371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21372. * @returns intersection info or null if no intersection
  21373. */
  21374. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21375. /** @hidden */
  21376. private _intersectLines;
  21377. /** @hidden */
  21378. private _intersectUnIndexedLines;
  21379. /** @hidden */
  21380. private _intersectTriangles;
  21381. /** @hidden */
  21382. private _intersectUnIndexedTriangles;
  21383. /** @hidden */
  21384. _rebuild(): void;
  21385. /**
  21386. * Creates a new submesh from the passed mesh
  21387. * @param newMesh defines the new hosting mesh
  21388. * @param newRenderingMesh defines an optional rendering mesh
  21389. * @returns the new submesh
  21390. */
  21391. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21392. /**
  21393. * Release associated resources
  21394. */
  21395. dispose(): void;
  21396. /**
  21397. * Gets the class name
  21398. * @returns the string "SubMesh".
  21399. */
  21400. getClassName(): string;
  21401. /**
  21402. * Creates a new submesh from indices data
  21403. * @param materialIndex the index of the main mesh material
  21404. * @param startIndex the index where to start the copy in the mesh indices array
  21405. * @param indexCount the number of indices to copy then from the startIndex
  21406. * @param mesh the main mesh to create the submesh from
  21407. * @param renderingMesh the optional rendering mesh
  21408. * @returns a new submesh
  21409. */
  21410. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21411. }
  21412. }
  21413. declare module BABYLON {
  21414. /**
  21415. * Class used to represent data loading progression
  21416. */
  21417. export class SceneLoaderFlags {
  21418. private static _ForceFullSceneLoadingForIncremental;
  21419. private static _ShowLoadingScreen;
  21420. private static _CleanBoneMatrixWeights;
  21421. private static _loggingLevel;
  21422. /**
  21423. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21424. */
  21425. static get ForceFullSceneLoadingForIncremental(): boolean;
  21426. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21427. /**
  21428. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21429. */
  21430. static get ShowLoadingScreen(): boolean;
  21431. static set ShowLoadingScreen(value: boolean);
  21432. /**
  21433. * Defines the current logging level (while loading the scene)
  21434. * @ignorenaming
  21435. */
  21436. static get loggingLevel(): number;
  21437. static set loggingLevel(value: number);
  21438. /**
  21439. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21440. */
  21441. static get CleanBoneMatrixWeights(): boolean;
  21442. static set CleanBoneMatrixWeights(value: boolean);
  21443. }
  21444. }
  21445. declare module BABYLON {
  21446. /**
  21447. * Class used to store geometry data (vertex buffers + index buffer)
  21448. */
  21449. export class Geometry implements IGetSetVerticesData {
  21450. /**
  21451. * Gets or sets the ID of the geometry
  21452. */
  21453. id: string;
  21454. /**
  21455. * Gets or sets the unique ID of the geometry
  21456. */
  21457. uniqueId: number;
  21458. /**
  21459. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21460. */
  21461. delayLoadState: number;
  21462. /**
  21463. * Gets the file containing the data to load when running in delay load state
  21464. */
  21465. delayLoadingFile: Nullable<string>;
  21466. /**
  21467. * Callback called when the geometry is updated
  21468. */
  21469. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21470. private _scene;
  21471. private _engine;
  21472. private _meshes;
  21473. private _totalVertices;
  21474. /** @hidden */
  21475. _indices: IndicesArray;
  21476. /** @hidden */
  21477. _vertexBuffers: {
  21478. [key: string]: VertexBuffer;
  21479. };
  21480. private _isDisposed;
  21481. private _extend;
  21482. private _boundingBias;
  21483. /** @hidden */
  21484. _delayInfo: Array<string>;
  21485. private _indexBuffer;
  21486. private _indexBufferIsUpdatable;
  21487. /** @hidden */
  21488. _boundingInfo: Nullable<BoundingInfo>;
  21489. /** @hidden */
  21490. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21491. /** @hidden */
  21492. _softwareSkinningFrameId: number;
  21493. private _vertexArrayObjects;
  21494. private _updatable;
  21495. /** @hidden */
  21496. _positions: Nullable<Vector3[]>;
  21497. /**
  21498. * 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
  21499. */
  21500. get boundingBias(): Vector2;
  21501. /**
  21502. * 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
  21503. */
  21504. set boundingBias(value: Vector2);
  21505. /**
  21506. * Static function used to attach a new empty geometry to a mesh
  21507. * @param mesh defines the mesh to attach the geometry to
  21508. * @returns the new Geometry
  21509. */
  21510. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21511. /**
  21512. * Creates a new geometry
  21513. * @param id defines the unique ID
  21514. * @param scene defines the hosting scene
  21515. * @param vertexData defines the VertexData used to get geometry data
  21516. * @param updatable defines if geometry must be updatable (false by default)
  21517. * @param mesh defines the mesh that will be associated with the geometry
  21518. */
  21519. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21520. /**
  21521. * Gets the current extend of the geometry
  21522. */
  21523. get extend(): {
  21524. minimum: Vector3;
  21525. maximum: Vector3;
  21526. };
  21527. /**
  21528. * Gets the hosting scene
  21529. * @returns the hosting Scene
  21530. */
  21531. getScene(): Scene;
  21532. /**
  21533. * Gets the hosting engine
  21534. * @returns the hosting Engine
  21535. */
  21536. getEngine(): Engine;
  21537. /**
  21538. * Defines if the geometry is ready to use
  21539. * @returns true if the geometry is ready to be used
  21540. */
  21541. isReady(): boolean;
  21542. /**
  21543. * Gets a value indicating that the geometry should not be serialized
  21544. */
  21545. get doNotSerialize(): boolean;
  21546. /** @hidden */
  21547. _rebuild(): void;
  21548. /**
  21549. * Affects all geometry data in one call
  21550. * @param vertexData defines the geometry data
  21551. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21552. */
  21553. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21554. /**
  21555. * Set specific vertex data
  21556. * @param kind defines the data kind (Position, normal, etc...)
  21557. * @param data defines the vertex data to use
  21558. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21559. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21560. */
  21561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21562. /**
  21563. * Removes a specific vertex data
  21564. * @param kind defines the data kind (Position, normal, etc...)
  21565. */
  21566. removeVerticesData(kind: string): void;
  21567. /**
  21568. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21569. * @param buffer defines the vertex buffer to use
  21570. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21571. */
  21572. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21573. /**
  21574. * Update a specific vertex buffer
  21575. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21576. * It will do nothing if the buffer is not updatable
  21577. * @param kind defines the data kind (Position, normal, etc...)
  21578. * @param data defines the data to use
  21579. * @param offset defines the offset in the target buffer where to store the data
  21580. * @param useBytes set to true if the offset is in bytes
  21581. */
  21582. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21583. /**
  21584. * Update a specific vertex buffer
  21585. * This function will create a new buffer if the current one is not updatable
  21586. * @param kind defines the data kind (Position, normal, etc...)
  21587. * @param data defines the data to use
  21588. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21589. */
  21590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21591. private _updateBoundingInfo;
  21592. /** @hidden */
  21593. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21594. /**
  21595. * Gets total number of vertices
  21596. * @returns the total number of vertices
  21597. */
  21598. getTotalVertices(): number;
  21599. /**
  21600. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21601. * @param kind defines the data kind (Position, normal, etc...)
  21602. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21603. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21604. * @returns a float array containing vertex data
  21605. */
  21606. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21607. /**
  21608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21609. * @param kind defines the data kind (Position, normal, etc...)
  21610. * @returns true if the vertex buffer with the specified kind is updatable
  21611. */
  21612. isVertexBufferUpdatable(kind: string): boolean;
  21613. /**
  21614. * Gets a specific vertex buffer
  21615. * @param kind defines the data kind (Position, normal, etc...)
  21616. * @returns a VertexBuffer
  21617. */
  21618. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21619. /**
  21620. * Returns all vertex buffers
  21621. * @return an object holding all vertex buffers indexed by kind
  21622. */
  21623. getVertexBuffers(): Nullable<{
  21624. [key: string]: VertexBuffer;
  21625. }>;
  21626. /**
  21627. * Gets a boolean indicating if specific vertex buffer is present
  21628. * @param kind defines the data kind (Position, normal, etc...)
  21629. * @returns true if data is present
  21630. */
  21631. isVerticesDataPresent(kind: string): boolean;
  21632. /**
  21633. * Gets a list of all attached data kinds (Position, normal, etc...)
  21634. * @returns a list of string containing all kinds
  21635. */
  21636. getVerticesDataKinds(): string[];
  21637. /**
  21638. * Update index buffer
  21639. * @param indices defines the indices to store in the index buffer
  21640. * @param offset defines the offset in the target buffer where to store the data
  21641. * @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)
  21642. */
  21643. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21644. /**
  21645. * Creates a new index buffer
  21646. * @param indices defines the indices to store in the index buffer
  21647. * @param totalVertices defines the total number of vertices (could be null)
  21648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21649. */
  21650. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21651. /**
  21652. * Return the total number of indices
  21653. * @returns the total number of indices
  21654. */
  21655. getTotalIndices(): number;
  21656. /**
  21657. * Gets the index buffer array
  21658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21660. * @returns the index buffer array
  21661. */
  21662. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21663. /**
  21664. * Gets the index buffer
  21665. * @return the index buffer
  21666. */
  21667. getIndexBuffer(): Nullable<DataBuffer>;
  21668. /** @hidden */
  21669. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21670. /**
  21671. * Release the associated resources for a specific mesh
  21672. * @param mesh defines the source mesh
  21673. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21674. */
  21675. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21676. /**
  21677. * Apply current geometry to a given mesh
  21678. * @param mesh defines the mesh to apply geometry to
  21679. */
  21680. applyToMesh(mesh: Mesh): void;
  21681. private _updateExtend;
  21682. private _applyToMesh;
  21683. private notifyUpdate;
  21684. /**
  21685. * Load the geometry if it was flagged as delay loaded
  21686. * @param scene defines the hosting scene
  21687. * @param onLoaded defines a callback called when the geometry is loaded
  21688. */
  21689. load(scene: Scene, onLoaded?: () => void): void;
  21690. private _queueLoad;
  21691. /**
  21692. * Invert the geometry to move from a right handed system to a left handed one.
  21693. */
  21694. toLeftHanded(): void;
  21695. /** @hidden */
  21696. _resetPointsArrayCache(): void;
  21697. /** @hidden */
  21698. _generatePointsArray(): boolean;
  21699. /**
  21700. * Gets a value indicating if the geometry is disposed
  21701. * @returns true if the geometry was disposed
  21702. */
  21703. isDisposed(): boolean;
  21704. private _disposeVertexArrayObjects;
  21705. /**
  21706. * Free all associated resources
  21707. */
  21708. dispose(): void;
  21709. /**
  21710. * Clone the current geometry into a new geometry
  21711. * @param id defines the unique ID of the new geometry
  21712. * @returns a new geometry object
  21713. */
  21714. copy(id: string): Geometry;
  21715. /**
  21716. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21717. * @return a JSON representation of the current geometry data (without the vertices data)
  21718. */
  21719. serialize(): any;
  21720. private toNumberArray;
  21721. /**
  21722. * Serialize all vertices data into a JSON oject
  21723. * @returns a JSON representation of the current geometry data
  21724. */
  21725. serializeVerticeData(): any;
  21726. /**
  21727. * Extracts a clone of a mesh geometry
  21728. * @param mesh defines the source mesh
  21729. * @param id defines the unique ID of the new geometry object
  21730. * @returns the new geometry object
  21731. */
  21732. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21733. /**
  21734. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21735. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21736. * Be aware Math.random() could cause collisions, but:
  21737. * "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"
  21738. * @returns a string containing a new GUID
  21739. */
  21740. static RandomId(): string;
  21741. /** @hidden */
  21742. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21743. private static _CleanMatricesWeights;
  21744. /**
  21745. * Create a new geometry from persisted data (Using .babylon file format)
  21746. * @param parsedVertexData defines the persisted data
  21747. * @param scene defines the hosting scene
  21748. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21749. * @returns the new geometry object
  21750. */
  21751. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21752. }
  21753. }
  21754. declare module BABYLON {
  21755. /**
  21756. * Define an interface for all classes that will get and set the data on vertices
  21757. */
  21758. export interface IGetSetVerticesData {
  21759. /**
  21760. * Gets a boolean indicating if specific vertex data is present
  21761. * @param kind defines the vertex data kind to use
  21762. * @returns true is data kind is present
  21763. */
  21764. isVerticesDataPresent(kind: string): boolean;
  21765. /**
  21766. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21770. * @returns a float array containing vertex data
  21771. */
  21772. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21773. /**
  21774. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21775. * @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.
  21776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21777. * @returns the indices array or an empty array if the mesh has no geometry
  21778. */
  21779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21780. /**
  21781. * Set specific vertex data
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @param data defines the vertex data to use
  21784. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21785. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21786. */
  21787. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21788. /**
  21789. * Update a specific associated vertex buffer
  21790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21791. * - VertexBuffer.PositionKind
  21792. * - VertexBuffer.UVKind
  21793. * - VertexBuffer.UV2Kind
  21794. * - VertexBuffer.UV3Kind
  21795. * - VertexBuffer.UV4Kind
  21796. * - VertexBuffer.UV5Kind
  21797. * - VertexBuffer.UV6Kind
  21798. * - VertexBuffer.ColorKind
  21799. * - VertexBuffer.MatricesIndicesKind
  21800. * - VertexBuffer.MatricesIndicesExtraKind
  21801. * - VertexBuffer.MatricesWeightsKind
  21802. * - VertexBuffer.MatricesWeightsExtraKind
  21803. * @param data defines the data source
  21804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21805. * @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)
  21806. */
  21807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21808. /**
  21809. * Creates a new index buffer
  21810. * @param indices defines the indices to store in the index buffer
  21811. * @param totalVertices defines the total number of vertices (could be null)
  21812. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21813. */
  21814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21815. }
  21816. /**
  21817. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21818. */
  21819. export class VertexData {
  21820. /**
  21821. * Mesh side orientation : usually the external or front surface
  21822. */
  21823. static readonly FRONTSIDE: number;
  21824. /**
  21825. * Mesh side orientation : usually the internal or back surface
  21826. */
  21827. static readonly BACKSIDE: number;
  21828. /**
  21829. * Mesh side orientation : both internal and external or front and back surfaces
  21830. */
  21831. static readonly DOUBLESIDE: number;
  21832. /**
  21833. * Mesh side orientation : by default, `FRONTSIDE`
  21834. */
  21835. static readonly DEFAULTSIDE: number;
  21836. /**
  21837. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21838. */
  21839. positions: Nullable<FloatArray>;
  21840. /**
  21841. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21842. */
  21843. normals: Nullable<FloatArray>;
  21844. /**
  21845. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21846. */
  21847. tangents: Nullable<FloatArray>;
  21848. /**
  21849. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21850. */
  21851. uvs: Nullable<FloatArray>;
  21852. /**
  21853. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21854. */
  21855. uvs2: Nullable<FloatArray>;
  21856. /**
  21857. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21858. */
  21859. uvs3: Nullable<FloatArray>;
  21860. /**
  21861. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs4: Nullable<FloatArray>;
  21864. /**
  21865. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs5: Nullable<FloatArray>;
  21868. /**
  21869. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21870. */
  21871. uvs6: Nullable<FloatArray>;
  21872. /**
  21873. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21874. */
  21875. colors: Nullable<FloatArray>;
  21876. /**
  21877. * 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).
  21878. */
  21879. matricesIndices: Nullable<FloatArray>;
  21880. /**
  21881. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21882. */
  21883. matricesWeights: Nullable<FloatArray>;
  21884. /**
  21885. * An array extending the number of possible indices
  21886. */
  21887. matricesIndicesExtra: Nullable<FloatArray>;
  21888. /**
  21889. * An array extending the number of possible weights when the number of indices is extended
  21890. */
  21891. matricesWeightsExtra: Nullable<FloatArray>;
  21892. /**
  21893. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21894. */
  21895. indices: Nullable<IndicesArray>;
  21896. /**
  21897. * Uses the passed data array to set the set the values for the specified kind of data
  21898. * @param data a linear array of floating numbers
  21899. * @param kind the type of data that is being set, eg positions, colors etc
  21900. */
  21901. set(data: FloatArray, kind: string): void;
  21902. /**
  21903. * Associates the vertexData to the passed Mesh.
  21904. * Sets it as updatable or not (default `false`)
  21905. * @param mesh the mesh the vertexData is applied to
  21906. * @param updatable when used and having the value true allows new data to update the vertexData
  21907. * @returns the VertexData
  21908. */
  21909. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21910. /**
  21911. * Associates the vertexData to the passed Geometry.
  21912. * Sets it as updatable or not (default `false`)
  21913. * @param geometry the geometry the vertexData is applied to
  21914. * @param updatable when used and having the value true allows new data to update the vertexData
  21915. * @returns VertexData
  21916. */
  21917. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21918. /**
  21919. * Updates the associated mesh
  21920. * @param mesh the mesh to be updated
  21921. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21922. * @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
  21923. * @returns VertexData
  21924. */
  21925. updateMesh(mesh: Mesh): VertexData;
  21926. /**
  21927. * Updates the associated geometry
  21928. * @param geometry the geometry to be updated
  21929. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21930. * @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
  21931. * @returns VertexData.
  21932. */
  21933. updateGeometry(geometry: Geometry): VertexData;
  21934. private _applyTo;
  21935. private _update;
  21936. /**
  21937. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21938. * @param matrix the transforming matrix
  21939. * @returns the VertexData
  21940. */
  21941. transform(matrix: Matrix): VertexData;
  21942. /**
  21943. * Merges the passed VertexData into the current one
  21944. * @param other the VertexData to be merged into the current one
  21945. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21946. * @returns the modified VertexData
  21947. */
  21948. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21949. private _mergeElement;
  21950. private _validate;
  21951. /**
  21952. * Serializes the VertexData
  21953. * @returns a serialized object
  21954. */
  21955. serialize(): any;
  21956. /**
  21957. * Extracts the vertexData from a mesh
  21958. * @param mesh the mesh from which to extract the VertexData
  21959. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21961. * @returns the object VertexData associated to the passed mesh
  21962. */
  21963. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21964. /**
  21965. * Extracts the vertexData from the geometry
  21966. * @param geometry the geometry from which to extract the VertexData
  21967. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21968. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21969. * @returns the object VertexData associated to the passed mesh
  21970. */
  21971. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21972. private static _ExtractFrom;
  21973. /**
  21974. * Creates the VertexData for a Ribbon
  21975. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21976. * * pathArray array of paths, each of which an array of successive Vector3
  21977. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21978. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21979. * * 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
  21980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21981. * * 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)
  21982. * * 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)
  21983. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21984. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21985. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21986. * @returns the VertexData of the ribbon
  21987. */
  21988. static CreateRibbon(options: {
  21989. pathArray: Vector3[][];
  21990. closeArray?: boolean;
  21991. closePath?: boolean;
  21992. offset?: number;
  21993. sideOrientation?: number;
  21994. frontUVs?: Vector4;
  21995. backUVs?: Vector4;
  21996. invertUV?: boolean;
  21997. uvs?: Vector2[];
  21998. colors?: Color4[];
  21999. }): VertexData;
  22000. /**
  22001. * Creates the VertexData for a box
  22002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22003. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22004. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22005. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22006. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22010. * * 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)
  22011. * * 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)
  22012. * @returns the VertexData of the box
  22013. */
  22014. static CreateBox(options: {
  22015. size?: number;
  22016. width?: number;
  22017. height?: number;
  22018. depth?: number;
  22019. faceUV?: Vector4[];
  22020. faceColors?: Color4[];
  22021. sideOrientation?: number;
  22022. frontUVs?: Vector4;
  22023. backUVs?: Vector4;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a tiled box
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22029. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22030. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22032. * @returns the VertexData of the box
  22033. */
  22034. static CreateTiledBox(options: {
  22035. pattern?: number;
  22036. width?: number;
  22037. height?: number;
  22038. depth?: number;
  22039. tileSize?: number;
  22040. tileWidth?: number;
  22041. tileHeight?: number;
  22042. alignHorizontal?: number;
  22043. alignVertical?: number;
  22044. faceUV?: Vector4[];
  22045. faceColors?: Color4[];
  22046. sideOrientation?: number;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a tiled plane
  22050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22051. * * pattern a limited pattern arrangement depending on the number
  22052. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22053. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22054. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22056. * * 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)
  22057. * * 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)
  22058. * @returns the VertexData of the tiled plane
  22059. */
  22060. static CreateTiledPlane(options: {
  22061. pattern?: number;
  22062. tileSize?: number;
  22063. tileWidth?: number;
  22064. tileHeight?: number;
  22065. size?: number;
  22066. width?: number;
  22067. height?: number;
  22068. alignHorizontal?: number;
  22069. alignVertical?: number;
  22070. sideOrientation?: number;
  22071. frontUVs?: Vector4;
  22072. backUVs?: Vector4;
  22073. }): VertexData;
  22074. /**
  22075. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22077. * * segments sets the number of horizontal strips optional, default 32
  22078. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22079. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22080. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22081. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22082. * * 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
  22083. * * 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
  22084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22085. * * 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)
  22086. * * 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)
  22087. * @returns the VertexData of the ellipsoid
  22088. */
  22089. static CreateSphere(options: {
  22090. segments?: number;
  22091. diameter?: number;
  22092. diameterX?: number;
  22093. diameterY?: number;
  22094. diameterZ?: number;
  22095. arc?: number;
  22096. slice?: number;
  22097. sideOrientation?: number;
  22098. frontUVs?: Vector4;
  22099. backUVs?: Vector4;
  22100. }): VertexData;
  22101. /**
  22102. * Creates the VertexData for a cylinder, cone or prism
  22103. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22104. * * height sets the height (y direction) of the cylinder, optional, default 2
  22105. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22106. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22107. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22108. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22109. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22110. * * 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
  22111. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22112. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22113. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22114. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22116. * * 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)
  22117. * * 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)
  22118. * @returns the VertexData of the cylinder, cone or prism
  22119. */
  22120. static CreateCylinder(options: {
  22121. height?: number;
  22122. diameterTop?: number;
  22123. diameterBottom?: number;
  22124. diameter?: number;
  22125. tessellation?: number;
  22126. subdivisions?: number;
  22127. arc?: number;
  22128. faceColors?: Color4[];
  22129. faceUV?: Vector4[];
  22130. hasRings?: boolean;
  22131. enclose?: boolean;
  22132. sideOrientation?: number;
  22133. frontUVs?: Vector4;
  22134. backUVs?: Vector4;
  22135. }): VertexData;
  22136. /**
  22137. * Creates the VertexData for a torus
  22138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22139. * * diameter the diameter of the torus, optional default 1
  22140. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22141. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22143. * * 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)
  22144. * * 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)
  22145. * @returns the VertexData of the torus
  22146. */
  22147. static CreateTorus(options: {
  22148. diameter?: number;
  22149. thickness?: number;
  22150. tessellation?: number;
  22151. sideOrientation?: number;
  22152. frontUVs?: Vector4;
  22153. backUVs?: Vector4;
  22154. }): VertexData;
  22155. /**
  22156. * Creates the VertexData of the LineSystem
  22157. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22158. * - lines an array of lines, each line being an array of successive Vector3
  22159. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22160. * @returns the VertexData of the LineSystem
  22161. */
  22162. static CreateLineSystem(options: {
  22163. lines: Vector3[][];
  22164. colors?: Nullable<Color4[][]>;
  22165. }): VertexData;
  22166. /**
  22167. * Create the VertexData for a DashedLines
  22168. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22169. * - points an array successive Vector3
  22170. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22171. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22172. * - dashNb the intended total number of dashes, optional, default 200
  22173. * @returns the VertexData for the DashedLines
  22174. */
  22175. static CreateDashedLines(options: {
  22176. points: Vector3[];
  22177. dashSize?: number;
  22178. gapSize?: number;
  22179. dashNb?: number;
  22180. }): VertexData;
  22181. /**
  22182. * Creates the VertexData for a Ground
  22183. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22184. * - width the width (x direction) of the ground, optional, default 1
  22185. * - height the height (z direction) of the ground, optional, default 1
  22186. * - subdivisions the number of subdivisions per side, optional, default 1
  22187. * @returns the VertexData of the Ground
  22188. */
  22189. static CreateGround(options: {
  22190. width?: number;
  22191. height?: number;
  22192. subdivisions?: number;
  22193. subdivisionsX?: number;
  22194. subdivisionsY?: number;
  22195. }): VertexData;
  22196. /**
  22197. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22198. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22199. * * xmin the ground minimum X coordinate, optional, default -1
  22200. * * zmin the ground minimum Z coordinate, optional, default -1
  22201. * * xmax the ground maximum X coordinate, optional, default 1
  22202. * * zmax the ground maximum Z coordinate, optional, default 1
  22203. * * 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}
  22204. * * 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}
  22205. * @returns the VertexData of the TiledGround
  22206. */
  22207. static CreateTiledGround(options: {
  22208. xmin: number;
  22209. zmin: number;
  22210. xmax: number;
  22211. zmax: number;
  22212. subdivisions?: {
  22213. w: number;
  22214. h: number;
  22215. };
  22216. precision?: {
  22217. w: number;
  22218. h: number;
  22219. };
  22220. }): VertexData;
  22221. /**
  22222. * Creates the VertexData of the Ground designed from a heightmap
  22223. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22224. * * width the width (x direction) of the ground
  22225. * * height the height (z direction) of the ground
  22226. * * subdivisions the number of subdivisions per side
  22227. * * minHeight the minimum altitude on the ground, optional, default 0
  22228. * * maxHeight the maximum altitude on the ground, optional default 1
  22229. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22230. * * buffer the array holding the image color data
  22231. * * bufferWidth the width of image
  22232. * * bufferHeight the height of image
  22233. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22234. * @returns the VertexData of the Ground designed from a heightmap
  22235. */
  22236. static CreateGroundFromHeightMap(options: {
  22237. width: number;
  22238. height: number;
  22239. subdivisions: number;
  22240. minHeight: number;
  22241. maxHeight: number;
  22242. colorFilter: Color3;
  22243. buffer: Uint8Array;
  22244. bufferWidth: number;
  22245. bufferHeight: number;
  22246. alphaFilter: number;
  22247. }): VertexData;
  22248. /**
  22249. * Creates the VertexData for a Plane
  22250. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22251. * * size sets the width and height of the plane to the value of size, optional default 1
  22252. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22253. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * 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)
  22256. * * 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)
  22257. * @returns the VertexData of the box
  22258. */
  22259. static CreatePlane(options: {
  22260. size?: number;
  22261. width?: number;
  22262. height?: number;
  22263. sideOrientation?: number;
  22264. frontUVs?: Vector4;
  22265. backUVs?: Vector4;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData of the Disc or regular Polygon
  22269. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22270. * * radius the radius of the disc, optional default 0.5
  22271. * * tessellation the number of polygon sides, optional, default 64
  22272. * * 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
  22273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22274. * * 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)
  22275. * * 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)
  22276. * @returns the VertexData of the box
  22277. */
  22278. static CreateDisc(options: {
  22279. radius?: number;
  22280. tessellation?: number;
  22281. arc?: number;
  22282. sideOrientation?: number;
  22283. frontUVs?: Vector4;
  22284. backUVs?: Vector4;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22288. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22289. * @param polygon a mesh built from polygonTriangulation.build()
  22290. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22292. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22293. * @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)
  22294. * @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)
  22295. * @returns the VertexData of the Polygon
  22296. */
  22297. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22298. /**
  22299. * Creates the VertexData of the IcoSphere
  22300. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22301. * * radius the radius of the IcoSphere, optional default 1
  22302. * * radiusX allows stretching in the x direction, optional, default radius
  22303. * * radiusY allows stretching in the y direction, optional, default radius
  22304. * * radiusZ allows stretching in the z direction, optional, default radius
  22305. * * flat when true creates a flat shaded mesh, optional, default true
  22306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * * 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)
  22309. * * 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)
  22310. * @returns the VertexData of the IcoSphere
  22311. */
  22312. static CreateIcoSphere(options: {
  22313. radius?: number;
  22314. radiusX?: number;
  22315. radiusY?: number;
  22316. radiusZ?: number;
  22317. flat?: boolean;
  22318. subdivisions?: number;
  22319. sideOrientation?: number;
  22320. frontUVs?: Vector4;
  22321. backUVs?: Vector4;
  22322. }): VertexData;
  22323. /**
  22324. * Creates the VertexData for a Polyhedron
  22325. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22326. * * type provided types are:
  22327. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22328. * * 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)
  22329. * * size the size of the IcoSphere, optional default 1
  22330. * * sizeX allows stretching in the x direction, optional, default size
  22331. * * sizeY allows stretching in the y direction, optional, default size
  22332. * * sizeZ allows stretching in the z direction, optional, default size
  22333. * * 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
  22334. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22335. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22336. * * flat when true creates a flat shaded mesh, optional, default true
  22337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22339. * * 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)
  22340. * * 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)
  22341. * @returns the VertexData of the Polyhedron
  22342. */
  22343. static CreatePolyhedron(options: {
  22344. type?: number;
  22345. size?: number;
  22346. sizeX?: number;
  22347. sizeY?: number;
  22348. sizeZ?: number;
  22349. custom?: any;
  22350. faceUV?: Vector4[];
  22351. faceColors?: Color4[];
  22352. flat?: boolean;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a TorusKnot
  22359. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22360. * * radius the radius of the torus knot, optional, default 2
  22361. * * tube the thickness of the tube, optional, default 0.5
  22362. * * radialSegments the number of sides on each tube segments, optional, default 32
  22363. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22364. * * p the number of windings around the z axis, optional, default 2
  22365. * * q the number of windings around the x axis, optional, default 3
  22366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22367. * * 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)
  22368. * * 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)
  22369. * @returns the VertexData of the Torus Knot
  22370. */
  22371. static CreateTorusKnot(options: {
  22372. radius?: number;
  22373. tube?: number;
  22374. radialSegments?: number;
  22375. tubularSegments?: number;
  22376. p?: number;
  22377. q?: number;
  22378. sideOrientation?: number;
  22379. frontUVs?: Vector4;
  22380. backUVs?: Vector4;
  22381. }): VertexData;
  22382. /**
  22383. * Compute normals for given positions and indices
  22384. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22385. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22386. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22387. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22388. * * facetNormals : optional array of facet normals (vector3)
  22389. * * facetPositions : optional array of facet positions (vector3)
  22390. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22391. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22392. * * bInfo : optional bounding info, required for facetPartitioning computation
  22393. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22394. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22395. * * useRightHandedSystem: optional boolean to for right handed system computation
  22396. * * depthSort : optional boolean to enable the facet depth sort computation
  22397. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22398. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22399. */
  22400. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22401. facetNormals?: any;
  22402. facetPositions?: any;
  22403. facetPartitioning?: any;
  22404. ratio?: number;
  22405. bInfo?: any;
  22406. bbSize?: Vector3;
  22407. subDiv?: any;
  22408. useRightHandedSystem?: boolean;
  22409. depthSort?: boolean;
  22410. distanceTo?: Vector3;
  22411. depthSortedFacets?: any;
  22412. }): void;
  22413. /** @hidden */
  22414. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22415. /**
  22416. * Applies VertexData created from the imported parameters to the geometry
  22417. * @param parsedVertexData the parsed data from an imported file
  22418. * @param geometry the geometry to apply the VertexData to
  22419. */
  22420. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22421. }
  22422. }
  22423. declare module BABYLON {
  22424. /**
  22425. * Defines a target to use with MorphTargetManager
  22426. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22427. */
  22428. export class MorphTarget implements IAnimatable {
  22429. /** defines the name of the target */
  22430. name: string;
  22431. /**
  22432. * Gets or sets the list of animations
  22433. */
  22434. animations: Animation[];
  22435. private _scene;
  22436. private _positions;
  22437. private _normals;
  22438. private _tangents;
  22439. private _uvs;
  22440. private _influence;
  22441. private _uniqueId;
  22442. /**
  22443. * Observable raised when the influence changes
  22444. */
  22445. onInfluenceChanged: Observable<boolean>;
  22446. /** @hidden */
  22447. _onDataLayoutChanged: Observable<void>;
  22448. /**
  22449. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22450. */
  22451. get influence(): number;
  22452. set influence(influence: number);
  22453. /**
  22454. * Gets or sets the id of the morph Target
  22455. */
  22456. id: string;
  22457. private _animationPropertiesOverride;
  22458. /**
  22459. * Gets or sets the animation properties override
  22460. */
  22461. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22462. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22463. /**
  22464. * Creates a new MorphTarget
  22465. * @param name defines the name of the target
  22466. * @param influence defines the influence to use
  22467. * @param scene defines the scene the morphtarget belongs to
  22468. */
  22469. constructor(
  22470. /** defines the name of the target */
  22471. name: string, influence?: number, scene?: Nullable<Scene>);
  22472. /**
  22473. * Gets the unique ID of this manager
  22474. */
  22475. get uniqueId(): number;
  22476. /**
  22477. * Gets a boolean defining if the target contains position data
  22478. */
  22479. get hasPositions(): boolean;
  22480. /**
  22481. * Gets a boolean defining if the target contains normal data
  22482. */
  22483. get hasNormals(): boolean;
  22484. /**
  22485. * Gets a boolean defining if the target contains tangent data
  22486. */
  22487. get hasTangents(): boolean;
  22488. /**
  22489. * Gets a boolean defining if the target contains texture coordinates data
  22490. */
  22491. get hasUVs(): boolean;
  22492. /**
  22493. * Affects position data to this target
  22494. * @param data defines the position data to use
  22495. */
  22496. setPositions(data: Nullable<FloatArray>): void;
  22497. /**
  22498. * Gets the position data stored in this target
  22499. * @returns a FloatArray containing the position data (or null if not present)
  22500. */
  22501. getPositions(): Nullable<FloatArray>;
  22502. /**
  22503. * Affects normal data to this target
  22504. * @param data defines the normal data to use
  22505. */
  22506. setNormals(data: Nullable<FloatArray>): void;
  22507. /**
  22508. * Gets the normal data stored in this target
  22509. * @returns a FloatArray containing the normal data (or null if not present)
  22510. */
  22511. getNormals(): Nullable<FloatArray>;
  22512. /**
  22513. * Affects tangent data to this target
  22514. * @param data defines the tangent data to use
  22515. */
  22516. setTangents(data: Nullable<FloatArray>): void;
  22517. /**
  22518. * Gets the tangent data stored in this target
  22519. * @returns a FloatArray containing the tangent data (or null if not present)
  22520. */
  22521. getTangents(): Nullable<FloatArray>;
  22522. /**
  22523. * Affects texture coordinates data to this target
  22524. * @param data defines the texture coordinates data to use
  22525. */
  22526. setUVs(data: Nullable<FloatArray>): void;
  22527. /**
  22528. * Gets the texture coordinates data stored in this target
  22529. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22530. */
  22531. getUVs(): Nullable<FloatArray>;
  22532. /**
  22533. * Clone the current target
  22534. * @returns a new MorphTarget
  22535. */
  22536. clone(): MorphTarget;
  22537. /**
  22538. * Serializes the current target into a Serialization object
  22539. * @returns the serialized object
  22540. */
  22541. serialize(): any;
  22542. /**
  22543. * Returns the string "MorphTarget"
  22544. * @returns "MorphTarget"
  22545. */
  22546. getClassName(): string;
  22547. /**
  22548. * Creates a new target from serialized data
  22549. * @param serializationObject defines the serialized data to use
  22550. * @returns a new MorphTarget
  22551. */
  22552. static Parse(serializationObject: any): MorphTarget;
  22553. /**
  22554. * Creates a MorphTarget from mesh data
  22555. * @param mesh defines the source mesh
  22556. * @param name defines the name to use for the new target
  22557. * @param influence defines the influence to attach to the target
  22558. * @returns a new MorphTarget
  22559. */
  22560. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22561. }
  22562. }
  22563. declare module BABYLON {
  22564. /**
  22565. * This class is used to deform meshes using morphing between different targets
  22566. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22567. */
  22568. export class MorphTargetManager {
  22569. private _targets;
  22570. private _targetInfluenceChangedObservers;
  22571. private _targetDataLayoutChangedObservers;
  22572. private _activeTargets;
  22573. private _scene;
  22574. private _influences;
  22575. private _supportsNormals;
  22576. private _supportsTangents;
  22577. private _supportsUVs;
  22578. private _vertexCount;
  22579. private _uniqueId;
  22580. private _tempInfluences;
  22581. /**
  22582. * Gets or sets a boolean indicating if normals must be morphed
  22583. */
  22584. enableNormalMorphing: boolean;
  22585. /**
  22586. * Gets or sets a boolean indicating if tangents must be morphed
  22587. */
  22588. enableTangentMorphing: boolean;
  22589. /**
  22590. * Gets or sets a boolean indicating if UV must be morphed
  22591. */
  22592. enableUVMorphing: boolean;
  22593. /**
  22594. * Creates a new MorphTargetManager
  22595. * @param scene defines the current scene
  22596. */
  22597. constructor(scene?: Nullable<Scene>);
  22598. /**
  22599. * Gets the unique ID of this manager
  22600. */
  22601. get uniqueId(): number;
  22602. /**
  22603. * Gets the number of vertices handled by this manager
  22604. */
  22605. get vertexCount(): number;
  22606. /**
  22607. * Gets a boolean indicating if this manager supports morphing of normals
  22608. */
  22609. get supportsNormals(): boolean;
  22610. /**
  22611. * Gets a boolean indicating if this manager supports morphing of tangents
  22612. */
  22613. get supportsTangents(): boolean;
  22614. /**
  22615. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22616. */
  22617. get supportsUVs(): boolean;
  22618. /**
  22619. * Gets the number of targets stored in this manager
  22620. */
  22621. get numTargets(): number;
  22622. /**
  22623. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22624. */
  22625. get numInfluencers(): number;
  22626. /**
  22627. * Gets the list of influences (one per target)
  22628. */
  22629. get influences(): Float32Array;
  22630. /**
  22631. * Gets the active target at specified index. An active target is a target with an influence > 0
  22632. * @param index defines the index to check
  22633. * @returns the requested target
  22634. */
  22635. getActiveTarget(index: number): MorphTarget;
  22636. /**
  22637. * Gets the target at specified index
  22638. * @param index defines the index to check
  22639. * @returns the requested target
  22640. */
  22641. getTarget(index: number): MorphTarget;
  22642. /**
  22643. * Add a new target to this manager
  22644. * @param target defines the target to add
  22645. */
  22646. addTarget(target: MorphTarget): void;
  22647. /**
  22648. * Removes a target from the manager
  22649. * @param target defines the target to remove
  22650. */
  22651. removeTarget(target: MorphTarget): void;
  22652. /**
  22653. * Clone the current manager
  22654. * @returns a new MorphTargetManager
  22655. */
  22656. clone(): MorphTargetManager;
  22657. /**
  22658. * Serializes the current manager into a Serialization object
  22659. * @returns the serialized object
  22660. */
  22661. serialize(): any;
  22662. private _syncActiveTargets;
  22663. /**
  22664. * Syncrhonize the targets with all the meshes using this morph target manager
  22665. */
  22666. synchronize(): void;
  22667. /**
  22668. * Creates a new MorphTargetManager from serialized data
  22669. * @param serializationObject defines the serialized data
  22670. * @param scene defines the hosting scene
  22671. * @returns the new MorphTargetManager
  22672. */
  22673. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22674. }
  22675. }
  22676. declare module BABYLON {
  22677. /**
  22678. * Class used to represent a specific level of detail of a mesh
  22679. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22680. */
  22681. export class MeshLODLevel {
  22682. /** Defines the distance where this level should start being displayed */
  22683. distance: number;
  22684. /** Defines the mesh to use to render this level */
  22685. mesh: Nullable<Mesh>;
  22686. /**
  22687. * Creates a new LOD level
  22688. * @param distance defines the distance where this level should star being displayed
  22689. * @param mesh defines the mesh to use to render this level
  22690. */
  22691. constructor(
  22692. /** Defines the distance where this level should start being displayed */
  22693. distance: number,
  22694. /** Defines the mesh to use to render this level */
  22695. mesh: Nullable<Mesh>);
  22696. }
  22697. }
  22698. declare module BABYLON {
  22699. /**
  22700. * Mesh representing the gorund
  22701. */
  22702. export class GroundMesh extends Mesh {
  22703. /** If octree should be generated */
  22704. generateOctree: boolean;
  22705. private _heightQuads;
  22706. /** @hidden */
  22707. _subdivisionsX: number;
  22708. /** @hidden */
  22709. _subdivisionsY: number;
  22710. /** @hidden */
  22711. _width: number;
  22712. /** @hidden */
  22713. _height: number;
  22714. /** @hidden */
  22715. _minX: number;
  22716. /** @hidden */
  22717. _maxX: number;
  22718. /** @hidden */
  22719. _minZ: number;
  22720. /** @hidden */
  22721. _maxZ: number;
  22722. constructor(name: string, scene: Scene);
  22723. /**
  22724. * "GroundMesh"
  22725. * @returns "GroundMesh"
  22726. */
  22727. getClassName(): string;
  22728. /**
  22729. * The minimum of x and y subdivisions
  22730. */
  22731. get subdivisions(): number;
  22732. /**
  22733. * X subdivisions
  22734. */
  22735. get subdivisionsX(): number;
  22736. /**
  22737. * Y subdivisions
  22738. */
  22739. get subdivisionsY(): number;
  22740. /**
  22741. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22742. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22743. * @param chunksCount the number of subdivisions for x and y
  22744. * @param octreeBlocksSize (Default: 32)
  22745. */
  22746. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22747. /**
  22748. * Returns a height (y) value in the Worl system :
  22749. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22750. * @param x x coordinate
  22751. * @param z z coordinate
  22752. * @returns the ground y position if (x, z) are outside the ground surface.
  22753. */
  22754. getHeightAtCoordinates(x: number, z: number): number;
  22755. /**
  22756. * Returns a normalized vector (Vector3) orthogonal to the ground
  22757. * at the ground coordinates (x, z) expressed in the World system.
  22758. * @param x x coordinate
  22759. * @param z z coordinate
  22760. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22761. */
  22762. getNormalAtCoordinates(x: number, z: number): Vector3;
  22763. /**
  22764. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22765. * at the ground coordinates (x, z) expressed in the World system.
  22766. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22767. * @param x x coordinate
  22768. * @param z z coordinate
  22769. * @param ref vector to store the result
  22770. * @returns the GroundMesh.
  22771. */
  22772. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22773. /**
  22774. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22775. * if the ground has been updated.
  22776. * This can be used in the render loop.
  22777. * @returns the GroundMesh.
  22778. */
  22779. updateCoordinateHeights(): GroundMesh;
  22780. private _getFacetAt;
  22781. private _initHeightQuads;
  22782. private _computeHeightQuads;
  22783. /**
  22784. * Serializes this ground mesh
  22785. * @param serializationObject object to write serialization to
  22786. */
  22787. serialize(serializationObject: any): void;
  22788. /**
  22789. * Parses a serialized ground mesh
  22790. * @param parsedMesh the serialized mesh
  22791. * @param scene the scene to create the ground mesh in
  22792. * @returns the created ground mesh
  22793. */
  22794. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22795. }
  22796. }
  22797. declare module BABYLON {
  22798. /**
  22799. * Interface for Physics-Joint data
  22800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22801. */
  22802. export interface PhysicsJointData {
  22803. /**
  22804. * The main pivot of the joint
  22805. */
  22806. mainPivot?: Vector3;
  22807. /**
  22808. * The connected pivot of the joint
  22809. */
  22810. connectedPivot?: Vector3;
  22811. /**
  22812. * The main axis of the joint
  22813. */
  22814. mainAxis?: Vector3;
  22815. /**
  22816. * The connected axis of the joint
  22817. */
  22818. connectedAxis?: Vector3;
  22819. /**
  22820. * The collision of the joint
  22821. */
  22822. collision?: boolean;
  22823. /**
  22824. * Native Oimo/Cannon/Energy data
  22825. */
  22826. nativeParams?: any;
  22827. }
  22828. /**
  22829. * This is a holder class for the physics joint created by the physics plugin
  22830. * It holds a set of functions to control the underlying joint
  22831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22832. */
  22833. export class PhysicsJoint {
  22834. /**
  22835. * The type of the physics joint
  22836. */
  22837. type: number;
  22838. /**
  22839. * The data for the physics joint
  22840. */
  22841. jointData: PhysicsJointData;
  22842. private _physicsJoint;
  22843. protected _physicsPlugin: IPhysicsEnginePlugin;
  22844. /**
  22845. * Initializes the physics joint
  22846. * @param type The type of the physics joint
  22847. * @param jointData The data for the physics joint
  22848. */
  22849. constructor(
  22850. /**
  22851. * The type of the physics joint
  22852. */
  22853. type: number,
  22854. /**
  22855. * The data for the physics joint
  22856. */
  22857. jointData: PhysicsJointData);
  22858. /**
  22859. * Gets the physics joint
  22860. */
  22861. get physicsJoint(): any;
  22862. /**
  22863. * Sets the physics joint
  22864. */
  22865. set physicsJoint(newJoint: any);
  22866. /**
  22867. * Sets the physics plugin
  22868. */
  22869. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22870. /**
  22871. * Execute a function that is physics-plugin specific.
  22872. * @param {Function} func the function that will be executed.
  22873. * It accepts two parameters: the physics world and the physics joint
  22874. */
  22875. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22876. /**
  22877. * Distance-Joint type
  22878. */
  22879. static DistanceJoint: number;
  22880. /**
  22881. * Hinge-Joint type
  22882. */
  22883. static HingeJoint: number;
  22884. /**
  22885. * Ball-and-Socket joint type
  22886. */
  22887. static BallAndSocketJoint: number;
  22888. /**
  22889. * Wheel-Joint type
  22890. */
  22891. static WheelJoint: number;
  22892. /**
  22893. * Slider-Joint type
  22894. */
  22895. static SliderJoint: number;
  22896. /**
  22897. * Prismatic-Joint type
  22898. */
  22899. static PrismaticJoint: number;
  22900. /**
  22901. * Universal-Joint type
  22902. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22903. */
  22904. static UniversalJoint: number;
  22905. /**
  22906. * Hinge-Joint 2 type
  22907. */
  22908. static Hinge2Joint: number;
  22909. /**
  22910. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22911. */
  22912. static PointToPointJoint: number;
  22913. /**
  22914. * Spring-Joint type
  22915. */
  22916. static SpringJoint: number;
  22917. /**
  22918. * Lock-Joint type
  22919. */
  22920. static LockJoint: number;
  22921. }
  22922. /**
  22923. * A class representing a physics distance joint
  22924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22925. */
  22926. export class DistanceJoint extends PhysicsJoint {
  22927. /**
  22928. *
  22929. * @param jointData The data for the Distance-Joint
  22930. */
  22931. constructor(jointData: DistanceJointData);
  22932. /**
  22933. * Update the predefined distance.
  22934. * @param maxDistance The maximum preferred distance
  22935. * @param minDistance The minimum preferred distance
  22936. */
  22937. updateDistance(maxDistance: number, minDistance?: number): void;
  22938. }
  22939. /**
  22940. * Represents a Motor-Enabled Joint
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22944. /**
  22945. * Initializes the Motor-Enabled Joint
  22946. * @param type The type of the joint
  22947. * @param jointData The physica joint data for the joint
  22948. */
  22949. constructor(type: number, jointData: PhysicsJointData);
  22950. /**
  22951. * Set the motor values.
  22952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22953. * @param force the force to apply
  22954. * @param maxForce max force for this motor.
  22955. */
  22956. setMotor(force?: number, maxForce?: number): void;
  22957. /**
  22958. * Set the motor's limits.
  22959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22960. * @param upperLimit The upper limit of the motor
  22961. * @param lowerLimit The lower limit of the motor
  22962. */
  22963. setLimit(upperLimit: number, lowerLimit?: number): void;
  22964. }
  22965. /**
  22966. * This class represents a single physics Hinge-Joint
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export class HingeJoint extends MotorEnabledJoint {
  22970. /**
  22971. * Initializes the Hinge-Joint
  22972. * @param jointData The joint data for the Hinge-Joint
  22973. */
  22974. constructor(jointData: PhysicsJointData);
  22975. /**
  22976. * Set the motor values.
  22977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22978. * @param {number} force the force to apply
  22979. * @param {number} maxForce max force for this motor.
  22980. */
  22981. setMotor(force?: number, maxForce?: number): void;
  22982. /**
  22983. * Set the motor's limits.
  22984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22985. * @param upperLimit The upper limit of the motor
  22986. * @param lowerLimit The lower limit of the motor
  22987. */
  22988. setLimit(upperLimit: number, lowerLimit?: number): void;
  22989. }
  22990. /**
  22991. * This class represents a dual hinge physics joint (same as wheel joint)
  22992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22993. */
  22994. export class Hinge2Joint extends MotorEnabledJoint {
  22995. /**
  22996. * Initializes the Hinge2-Joint
  22997. * @param jointData The joint data for the Hinge2-Joint
  22998. */
  22999. constructor(jointData: PhysicsJointData);
  23000. /**
  23001. * Set the motor values.
  23002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23003. * @param {number} targetSpeed the speed the motor is to reach
  23004. * @param {number} maxForce max force for this motor.
  23005. * @param {motorIndex} the motor's index, 0 or 1.
  23006. */
  23007. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23008. /**
  23009. * Set the motor limits.
  23010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23011. * @param {number} upperLimit the upper limit
  23012. * @param {number} lowerLimit lower limit
  23013. * @param {motorIndex} the motor's index, 0 or 1.
  23014. */
  23015. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23016. }
  23017. /**
  23018. * Interface for a motor enabled joint
  23019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23020. */
  23021. export interface IMotorEnabledJoint {
  23022. /**
  23023. * Physics joint
  23024. */
  23025. physicsJoint: any;
  23026. /**
  23027. * Sets the motor of the motor-enabled joint
  23028. * @param force The force of the motor
  23029. * @param maxForce The maximum force of the motor
  23030. * @param motorIndex The index of the motor
  23031. */
  23032. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23033. /**
  23034. * Sets the limit of the motor
  23035. * @param upperLimit The upper limit of the motor
  23036. * @param lowerLimit The lower limit of the motor
  23037. * @param motorIndex The index of the motor
  23038. */
  23039. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23040. }
  23041. /**
  23042. * Joint data for a Distance-Joint
  23043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23044. */
  23045. export interface DistanceJointData extends PhysicsJointData {
  23046. /**
  23047. * Max distance the 2 joint objects can be apart
  23048. */
  23049. maxDistance: number;
  23050. }
  23051. /**
  23052. * Joint data from a spring joint
  23053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23054. */
  23055. export interface SpringJointData extends PhysicsJointData {
  23056. /**
  23057. * Length of the spring
  23058. */
  23059. length: number;
  23060. /**
  23061. * Stiffness of the spring
  23062. */
  23063. stiffness: number;
  23064. /**
  23065. * Damping of the spring
  23066. */
  23067. damping: number;
  23068. /** this callback will be called when applying the force to the impostors. */
  23069. forceApplicationCallback: () => void;
  23070. }
  23071. }
  23072. declare module BABYLON {
  23073. /**
  23074. * Holds the data for the raycast result
  23075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23076. */
  23077. export class PhysicsRaycastResult {
  23078. private _hasHit;
  23079. private _hitDistance;
  23080. private _hitNormalWorld;
  23081. private _hitPointWorld;
  23082. private _rayFromWorld;
  23083. private _rayToWorld;
  23084. /**
  23085. * Gets if there was a hit
  23086. */
  23087. get hasHit(): boolean;
  23088. /**
  23089. * Gets the distance from the hit
  23090. */
  23091. get hitDistance(): number;
  23092. /**
  23093. * Gets the hit normal/direction in the world
  23094. */
  23095. get hitNormalWorld(): Vector3;
  23096. /**
  23097. * Gets the hit point in the world
  23098. */
  23099. get hitPointWorld(): Vector3;
  23100. /**
  23101. * Gets the ray "start point" of the ray in the world
  23102. */
  23103. get rayFromWorld(): Vector3;
  23104. /**
  23105. * Gets the ray "end point" of the ray in the world
  23106. */
  23107. get rayToWorld(): Vector3;
  23108. /**
  23109. * Sets the hit data (normal & point in world space)
  23110. * @param hitNormalWorld defines the normal in world space
  23111. * @param hitPointWorld defines the point in world space
  23112. */
  23113. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23114. /**
  23115. * Sets the distance from the start point to the hit point
  23116. * @param distance
  23117. */
  23118. setHitDistance(distance: number): void;
  23119. /**
  23120. * Calculates the distance manually
  23121. */
  23122. calculateHitDistance(): void;
  23123. /**
  23124. * Resets all the values to default
  23125. * @param from The from point on world space
  23126. * @param to The to point on world space
  23127. */
  23128. reset(from?: Vector3, to?: Vector3): void;
  23129. }
  23130. /**
  23131. * Interface for the size containing width and height
  23132. */
  23133. interface IXYZ {
  23134. /**
  23135. * X
  23136. */
  23137. x: number;
  23138. /**
  23139. * Y
  23140. */
  23141. y: number;
  23142. /**
  23143. * Z
  23144. */
  23145. z: number;
  23146. }
  23147. }
  23148. declare module BABYLON {
  23149. /**
  23150. * Interface used to describe a physics joint
  23151. */
  23152. export interface PhysicsImpostorJoint {
  23153. /** Defines the main impostor to which the joint is linked */
  23154. mainImpostor: PhysicsImpostor;
  23155. /** Defines the impostor that is connected to the main impostor using this joint */
  23156. connectedImpostor: PhysicsImpostor;
  23157. /** Defines the joint itself */
  23158. joint: PhysicsJoint;
  23159. }
  23160. /** @hidden */
  23161. export interface IPhysicsEnginePlugin {
  23162. world: any;
  23163. name: string;
  23164. setGravity(gravity: Vector3): void;
  23165. setTimeStep(timeStep: number): void;
  23166. getTimeStep(): number;
  23167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23171. removePhysicsBody(impostor: PhysicsImpostor): void;
  23172. generateJoint(joint: PhysicsImpostorJoint): void;
  23173. removeJoint(joint: PhysicsImpostorJoint): void;
  23174. isSupported(): boolean;
  23175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23177. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23178. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23179. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23180. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23182. getBodyMass(impostor: PhysicsImpostor): number;
  23183. getBodyFriction(impostor: PhysicsImpostor): number;
  23184. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23185. getBodyRestitution(impostor: PhysicsImpostor): number;
  23186. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23187. getBodyPressure?(impostor: PhysicsImpostor): number;
  23188. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23189. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23190. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23191. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23192. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23193. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23194. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23195. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23196. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23197. sleepBody(impostor: PhysicsImpostor): void;
  23198. wakeUpBody(impostor: PhysicsImpostor): void;
  23199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23200. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23201. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23202. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23203. getRadius(impostor: PhysicsImpostor): number;
  23204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23206. dispose(): void;
  23207. }
  23208. /**
  23209. * Interface used to define a physics engine
  23210. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface IPhysicsEngine {
  23213. /**
  23214. * Gets the gravity vector used by the simulation
  23215. */
  23216. gravity: Vector3;
  23217. /**
  23218. * Sets the gravity vector used by the simulation
  23219. * @param gravity defines the gravity vector to use
  23220. */
  23221. setGravity(gravity: Vector3): void;
  23222. /**
  23223. * Set the time step of the physics engine.
  23224. * Default is 1/60.
  23225. * To slow it down, enter 1/600 for example.
  23226. * To speed it up, 1/30
  23227. * @param newTimeStep the new timestep to apply to this world.
  23228. */
  23229. setTimeStep(newTimeStep: number): void;
  23230. /**
  23231. * Get the time step of the physics engine.
  23232. * @returns the current time step
  23233. */
  23234. getTimeStep(): number;
  23235. /**
  23236. * Set the sub time step of the physics engine.
  23237. * Default is 0 meaning there is no sub steps
  23238. * To increase physics resolution precision, set a small value (like 1 ms)
  23239. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23240. */
  23241. setSubTimeStep(subTimeStep: number): void;
  23242. /**
  23243. * Get the sub time step of the physics engine.
  23244. * @returns the current sub time step
  23245. */
  23246. getSubTimeStep(): number;
  23247. /**
  23248. * Release all resources
  23249. */
  23250. dispose(): void;
  23251. /**
  23252. * Gets the name of the current physics plugin
  23253. * @returns the name of the plugin
  23254. */
  23255. getPhysicsPluginName(): string;
  23256. /**
  23257. * Adding a new impostor for the impostor tracking.
  23258. * This will be done by the impostor itself.
  23259. * @param impostor the impostor to add
  23260. */
  23261. addImpostor(impostor: PhysicsImpostor): void;
  23262. /**
  23263. * Remove an impostor from the engine.
  23264. * This impostor and its mesh will not longer be updated by the physics engine.
  23265. * @param impostor the impostor to remove
  23266. */
  23267. removeImpostor(impostor: PhysicsImpostor): void;
  23268. /**
  23269. * Add a joint to the physics engine
  23270. * @param mainImpostor defines the main impostor to which the joint is added.
  23271. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23272. * @param joint defines the joint that will connect both impostors.
  23273. */
  23274. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23275. /**
  23276. * Removes a joint from the simulation
  23277. * @param mainImpostor defines the impostor used with the joint
  23278. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23279. * @param joint defines the joint to remove
  23280. */
  23281. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23282. /**
  23283. * Gets the current plugin used to run the simulation
  23284. * @returns current plugin
  23285. */
  23286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23287. /**
  23288. * Gets the list of physic impostors
  23289. * @returns an array of PhysicsImpostor
  23290. */
  23291. getImpostors(): Array<PhysicsImpostor>;
  23292. /**
  23293. * Gets the impostor for a physics enabled object
  23294. * @param object defines the object impersonated by the impostor
  23295. * @returns the PhysicsImpostor or null if not found
  23296. */
  23297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23298. /**
  23299. * Gets the impostor for a physics body object
  23300. * @param body defines physics body used by the impostor
  23301. * @returns the PhysicsImpostor or null if not found
  23302. */
  23303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23304. /**
  23305. * Does a raycast in the physics world
  23306. * @param from when should the ray start?
  23307. * @param to when should the ray end?
  23308. * @returns PhysicsRaycastResult
  23309. */
  23310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23311. /**
  23312. * Called by the scene. No need to call it.
  23313. * @param delta defines the timespam between frames
  23314. */
  23315. _step(delta: number): void;
  23316. }
  23317. }
  23318. declare module BABYLON {
  23319. /**
  23320. * The interface for the physics imposter parameters
  23321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23322. */
  23323. export interface PhysicsImpostorParameters {
  23324. /**
  23325. * The mass of the physics imposter
  23326. */
  23327. mass: number;
  23328. /**
  23329. * The friction of the physics imposter
  23330. */
  23331. friction?: number;
  23332. /**
  23333. * The coefficient of restitution of the physics imposter
  23334. */
  23335. restitution?: number;
  23336. /**
  23337. * The native options of the physics imposter
  23338. */
  23339. nativeOptions?: any;
  23340. /**
  23341. * Specifies if the parent should be ignored
  23342. */
  23343. ignoreParent?: boolean;
  23344. /**
  23345. * Specifies if bi-directional transformations should be disabled
  23346. */
  23347. disableBidirectionalTransformation?: boolean;
  23348. /**
  23349. * The pressure inside the physics imposter, soft object only
  23350. */
  23351. pressure?: number;
  23352. /**
  23353. * The stiffness the physics imposter, soft object only
  23354. */
  23355. stiffness?: number;
  23356. /**
  23357. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23358. */
  23359. velocityIterations?: number;
  23360. /**
  23361. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23362. */
  23363. positionIterations?: number;
  23364. /**
  23365. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23366. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23367. * Add to fix multiple points
  23368. */
  23369. fixedPoints?: number;
  23370. /**
  23371. * The collision margin around a soft object
  23372. */
  23373. margin?: number;
  23374. /**
  23375. * The collision margin around a soft object
  23376. */
  23377. damping?: number;
  23378. /**
  23379. * The path for a rope based on an extrusion
  23380. */
  23381. path?: any;
  23382. /**
  23383. * The shape of an extrusion used for a rope based on an extrusion
  23384. */
  23385. shape?: any;
  23386. }
  23387. /**
  23388. * Interface for a physics-enabled object
  23389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23390. */
  23391. export interface IPhysicsEnabledObject {
  23392. /**
  23393. * The position of the physics-enabled object
  23394. */
  23395. position: Vector3;
  23396. /**
  23397. * The rotation of the physics-enabled object
  23398. */
  23399. rotationQuaternion: Nullable<Quaternion>;
  23400. /**
  23401. * The scale of the physics-enabled object
  23402. */
  23403. scaling: Vector3;
  23404. /**
  23405. * The rotation of the physics-enabled object
  23406. */
  23407. rotation?: Vector3;
  23408. /**
  23409. * The parent of the physics-enabled object
  23410. */
  23411. parent?: any;
  23412. /**
  23413. * The bounding info of the physics-enabled object
  23414. * @returns The bounding info of the physics-enabled object
  23415. */
  23416. getBoundingInfo(): BoundingInfo;
  23417. /**
  23418. * Computes the world matrix
  23419. * @param force Specifies if the world matrix should be computed by force
  23420. * @returns A world matrix
  23421. */
  23422. computeWorldMatrix(force: boolean): Matrix;
  23423. /**
  23424. * Gets the world matrix
  23425. * @returns A world matrix
  23426. */
  23427. getWorldMatrix?(): Matrix;
  23428. /**
  23429. * Gets the child meshes
  23430. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23431. * @returns An array of abstract meshes
  23432. */
  23433. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23434. /**
  23435. * Gets the vertex data
  23436. * @param kind The type of vertex data
  23437. * @returns A nullable array of numbers, or a float32 array
  23438. */
  23439. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23440. /**
  23441. * Gets the indices from the mesh
  23442. * @returns A nullable array of index arrays
  23443. */
  23444. getIndices?(): Nullable<IndicesArray>;
  23445. /**
  23446. * Gets the scene from the mesh
  23447. * @returns the indices array or null
  23448. */
  23449. getScene?(): Scene;
  23450. /**
  23451. * Gets the absolute position from the mesh
  23452. * @returns the absolute position
  23453. */
  23454. getAbsolutePosition(): Vector3;
  23455. /**
  23456. * Gets the absolute pivot point from the mesh
  23457. * @returns the absolute pivot point
  23458. */
  23459. getAbsolutePivotPoint(): Vector3;
  23460. /**
  23461. * Rotates the mesh
  23462. * @param axis The axis of rotation
  23463. * @param amount The amount of rotation
  23464. * @param space The space of the rotation
  23465. * @returns The rotation transform node
  23466. */
  23467. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23468. /**
  23469. * Translates the mesh
  23470. * @param axis The axis of translation
  23471. * @param distance The distance of translation
  23472. * @param space The space of the translation
  23473. * @returns The transform node
  23474. */
  23475. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23476. /**
  23477. * Sets the absolute position of the mesh
  23478. * @param absolutePosition The absolute position of the mesh
  23479. * @returns The transform node
  23480. */
  23481. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23482. /**
  23483. * Gets the class name of the mesh
  23484. * @returns The class name
  23485. */
  23486. getClassName(): string;
  23487. }
  23488. /**
  23489. * Represents a physics imposter
  23490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23491. */
  23492. export class PhysicsImpostor {
  23493. /**
  23494. * The physics-enabled object used as the physics imposter
  23495. */
  23496. object: IPhysicsEnabledObject;
  23497. /**
  23498. * The type of the physics imposter
  23499. */
  23500. type: number;
  23501. private _options;
  23502. private _scene?;
  23503. /**
  23504. * The default object size of the imposter
  23505. */
  23506. static DEFAULT_OBJECT_SIZE: Vector3;
  23507. /**
  23508. * The identity quaternion of the imposter
  23509. */
  23510. static IDENTITY_QUATERNION: Quaternion;
  23511. /** @hidden */
  23512. _pluginData: any;
  23513. private _physicsEngine;
  23514. private _physicsBody;
  23515. private _bodyUpdateRequired;
  23516. private _onBeforePhysicsStepCallbacks;
  23517. private _onAfterPhysicsStepCallbacks;
  23518. /** @hidden */
  23519. _onPhysicsCollideCallbacks: Array<{
  23520. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23521. otherImpostors: Array<PhysicsImpostor>;
  23522. }>;
  23523. private _deltaPosition;
  23524. private _deltaRotation;
  23525. private _deltaRotationConjugated;
  23526. /** @hidden */
  23527. _isFromLine: boolean;
  23528. private _parent;
  23529. private _isDisposed;
  23530. private static _tmpVecs;
  23531. private static _tmpQuat;
  23532. /**
  23533. * Specifies if the physics imposter is disposed
  23534. */
  23535. get isDisposed(): boolean;
  23536. /**
  23537. * Gets the mass of the physics imposter
  23538. */
  23539. get mass(): number;
  23540. set mass(value: number);
  23541. /**
  23542. * Gets the coefficient of friction
  23543. */
  23544. get friction(): number;
  23545. /**
  23546. * Sets the coefficient of friction
  23547. */
  23548. set friction(value: number);
  23549. /**
  23550. * Gets the coefficient of restitution
  23551. */
  23552. get restitution(): number;
  23553. /**
  23554. * Sets the coefficient of restitution
  23555. */
  23556. set restitution(value: number);
  23557. /**
  23558. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23559. */
  23560. get pressure(): number;
  23561. /**
  23562. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23563. */
  23564. set pressure(value: number);
  23565. /**
  23566. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23567. */
  23568. get stiffness(): number;
  23569. /**
  23570. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23571. */
  23572. set stiffness(value: number);
  23573. /**
  23574. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. get velocityIterations(): number;
  23577. /**
  23578. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23579. */
  23580. set velocityIterations(value: number);
  23581. /**
  23582. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23583. */
  23584. get positionIterations(): number;
  23585. /**
  23586. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23587. */
  23588. set positionIterations(value: number);
  23589. /**
  23590. * The unique id of the physics imposter
  23591. * set by the physics engine when adding this impostor to the array
  23592. */
  23593. uniqueId: number;
  23594. /**
  23595. * @hidden
  23596. */
  23597. soft: boolean;
  23598. /**
  23599. * @hidden
  23600. */
  23601. segments: number;
  23602. private _joints;
  23603. /**
  23604. * Initializes the physics imposter
  23605. * @param object The physics-enabled object used as the physics imposter
  23606. * @param type The type of the physics imposter
  23607. * @param _options The options for the physics imposter
  23608. * @param _scene The Babylon scene
  23609. */
  23610. constructor(
  23611. /**
  23612. * The physics-enabled object used as the physics imposter
  23613. */
  23614. object: IPhysicsEnabledObject,
  23615. /**
  23616. * The type of the physics imposter
  23617. */
  23618. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23619. /**
  23620. * This function will completly initialize this impostor.
  23621. * It will create a new body - but only if this mesh has no parent.
  23622. * If it has, this impostor will not be used other than to define the impostor
  23623. * of the child mesh.
  23624. * @hidden
  23625. */
  23626. _init(): void;
  23627. private _getPhysicsParent;
  23628. /**
  23629. * Should a new body be generated.
  23630. * @returns boolean specifying if body initialization is required
  23631. */
  23632. isBodyInitRequired(): boolean;
  23633. /**
  23634. * Sets the updated scaling
  23635. * @param updated Specifies if the scaling is updated
  23636. */
  23637. setScalingUpdated(): void;
  23638. /**
  23639. * Force a regeneration of this or the parent's impostor's body.
  23640. * Use under cautious - This will remove all joints already implemented.
  23641. */
  23642. forceUpdate(): void;
  23643. /**
  23644. * Gets the body that holds this impostor. Either its own, or its parent.
  23645. */
  23646. get physicsBody(): any;
  23647. /**
  23648. * Get the parent of the physics imposter
  23649. * @returns Physics imposter or null
  23650. */
  23651. get parent(): Nullable<PhysicsImpostor>;
  23652. /**
  23653. * Sets the parent of the physics imposter
  23654. */
  23655. set parent(value: Nullable<PhysicsImpostor>);
  23656. /**
  23657. * Set the physics body. Used mainly by the physics engine/plugin
  23658. */
  23659. set physicsBody(physicsBody: any);
  23660. /**
  23661. * Resets the update flags
  23662. */
  23663. resetUpdateFlags(): void;
  23664. /**
  23665. * Gets the object extend size
  23666. * @returns the object extend size
  23667. */
  23668. getObjectExtendSize(): Vector3;
  23669. /**
  23670. * Gets the object center
  23671. * @returns The object center
  23672. */
  23673. getObjectCenter(): Vector3;
  23674. /**
  23675. * Get a specific parametes from the options parameter
  23676. * @param paramName The object parameter name
  23677. * @returns The object parameter
  23678. */
  23679. getParam(paramName: string): any;
  23680. /**
  23681. * Sets a specific parameter in the options given to the physics plugin
  23682. * @param paramName The parameter name
  23683. * @param value The value of the parameter
  23684. */
  23685. setParam(paramName: string, value: number): void;
  23686. /**
  23687. * Specifically change the body's mass option. Won't recreate the physics body object
  23688. * @param mass The mass of the physics imposter
  23689. */
  23690. setMass(mass: number): void;
  23691. /**
  23692. * Gets the linear velocity
  23693. * @returns linear velocity or null
  23694. */
  23695. getLinearVelocity(): Nullable<Vector3>;
  23696. /**
  23697. * Sets the linear velocity
  23698. * @param velocity linear velocity or null
  23699. */
  23700. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23701. /**
  23702. * Gets the angular velocity
  23703. * @returns angular velocity or null
  23704. */
  23705. getAngularVelocity(): Nullable<Vector3>;
  23706. /**
  23707. * Sets the angular velocity
  23708. * @param velocity The velocity or null
  23709. */
  23710. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23711. /**
  23712. * Execute a function with the physics plugin native code
  23713. * Provide a function the will have two variables - the world object and the physics body object
  23714. * @param func The function to execute with the physics plugin native code
  23715. */
  23716. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23717. /**
  23718. * Register a function that will be executed before the physics world is stepping forward
  23719. * @param func The function to execute before the physics world is stepped forward
  23720. */
  23721. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23722. /**
  23723. * Unregister a function that will be executed before the physics world is stepping forward
  23724. * @param func The function to execute before the physics world is stepped forward
  23725. */
  23726. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23727. /**
  23728. * Register a function that will be executed after the physics step
  23729. * @param func The function to execute after physics step
  23730. */
  23731. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23732. /**
  23733. * Unregisters a function that will be executed after the physics step
  23734. * @param func The function to execute after physics step
  23735. */
  23736. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23737. /**
  23738. * register a function that will be executed when this impostor collides against a different body
  23739. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23740. * @param func Callback that is executed on collision
  23741. */
  23742. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23743. /**
  23744. * Unregisters the physics imposter on contact
  23745. * @param collideAgainst The physics object to collide against
  23746. * @param func Callback to execute on collision
  23747. */
  23748. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23749. private _tmpQuat;
  23750. private _tmpQuat2;
  23751. /**
  23752. * Get the parent rotation
  23753. * @returns The parent rotation
  23754. */
  23755. getParentsRotation(): Quaternion;
  23756. /**
  23757. * this function is executed by the physics engine.
  23758. */
  23759. beforeStep: () => void;
  23760. /**
  23761. * this function is executed by the physics engine
  23762. */
  23763. afterStep: () => void;
  23764. /**
  23765. * Legacy collision detection event support
  23766. */
  23767. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23768. /**
  23769. * event and body object due to cannon's event-based architecture.
  23770. */
  23771. onCollide: (e: {
  23772. body: any;
  23773. }) => void;
  23774. /**
  23775. * Apply a force
  23776. * @param force The force to apply
  23777. * @param contactPoint The contact point for the force
  23778. * @returns The physics imposter
  23779. */
  23780. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23781. /**
  23782. * Apply an impulse
  23783. * @param force The impulse force
  23784. * @param contactPoint The contact point for the impulse force
  23785. * @returns The physics imposter
  23786. */
  23787. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23788. /**
  23789. * A help function to create a joint
  23790. * @param otherImpostor A physics imposter used to create a joint
  23791. * @param jointType The type of joint
  23792. * @param jointData The data for the joint
  23793. * @returns The physics imposter
  23794. */
  23795. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23796. /**
  23797. * Add a joint to this impostor with a different impostor
  23798. * @param otherImpostor A physics imposter used to add a joint
  23799. * @param joint The joint to add
  23800. * @returns The physics imposter
  23801. */
  23802. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23803. /**
  23804. * Add an anchor to a cloth impostor
  23805. * @param otherImpostor rigid impostor to anchor to
  23806. * @param width ratio across width from 0 to 1
  23807. * @param height ratio up height from 0 to 1
  23808. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23809. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23810. * @returns impostor the soft imposter
  23811. */
  23812. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23813. /**
  23814. * Add a hook to a rope impostor
  23815. * @param otherImpostor rigid impostor to anchor to
  23816. * @param length ratio across rope from 0 to 1
  23817. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23818. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23819. * @returns impostor the rope imposter
  23820. */
  23821. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23822. /**
  23823. * Will keep this body still, in a sleep mode.
  23824. * @returns the physics imposter
  23825. */
  23826. sleep(): PhysicsImpostor;
  23827. /**
  23828. * Wake the body up.
  23829. * @returns The physics imposter
  23830. */
  23831. wakeUp(): PhysicsImpostor;
  23832. /**
  23833. * Clones the physics imposter
  23834. * @param newObject The physics imposter clones to this physics-enabled object
  23835. * @returns A nullable physics imposter
  23836. */
  23837. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23838. /**
  23839. * Disposes the physics imposter
  23840. */
  23841. dispose(): void;
  23842. /**
  23843. * Sets the delta position
  23844. * @param position The delta position amount
  23845. */
  23846. setDeltaPosition(position: Vector3): void;
  23847. /**
  23848. * Sets the delta rotation
  23849. * @param rotation The delta rotation amount
  23850. */
  23851. setDeltaRotation(rotation: Quaternion): void;
  23852. /**
  23853. * Gets the box size of the physics imposter and stores the result in the input parameter
  23854. * @param result Stores the box size
  23855. * @returns The physics imposter
  23856. */
  23857. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23858. /**
  23859. * Gets the radius of the physics imposter
  23860. * @returns Radius of the physics imposter
  23861. */
  23862. getRadius(): number;
  23863. /**
  23864. * Sync a bone with this impostor
  23865. * @param bone The bone to sync to the impostor.
  23866. * @param boneMesh The mesh that the bone is influencing.
  23867. * @param jointPivot The pivot of the joint / bone in local space.
  23868. * @param distToJoint Optional distance from the impostor to the joint.
  23869. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23870. */
  23871. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23872. /**
  23873. * Sync impostor to a bone
  23874. * @param bone The bone that the impostor will be synced to.
  23875. * @param boneMesh The mesh that the bone is influencing.
  23876. * @param jointPivot The pivot of the joint / bone in local space.
  23877. * @param distToJoint Optional distance from the impostor to the joint.
  23878. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23879. * @param boneAxis Optional vector3 axis the bone is aligned with
  23880. */
  23881. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23882. /**
  23883. * No-Imposter type
  23884. */
  23885. static NoImpostor: number;
  23886. /**
  23887. * Sphere-Imposter type
  23888. */
  23889. static SphereImpostor: number;
  23890. /**
  23891. * Box-Imposter type
  23892. */
  23893. static BoxImpostor: number;
  23894. /**
  23895. * Plane-Imposter type
  23896. */
  23897. static PlaneImpostor: number;
  23898. /**
  23899. * Mesh-imposter type
  23900. */
  23901. static MeshImpostor: number;
  23902. /**
  23903. * Capsule-Impostor type (Ammo.js plugin only)
  23904. */
  23905. static CapsuleImpostor: number;
  23906. /**
  23907. * Cylinder-Imposter type
  23908. */
  23909. static CylinderImpostor: number;
  23910. /**
  23911. * Particle-Imposter type
  23912. */
  23913. static ParticleImpostor: number;
  23914. /**
  23915. * Heightmap-Imposter type
  23916. */
  23917. static HeightmapImpostor: number;
  23918. /**
  23919. * ConvexHull-Impostor type (Ammo.js plugin only)
  23920. */
  23921. static ConvexHullImpostor: number;
  23922. /**
  23923. * Custom-Imposter type (Ammo.js plugin only)
  23924. */
  23925. static CustomImpostor: number;
  23926. /**
  23927. * Rope-Imposter type
  23928. */
  23929. static RopeImpostor: number;
  23930. /**
  23931. * Cloth-Imposter type
  23932. */
  23933. static ClothImpostor: number;
  23934. /**
  23935. * Softbody-Imposter type
  23936. */
  23937. static SoftbodyImpostor: number;
  23938. }
  23939. }
  23940. declare module BABYLON {
  23941. /**
  23942. * @hidden
  23943. **/
  23944. export class _CreationDataStorage {
  23945. closePath?: boolean;
  23946. closeArray?: boolean;
  23947. idx: number[];
  23948. dashSize: number;
  23949. gapSize: number;
  23950. path3D: Path3D;
  23951. pathArray: Vector3[][];
  23952. arc: number;
  23953. radius: number;
  23954. cap: number;
  23955. tessellation: number;
  23956. }
  23957. /**
  23958. * @hidden
  23959. **/
  23960. class _InstanceDataStorage {
  23961. visibleInstances: any;
  23962. batchCache: _InstancesBatch;
  23963. instancesBufferSize: number;
  23964. instancesBuffer: Nullable<Buffer>;
  23965. instancesData: Float32Array;
  23966. overridenInstanceCount: number;
  23967. isFrozen: boolean;
  23968. previousBatch: Nullable<_InstancesBatch>;
  23969. hardwareInstancedRendering: boolean;
  23970. sideOrientation: number;
  23971. manualUpdate: boolean;
  23972. }
  23973. /**
  23974. * @hidden
  23975. **/
  23976. export class _InstancesBatch {
  23977. mustReturn: boolean;
  23978. visibleInstances: Nullable<InstancedMesh[]>[];
  23979. renderSelf: boolean[];
  23980. hardwareInstancedRendering: boolean[];
  23981. }
  23982. /**
  23983. * Class used to represent renderable models
  23984. */
  23985. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23986. /**
  23987. * Mesh side orientation : usually the external or front surface
  23988. */
  23989. static readonly FRONTSIDE: number;
  23990. /**
  23991. * Mesh side orientation : usually the internal or back surface
  23992. */
  23993. static readonly BACKSIDE: number;
  23994. /**
  23995. * Mesh side orientation : both internal and external or front and back surfaces
  23996. */
  23997. static readonly DOUBLESIDE: number;
  23998. /**
  23999. * Mesh side orientation : by default, `FRONTSIDE`
  24000. */
  24001. static readonly DEFAULTSIDE: number;
  24002. /**
  24003. * Mesh cap setting : no cap
  24004. */
  24005. static readonly NO_CAP: number;
  24006. /**
  24007. * Mesh cap setting : one cap at the beginning of the mesh
  24008. */
  24009. static readonly CAP_START: number;
  24010. /**
  24011. * Mesh cap setting : one cap at the end of the mesh
  24012. */
  24013. static readonly CAP_END: number;
  24014. /**
  24015. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24016. */
  24017. static readonly CAP_ALL: number;
  24018. /**
  24019. * Mesh pattern setting : no flip or rotate
  24020. */
  24021. static readonly NO_FLIP: number;
  24022. /**
  24023. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24024. */
  24025. static readonly FLIP_TILE: number;
  24026. /**
  24027. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24028. */
  24029. static readonly ROTATE_TILE: number;
  24030. /**
  24031. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24032. */
  24033. static readonly FLIP_ROW: number;
  24034. /**
  24035. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24036. */
  24037. static readonly ROTATE_ROW: number;
  24038. /**
  24039. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24040. */
  24041. static readonly FLIP_N_ROTATE_TILE: number;
  24042. /**
  24043. * Mesh pattern setting : rotate pattern and rotate
  24044. */
  24045. static readonly FLIP_N_ROTATE_ROW: number;
  24046. /**
  24047. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24048. */
  24049. static readonly CENTER: number;
  24050. /**
  24051. * Mesh tile positioning : part tiles on left
  24052. */
  24053. static readonly LEFT: number;
  24054. /**
  24055. * Mesh tile positioning : part tiles on right
  24056. */
  24057. static readonly RIGHT: number;
  24058. /**
  24059. * Mesh tile positioning : part tiles on top
  24060. */
  24061. static readonly TOP: number;
  24062. /**
  24063. * Mesh tile positioning : part tiles on bottom
  24064. */
  24065. static readonly BOTTOM: number;
  24066. /**
  24067. * Gets the default side orientation.
  24068. * @param orientation the orientation to value to attempt to get
  24069. * @returns the default orientation
  24070. * @hidden
  24071. */
  24072. static _GetDefaultSideOrientation(orientation?: number): number;
  24073. private _internalMeshDataInfo;
  24074. /**
  24075. * An event triggered before rendering the mesh
  24076. */
  24077. get onBeforeRenderObservable(): Observable<Mesh>;
  24078. /**
  24079. * An event triggered before binding the mesh
  24080. */
  24081. get onBeforeBindObservable(): Observable<Mesh>;
  24082. /**
  24083. * An event triggered after rendering the mesh
  24084. */
  24085. get onAfterRenderObservable(): Observable<Mesh>;
  24086. /**
  24087. * An event triggered before drawing the mesh
  24088. */
  24089. get onBeforeDrawObservable(): Observable<Mesh>;
  24090. private _onBeforeDrawObserver;
  24091. /**
  24092. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24093. */
  24094. set onBeforeDraw(callback: () => void);
  24095. get hasInstances(): boolean;
  24096. /**
  24097. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24098. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24099. */
  24100. delayLoadState: number;
  24101. /**
  24102. * Gets the list of instances created from this mesh
  24103. * it is not supposed to be modified manually.
  24104. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24105. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24106. */
  24107. instances: InstancedMesh[];
  24108. /**
  24109. * Gets the file containing delay loading data for this mesh
  24110. */
  24111. delayLoadingFile: string;
  24112. /** @hidden */
  24113. _binaryInfo: any;
  24114. /**
  24115. * User defined function used to change how LOD level selection is done
  24116. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24117. */
  24118. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24119. /**
  24120. * Gets or sets the morph target manager
  24121. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24122. */
  24123. get morphTargetManager(): Nullable<MorphTargetManager>;
  24124. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24125. /** @hidden */
  24126. _creationDataStorage: Nullable<_CreationDataStorage>;
  24127. /** @hidden */
  24128. _geometry: Nullable<Geometry>;
  24129. /** @hidden */
  24130. _delayInfo: Array<string>;
  24131. /** @hidden */
  24132. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24133. /** @hidden */
  24134. _instanceDataStorage: _InstanceDataStorage;
  24135. private _effectiveMaterial;
  24136. /** @hidden */
  24137. _shouldGenerateFlatShading: boolean;
  24138. /** @hidden */
  24139. _originalBuilderSideOrientation: number;
  24140. /**
  24141. * Use this property to change the original side orientation defined at construction time
  24142. */
  24143. overrideMaterialSideOrientation: Nullable<number>;
  24144. /**
  24145. * Gets the source mesh (the one used to clone this one from)
  24146. */
  24147. get source(): Nullable<Mesh>;
  24148. /**
  24149. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24150. */
  24151. get isUnIndexed(): boolean;
  24152. set isUnIndexed(value: boolean);
  24153. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24154. get worldMatrixInstancedBuffer(): Float32Array;
  24155. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24156. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24157. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24158. /**
  24159. * @constructor
  24160. * @param name The value used by scene.getMeshByName() to do a lookup.
  24161. * @param scene The scene to add this mesh to.
  24162. * @param parent The parent of this mesh, if it has one
  24163. * @param source An optional Mesh from which geometry is shared, cloned.
  24164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24165. * When false, achieved by calling a clone(), also passing False.
  24166. * This will make creation of children, recursive.
  24167. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24168. */
  24169. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24170. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24171. doNotInstantiate: boolean;
  24172. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24173. /**
  24174. * Gets the class name
  24175. * @returns the string "Mesh".
  24176. */
  24177. getClassName(): string;
  24178. /** @hidden */
  24179. get _isMesh(): boolean;
  24180. /**
  24181. * Returns a description of this mesh
  24182. * @param fullDetails define if full details about this mesh must be used
  24183. * @returns a descriptive string representing this mesh
  24184. */
  24185. toString(fullDetails?: boolean): string;
  24186. /** @hidden */
  24187. _unBindEffect(): void;
  24188. /**
  24189. * Gets a boolean indicating if this mesh has LOD
  24190. */
  24191. get hasLODLevels(): boolean;
  24192. /**
  24193. * Gets the list of MeshLODLevel associated with the current mesh
  24194. * @returns an array of MeshLODLevel
  24195. */
  24196. getLODLevels(): MeshLODLevel[];
  24197. private _sortLODLevels;
  24198. /**
  24199. * Add a mesh as LOD level triggered at the given distance.
  24200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24201. * @param distance The distance from the center of the object to show this level
  24202. * @param mesh The mesh to be added as LOD level (can be null)
  24203. * @return This mesh (for chaining)
  24204. */
  24205. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24206. /**
  24207. * Returns the LOD level mesh at the passed distance or null if not found.
  24208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24209. * @param distance The distance from the center of the object to show this level
  24210. * @returns a Mesh or `null`
  24211. */
  24212. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24213. /**
  24214. * Remove a mesh from the LOD array
  24215. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24216. * @param mesh defines the mesh to be removed
  24217. * @return This mesh (for chaining)
  24218. */
  24219. removeLODLevel(mesh: Mesh): Mesh;
  24220. /**
  24221. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24222. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24223. * @param camera defines the camera to use to compute distance
  24224. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24225. * @return This mesh (for chaining)
  24226. */
  24227. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24228. /**
  24229. * Gets the mesh internal Geometry object
  24230. */
  24231. get geometry(): Nullable<Geometry>;
  24232. /**
  24233. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24234. * @returns the total number of vertices
  24235. */
  24236. getTotalVertices(): number;
  24237. /**
  24238. * Returns the content of an associated vertex buffer
  24239. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24240. * - VertexBuffer.PositionKind
  24241. * - VertexBuffer.UVKind
  24242. * - VertexBuffer.UV2Kind
  24243. * - VertexBuffer.UV3Kind
  24244. * - VertexBuffer.UV4Kind
  24245. * - VertexBuffer.UV5Kind
  24246. * - VertexBuffer.UV6Kind
  24247. * - VertexBuffer.ColorKind
  24248. * - VertexBuffer.MatricesIndicesKind
  24249. * - VertexBuffer.MatricesIndicesExtraKind
  24250. * - VertexBuffer.MatricesWeightsKind
  24251. * - VertexBuffer.MatricesWeightsExtraKind
  24252. * @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
  24253. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24254. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24255. */
  24256. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24257. /**
  24258. * Returns the mesh VertexBuffer object from the requested `kind`
  24259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24260. * - VertexBuffer.PositionKind
  24261. * - VertexBuffer.NormalKind
  24262. * - VertexBuffer.UVKind
  24263. * - VertexBuffer.UV2Kind
  24264. * - VertexBuffer.UV3Kind
  24265. * - VertexBuffer.UV4Kind
  24266. * - VertexBuffer.UV5Kind
  24267. * - VertexBuffer.UV6Kind
  24268. * - VertexBuffer.ColorKind
  24269. * - VertexBuffer.MatricesIndicesKind
  24270. * - VertexBuffer.MatricesIndicesExtraKind
  24271. * - VertexBuffer.MatricesWeightsKind
  24272. * - VertexBuffer.MatricesWeightsExtraKind
  24273. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24274. */
  24275. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24276. /**
  24277. * Tests if a specific vertex buffer is associated with this mesh
  24278. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24279. * - VertexBuffer.PositionKind
  24280. * - VertexBuffer.NormalKind
  24281. * - VertexBuffer.UVKind
  24282. * - VertexBuffer.UV2Kind
  24283. * - VertexBuffer.UV3Kind
  24284. * - VertexBuffer.UV4Kind
  24285. * - VertexBuffer.UV5Kind
  24286. * - VertexBuffer.UV6Kind
  24287. * - VertexBuffer.ColorKind
  24288. * - VertexBuffer.MatricesIndicesKind
  24289. * - VertexBuffer.MatricesIndicesExtraKind
  24290. * - VertexBuffer.MatricesWeightsKind
  24291. * - VertexBuffer.MatricesWeightsExtraKind
  24292. * @returns a boolean
  24293. */
  24294. isVerticesDataPresent(kind: string): boolean;
  24295. /**
  24296. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24297. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24298. * - VertexBuffer.PositionKind
  24299. * - VertexBuffer.UVKind
  24300. * - VertexBuffer.UV2Kind
  24301. * - VertexBuffer.UV3Kind
  24302. * - VertexBuffer.UV4Kind
  24303. * - VertexBuffer.UV5Kind
  24304. * - VertexBuffer.UV6Kind
  24305. * - VertexBuffer.ColorKind
  24306. * - VertexBuffer.MatricesIndicesKind
  24307. * - VertexBuffer.MatricesIndicesExtraKind
  24308. * - VertexBuffer.MatricesWeightsKind
  24309. * - VertexBuffer.MatricesWeightsExtraKind
  24310. * @returns a boolean
  24311. */
  24312. isVertexBufferUpdatable(kind: string): boolean;
  24313. /**
  24314. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24315. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24316. * - VertexBuffer.PositionKind
  24317. * - VertexBuffer.NormalKind
  24318. * - VertexBuffer.UVKind
  24319. * - VertexBuffer.UV2Kind
  24320. * - VertexBuffer.UV3Kind
  24321. * - VertexBuffer.UV4Kind
  24322. * - VertexBuffer.UV5Kind
  24323. * - VertexBuffer.UV6Kind
  24324. * - VertexBuffer.ColorKind
  24325. * - VertexBuffer.MatricesIndicesKind
  24326. * - VertexBuffer.MatricesIndicesExtraKind
  24327. * - VertexBuffer.MatricesWeightsKind
  24328. * - VertexBuffer.MatricesWeightsExtraKind
  24329. * @returns an array of strings
  24330. */
  24331. getVerticesDataKinds(): string[];
  24332. /**
  24333. * Returns a positive integer : the total number of indices in this mesh geometry.
  24334. * @returns the numner of indices or zero if the mesh has no geometry.
  24335. */
  24336. getTotalIndices(): number;
  24337. /**
  24338. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24339. * @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.
  24340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24341. * @returns the indices array or an empty array if the mesh has no geometry
  24342. */
  24343. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24344. get isBlocked(): boolean;
  24345. /**
  24346. * Determine if the current mesh is ready to be rendered
  24347. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24348. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24349. * @returns true if all associated assets are ready (material, textures, shaders)
  24350. */
  24351. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24352. /**
  24353. * 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.
  24354. */
  24355. get areNormalsFrozen(): boolean;
  24356. /**
  24357. * 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.
  24358. * @returns the current mesh
  24359. */
  24360. freezeNormals(): Mesh;
  24361. /**
  24362. * 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
  24363. * @returns the current mesh
  24364. */
  24365. unfreezeNormals(): Mesh;
  24366. /**
  24367. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24368. */
  24369. set overridenInstanceCount(count: number);
  24370. /** @hidden */
  24371. _preActivate(): Mesh;
  24372. /** @hidden */
  24373. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24374. /** @hidden */
  24375. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24376. /**
  24377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24378. * This means the mesh underlying bounding box and sphere are recomputed.
  24379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24380. * @returns the current mesh
  24381. */
  24382. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24383. /** @hidden */
  24384. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24385. /**
  24386. * This function will subdivide the mesh into multiple submeshes
  24387. * @param count defines the expected number of submeshes
  24388. */
  24389. subdivide(count: number): void;
  24390. /**
  24391. * Copy a FloatArray into a specific associated vertex buffer
  24392. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24393. * - VertexBuffer.PositionKind
  24394. * - VertexBuffer.UVKind
  24395. * - VertexBuffer.UV2Kind
  24396. * - VertexBuffer.UV3Kind
  24397. * - VertexBuffer.UV4Kind
  24398. * - VertexBuffer.UV5Kind
  24399. * - VertexBuffer.UV6Kind
  24400. * - VertexBuffer.ColorKind
  24401. * - VertexBuffer.MatricesIndicesKind
  24402. * - VertexBuffer.MatricesIndicesExtraKind
  24403. * - VertexBuffer.MatricesWeightsKind
  24404. * - VertexBuffer.MatricesWeightsExtraKind
  24405. * @param data defines the data source
  24406. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24407. * @param stride defines the data stride size (can be null)
  24408. * @returns the current mesh
  24409. */
  24410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24411. /**
  24412. * Delete a vertex buffer associated with this mesh
  24413. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24414. * - VertexBuffer.PositionKind
  24415. * - VertexBuffer.UVKind
  24416. * - VertexBuffer.UV2Kind
  24417. * - VertexBuffer.UV3Kind
  24418. * - VertexBuffer.UV4Kind
  24419. * - VertexBuffer.UV5Kind
  24420. * - VertexBuffer.UV6Kind
  24421. * - VertexBuffer.ColorKind
  24422. * - VertexBuffer.MatricesIndicesKind
  24423. * - VertexBuffer.MatricesIndicesExtraKind
  24424. * - VertexBuffer.MatricesWeightsKind
  24425. * - VertexBuffer.MatricesWeightsExtraKind
  24426. */
  24427. removeVerticesData(kind: string): void;
  24428. /**
  24429. * Flags an associated vertex buffer as updatable
  24430. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24431. * - VertexBuffer.PositionKind
  24432. * - VertexBuffer.UVKind
  24433. * - VertexBuffer.UV2Kind
  24434. * - VertexBuffer.UV3Kind
  24435. * - VertexBuffer.UV4Kind
  24436. * - VertexBuffer.UV5Kind
  24437. * - VertexBuffer.UV6Kind
  24438. * - VertexBuffer.ColorKind
  24439. * - VertexBuffer.MatricesIndicesKind
  24440. * - VertexBuffer.MatricesIndicesExtraKind
  24441. * - VertexBuffer.MatricesWeightsKind
  24442. * - VertexBuffer.MatricesWeightsExtraKind
  24443. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24444. */
  24445. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24446. /**
  24447. * Sets the mesh global Vertex Buffer
  24448. * @param buffer defines the buffer to use
  24449. * @returns the current mesh
  24450. */
  24451. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24452. /**
  24453. * Update a specific associated vertex buffer
  24454. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24455. * - VertexBuffer.PositionKind
  24456. * - VertexBuffer.UVKind
  24457. * - VertexBuffer.UV2Kind
  24458. * - VertexBuffer.UV3Kind
  24459. * - VertexBuffer.UV4Kind
  24460. * - VertexBuffer.UV5Kind
  24461. * - VertexBuffer.UV6Kind
  24462. * - VertexBuffer.ColorKind
  24463. * - VertexBuffer.MatricesIndicesKind
  24464. * - VertexBuffer.MatricesIndicesExtraKind
  24465. * - VertexBuffer.MatricesWeightsKind
  24466. * - VertexBuffer.MatricesWeightsExtraKind
  24467. * @param data defines the data source
  24468. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24469. * @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)
  24470. * @returns the current mesh
  24471. */
  24472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24473. /**
  24474. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24475. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24476. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24477. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24478. * @returns the current mesh
  24479. */
  24480. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24481. /**
  24482. * Creates a un-shared specific occurence of the geometry for the mesh.
  24483. * @returns the current mesh
  24484. */
  24485. makeGeometryUnique(): Mesh;
  24486. /**
  24487. * Set the index buffer of this mesh
  24488. * @param indices defines the source data
  24489. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24490. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24491. * @returns the current mesh
  24492. */
  24493. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24494. /**
  24495. * Update the current index buffer
  24496. * @param indices defines the source data
  24497. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24498. * @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)
  24499. * @returns the current mesh
  24500. */
  24501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24502. /**
  24503. * Invert the geometry to move from a right handed system to a left handed one.
  24504. * @returns the current mesh
  24505. */
  24506. toLeftHanded(): Mesh;
  24507. /** @hidden */
  24508. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24509. /** @hidden */
  24510. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24511. /**
  24512. * Registers for this mesh a javascript function called just before the rendering process
  24513. * @param func defines the function to call before rendering this mesh
  24514. * @returns the current mesh
  24515. */
  24516. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24517. /**
  24518. * Disposes a previously registered javascript function called before the rendering
  24519. * @param func defines the function to remove
  24520. * @returns the current mesh
  24521. */
  24522. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24523. /**
  24524. * Registers for this mesh a javascript function called just after the rendering is complete
  24525. * @param func defines the function to call after rendering this mesh
  24526. * @returns the current mesh
  24527. */
  24528. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24529. /**
  24530. * Disposes a previously registered javascript function called after the rendering.
  24531. * @param func defines the function to remove
  24532. * @returns the current mesh
  24533. */
  24534. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24535. /** @hidden */
  24536. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24537. /** @hidden */
  24538. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24539. /** @hidden */
  24540. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24541. /** @hidden */
  24542. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24543. /** @hidden */
  24544. _rebuild(): void;
  24545. /** @hidden */
  24546. _freeze(): void;
  24547. /** @hidden */
  24548. _unFreeze(): void;
  24549. /**
  24550. * 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
  24551. * @param subMesh defines the subMesh to render
  24552. * @param enableAlphaMode defines if alpha mode can be changed
  24553. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24554. * @returns the current mesh
  24555. */
  24556. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24557. private _onBeforeDraw;
  24558. /**
  24559. * Renormalize the mesh and patch it up if there are no weights
  24560. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24561. * However in the case of zero weights then we set just a single influence to 1.
  24562. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24563. */
  24564. cleanMatrixWeights(): void;
  24565. private normalizeSkinFourWeights;
  24566. private normalizeSkinWeightsAndExtra;
  24567. /**
  24568. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24569. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24570. * the user know there was an issue with importing the mesh
  24571. * @returns a validation object with skinned, valid and report string
  24572. */
  24573. validateSkinning(): {
  24574. skinned: boolean;
  24575. valid: boolean;
  24576. report: string;
  24577. };
  24578. /** @hidden */
  24579. _checkDelayState(): Mesh;
  24580. private _queueLoad;
  24581. /**
  24582. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24583. * A mesh is in the frustum if its bounding box intersects the frustum
  24584. * @param frustumPlanes defines the frustum to test
  24585. * @returns true if the mesh is in the frustum planes
  24586. */
  24587. isInFrustum(frustumPlanes: Plane[]): boolean;
  24588. /**
  24589. * Sets the mesh material by the material or multiMaterial `id` property
  24590. * @param id is a string identifying the material or the multiMaterial
  24591. * @returns the current mesh
  24592. */
  24593. setMaterialByID(id: string): Mesh;
  24594. /**
  24595. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24596. * @returns an array of IAnimatable
  24597. */
  24598. getAnimatables(): IAnimatable[];
  24599. /**
  24600. * Modifies the mesh geometry according to the passed transformation matrix.
  24601. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24602. * The mesh normals are modified using the same transformation.
  24603. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24604. * @param transform defines the transform matrix to use
  24605. * @see http://doc.babylonjs.com/resources/baking_transformations
  24606. * @returns the current mesh
  24607. */
  24608. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24609. /**
  24610. * Modifies the mesh geometry according to its own current World Matrix.
  24611. * The mesh World Matrix is then reset.
  24612. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24613. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24614. * @see http://doc.babylonjs.com/resources/baking_transformations
  24615. * @returns the current mesh
  24616. */
  24617. bakeCurrentTransformIntoVertices(): Mesh;
  24618. /** @hidden */
  24619. get _positions(): Nullable<Vector3[]>;
  24620. /** @hidden */
  24621. _resetPointsArrayCache(): Mesh;
  24622. /** @hidden */
  24623. _generatePointsArray(): boolean;
  24624. /**
  24625. * Returns a new Mesh object generated from the current mesh properties.
  24626. * This method must not get confused with createInstance()
  24627. * @param name is a string, the name given to the new mesh
  24628. * @param newParent can be any Node object (default `null`)
  24629. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24630. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24631. * @returns a new mesh
  24632. */
  24633. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24634. /**
  24635. * Releases resources associated with this mesh.
  24636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24638. */
  24639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24640. /** @hidden */
  24641. _disposeInstanceSpecificData(): void;
  24642. /**
  24643. * Modifies the mesh geometry according to a displacement map.
  24644. * 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.
  24645. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24646. * @param url is a string, the URL from the image file is to be downloaded.
  24647. * @param minHeight is the lower limit of the displacement.
  24648. * @param maxHeight is the upper limit of the displacement.
  24649. * @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.
  24650. * @param uvOffset is an optional vector2 used to offset UV.
  24651. * @param uvScale is an optional vector2 used to scale UV.
  24652. * @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.
  24653. * @returns the Mesh.
  24654. */
  24655. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24656. /**
  24657. * Modifies the mesh geometry according to a displacementMap buffer.
  24658. * 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.
  24659. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24660. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24661. * @param heightMapWidth is the width of the buffer image.
  24662. * @param heightMapHeight is the height of the buffer image.
  24663. * @param minHeight is the lower limit of the displacement.
  24664. * @param maxHeight is the upper limit of the displacement.
  24665. * @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.
  24666. * @param uvOffset is an optional vector2 used to offset UV.
  24667. * @param uvScale is an optional vector2 used to scale UV.
  24668. * @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.
  24669. * @returns the Mesh.
  24670. */
  24671. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24672. /**
  24673. * Modify the mesh to get a flat shading rendering.
  24674. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24675. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24676. * @returns current mesh
  24677. */
  24678. convertToFlatShadedMesh(): Mesh;
  24679. /**
  24680. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24681. * In other words, more vertices, no more indices and a single bigger VBO.
  24682. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24683. * @returns current mesh
  24684. */
  24685. convertToUnIndexedMesh(): Mesh;
  24686. /**
  24687. * Inverses facet orientations.
  24688. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24689. * @param flipNormals will also inverts the normals
  24690. * @returns current mesh
  24691. */
  24692. flipFaces(flipNormals?: boolean): Mesh;
  24693. /**
  24694. * Increase the number of facets and hence vertices in a mesh
  24695. * Vertex normals are interpolated from existing vertex normals
  24696. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24697. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24698. */
  24699. increaseVertices(numberPerEdge: number): void;
  24700. /**
  24701. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24702. * This will undo any application of covertToFlatShadedMesh
  24703. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24704. */
  24705. forceSharedVertices(): void;
  24706. /** @hidden */
  24707. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24708. /** @hidden */
  24709. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24710. /**
  24711. * Creates a new InstancedMesh object from the mesh model.
  24712. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24713. * @param name defines the name of the new instance
  24714. * @returns a new InstancedMesh
  24715. */
  24716. createInstance(name: string): InstancedMesh;
  24717. /**
  24718. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24719. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24720. * @returns the current mesh
  24721. */
  24722. synchronizeInstances(): Mesh;
  24723. /**
  24724. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24725. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24726. * This should be used together with the simplification to avoid disappearing triangles.
  24727. * @param successCallback an optional success callback to be called after the optimization finished.
  24728. * @returns the current mesh
  24729. */
  24730. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24731. /**
  24732. * Serialize current mesh
  24733. * @param serializationObject defines the object which will receive the serialization data
  24734. */
  24735. serialize(serializationObject: any): void;
  24736. /** @hidden */
  24737. _syncGeometryWithMorphTargetManager(): void;
  24738. /** @hidden */
  24739. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24740. /**
  24741. * Returns a new Mesh object parsed from the source provided.
  24742. * @param parsedMesh is the source
  24743. * @param scene defines the hosting scene
  24744. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24745. * @returns a new Mesh
  24746. */
  24747. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24748. /**
  24749. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24750. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24751. * @param name defines the name of the mesh to create
  24752. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24753. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24754. * @param closePath creates a seam between the first and the last points of each path of the path array
  24755. * @param offset is taken in account only if the `pathArray` is containing a single path
  24756. * @param scene defines the hosting scene
  24757. * @param updatable defines if the mesh must be flagged as updatable
  24758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24759. * @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)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24763. /**
  24764. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24765. * @param name defines the name of the mesh to create
  24766. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24767. * @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
  24768. * @param scene defines the hosting scene
  24769. * @param updatable defines if the mesh must be flagged as updatable
  24770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24771. * @returns a new Mesh
  24772. */
  24773. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24774. /**
  24775. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24776. * @param name defines the name of the mesh to create
  24777. * @param size sets the size (float) of each box side (default 1)
  24778. * @param scene defines the hosting scene
  24779. * @param updatable defines if the mesh must be flagged as updatable
  24780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24781. * @returns a new Mesh
  24782. */
  24783. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24784. /**
  24785. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24786. * @param name defines the name of the mesh to create
  24787. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24788. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24789. * @param scene defines the hosting scene
  24790. * @param updatable defines if the mesh must be flagged as updatable
  24791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24792. * @returns a new Mesh
  24793. */
  24794. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24795. /**
  24796. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24797. * @param name defines the name of the mesh to create
  24798. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24799. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24800. * @param scene defines the hosting scene
  24801. * @returns a new Mesh
  24802. */
  24803. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24804. /**
  24805. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24806. * @param name defines the name of the mesh to create
  24807. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24808. * @param diameterTop set the top cap diameter (floats, default 1)
  24809. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24810. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24811. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24812. * @param scene defines the hosting scene
  24813. * @param updatable defines if the mesh must be flagged as updatable
  24814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24815. * @returns a new Mesh
  24816. */
  24817. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24818. /**
  24819. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24820. * @param name defines the name of the mesh to create
  24821. * @param diameter sets the diameter size (float) of the torus (default 1)
  24822. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24823. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24824. * @param scene defines the hosting scene
  24825. * @param updatable defines if the mesh must be flagged as updatable
  24826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24827. * @returns a new Mesh
  24828. */
  24829. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24830. /**
  24831. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24832. * @param name defines the name of the mesh to create
  24833. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24834. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24835. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24836. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24837. * @param p the number of windings on X axis (positive integers, default 2)
  24838. * @param q the number of windings on Y axis (positive integers, default 3)
  24839. * @param scene defines the hosting scene
  24840. * @param updatable defines if the mesh must be flagged as updatable
  24841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24842. * @returns a new Mesh
  24843. */
  24844. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24845. /**
  24846. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24847. * @param name defines the name of the mesh to create
  24848. * @param points is an array successive Vector3
  24849. * @param scene defines the hosting scene
  24850. * @param updatable defines if the mesh must be flagged as updatable
  24851. * @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).
  24852. * @returns a new Mesh
  24853. */
  24854. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24855. /**
  24856. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24857. * @param name defines the name of the mesh to create
  24858. * @param points is an array successive Vector3
  24859. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24860. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24861. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24862. * @param scene defines the hosting scene
  24863. * @param updatable defines if the mesh must be flagged as updatable
  24864. * @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)
  24865. * @returns a new Mesh
  24866. */
  24867. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24868. /**
  24869. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24870. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24871. * 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.
  24872. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24873. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24874. * Remember you can only change the shape positions, not their number when updating a polygon.
  24875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24876. * @param name defines the name of the mesh to create
  24877. * @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
  24878. * @param scene defines the hosting scene
  24879. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @param earcutInjection can be used to inject your own earcut reference
  24883. * @returns a new Mesh
  24884. */
  24885. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24886. /**
  24887. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24888. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24889. * @param name defines the name of the mesh to create
  24890. * @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
  24891. * @param depth defines the height of extrusion
  24892. * @param scene defines the hosting scene
  24893. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24894. * @param updatable defines if the mesh must be flagged as updatable
  24895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24896. * @param earcutInjection can be used to inject your own earcut reference
  24897. * @returns a new Mesh
  24898. */
  24899. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24900. /**
  24901. * Creates an extruded shape mesh.
  24902. * 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
  24903. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24904. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24905. * @param name defines the name of the mesh to create
  24906. * @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
  24907. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24908. * @param scale is the value to scale the shape
  24909. * @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
  24910. * @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
  24911. * @param scene defines the hosting scene
  24912. * @param updatable defines if the mesh must be flagged as updatable
  24913. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24914. * @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)
  24915. * @returns a new Mesh
  24916. */
  24917. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24918. /**
  24919. * Creates an custom extruded shape mesh.
  24920. * The custom extrusion is a parametric shape.
  24921. * It has no predefined shape. Its final shape will depend on the input parameters.
  24922. * Please consider using the same method from the MeshBuilder class instead
  24923. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24924. * @param name defines the name of the mesh to create
  24925. * @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
  24926. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24927. * @param scaleFunction is a custom Javascript function called on each path point
  24928. * @param rotationFunction is a custom Javascript function called on each path point
  24929. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24930. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24931. * @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
  24932. * @param scene defines the hosting scene
  24933. * @param updatable defines if the mesh must be flagged as updatable
  24934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24935. * @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)
  24936. * @returns a new Mesh
  24937. */
  24938. 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;
  24939. /**
  24940. * Creates lathe mesh.
  24941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24942. * Please consider using the same method from the MeshBuilder class instead
  24943. * @param name defines the name of the mesh to create
  24944. * @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
  24945. * @param radius is the radius value of the lathe
  24946. * @param tessellation is the side number of the lathe.
  24947. * @param scene defines the hosting scene
  24948. * @param updatable defines if the mesh must be flagged as updatable
  24949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24950. * @returns a new Mesh
  24951. */
  24952. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24953. /**
  24954. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24955. * @param name defines the name of the mesh to create
  24956. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24957. * @param scene defines the hosting scene
  24958. * @param updatable defines if the mesh must be flagged as updatable
  24959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24963. /**
  24964. * Creates a ground mesh.
  24965. * Please consider using the same method from the MeshBuilder class instead
  24966. * @param name defines the name of the mesh to create
  24967. * @param width set the width of the ground
  24968. * @param height set the height of the ground
  24969. * @param subdivisions sets the number of subdivisions per side
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @returns a new Mesh
  24973. */
  24974. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24975. /**
  24976. * Creates a tiled ground mesh.
  24977. * Please consider using the same method from the MeshBuilder class instead
  24978. * @param name defines the name of the mesh to create
  24979. * @param xmin set the ground minimum X coordinate
  24980. * @param zmin set the ground minimum Y coordinate
  24981. * @param xmax set the ground maximum X coordinate
  24982. * @param zmax set the ground maximum Z coordinate
  24983. * @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
  24984. * @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
  24985. * @param scene defines the hosting scene
  24986. * @param updatable defines if the mesh must be flagged as updatable
  24987. * @returns a new Mesh
  24988. */
  24989. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24990. w: number;
  24991. h: number;
  24992. }, precision: {
  24993. w: number;
  24994. h: number;
  24995. }, scene: Scene, updatable?: boolean): Mesh;
  24996. /**
  24997. * Creates a ground mesh from a height map.
  24998. * Please consider using the same method from the MeshBuilder class instead
  24999. * @see http://doc.babylonjs.com/babylon101/height_map
  25000. * @param name defines the name of the mesh to create
  25001. * @param url sets the URL of the height map image resource
  25002. * @param width set the ground width size
  25003. * @param height set the ground height size
  25004. * @param subdivisions sets the number of subdivision per side
  25005. * @param minHeight is the minimum altitude on the ground
  25006. * @param maxHeight is the maximum altitude on the ground
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25010. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25011. * @returns a new Mesh
  25012. */
  25013. 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;
  25014. /**
  25015. * Creates a tube mesh.
  25016. * The tube is a parametric shape.
  25017. * It has no predefined shape. Its final shape will depend on the input parameters.
  25018. * Please consider using the same method from the MeshBuilder class instead
  25019. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25020. * @param name defines the name of the mesh to create
  25021. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25022. * @param radius sets the tube radius size
  25023. * @param tessellation is the number of sides on the tubular surface
  25024. * @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
  25025. * @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
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @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)
  25030. * @returns a new Mesh
  25031. */
  25032. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25033. (i: number, distance: number): number;
  25034. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates a polyhedron mesh.
  25037. * Please consider using the same method from the MeshBuilder class instead.
  25038. * * 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
  25039. * * The parameter `size` (positive float, default 1) sets the polygon size
  25040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25041. * * 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`
  25042. * * 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
  25043. * * 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)`)
  25044. * * 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
  25045. * * 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
  25046. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25047. * * 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
  25048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25049. * @param name defines the name of the mesh to create
  25050. * @param options defines the options used to create the mesh
  25051. * @param scene defines the hosting scene
  25052. * @returns a new Mesh
  25053. */
  25054. static CreatePolyhedron(name: string, options: {
  25055. type?: number;
  25056. size?: number;
  25057. sizeX?: number;
  25058. sizeY?: number;
  25059. sizeZ?: number;
  25060. custom?: any;
  25061. faceUV?: Vector4[];
  25062. faceColors?: Color4[];
  25063. updatable?: boolean;
  25064. sideOrientation?: number;
  25065. }, scene: Scene): Mesh;
  25066. /**
  25067. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25068. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25069. * * 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`)
  25070. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25071. * * 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
  25072. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25073. * * 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
  25074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25075. * @param name defines the name of the mesh
  25076. * @param options defines the options used to create the mesh
  25077. * @param scene defines the hosting scene
  25078. * @returns a new Mesh
  25079. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25080. */
  25081. static CreateIcoSphere(name: string, options: {
  25082. radius?: number;
  25083. flat?: boolean;
  25084. subdivisions?: number;
  25085. sideOrientation?: number;
  25086. updatable?: boolean;
  25087. }, scene: Scene): Mesh;
  25088. /**
  25089. * Creates a decal mesh.
  25090. * Please consider using the same method from the MeshBuilder class instead.
  25091. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25092. * @param name defines the name of the mesh
  25093. * @param sourceMesh defines the mesh receiving the decal
  25094. * @param position sets the position of the decal in world coordinates
  25095. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25096. * @param size sets the decal scaling
  25097. * @param angle sets the angle to rotate the decal
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25101. /**
  25102. * Prepare internal position array for software CPU skinning
  25103. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25104. */
  25105. setPositionsForCPUSkinning(): Float32Array;
  25106. /**
  25107. * Prepare internal normal array for software CPU skinning
  25108. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25109. */
  25110. setNormalsForCPUSkinning(): Float32Array;
  25111. /**
  25112. * Updates the vertex buffer by applying transformation from the bones
  25113. * @param skeleton defines the skeleton to apply to current mesh
  25114. * @returns the current mesh
  25115. */
  25116. applySkeleton(skeleton: Skeleton): Mesh;
  25117. /**
  25118. * 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
  25119. * @param meshes defines the list of meshes to scan
  25120. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25121. */
  25122. static MinMax(meshes: AbstractMesh[]): {
  25123. min: Vector3;
  25124. max: Vector3;
  25125. };
  25126. /**
  25127. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25128. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25129. * @returns a vector3
  25130. */
  25131. static Center(meshesOrMinMaxVector: {
  25132. min: Vector3;
  25133. max: Vector3;
  25134. } | AbstractMesh[]): Vector3;
  25135. /**
  25136. * Merge the array of meshes into a single mesh for performance reasons.
  25137. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25138. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25139. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25140. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25141. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25142. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25143. * @returns a new mesh
  25144. */
  25145. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25146. /** @hidden */
  25147. addInstance(instance: InstancedMesh): void;
  25148. /** @hidden */
  25149. removeInstance(instance: InstancedMesh): void;
  25150. }
  25151. }
  25152. declare module BABYLON {
  25153. /**
  25154. * This is the base class of all the camera used in the application.
  25155. * @see http://doc.babylonjs.com/features/cameras
  25156. */
  25157. export class Camera extends Node {
  25158. /** @hidden */
  25159. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25160. /**
  25161. * This is the default projection mode used by the cameras.
  25162. * It helps recreating a feeling of perspective and better appreciate depth.
  25163. * This is the best way to simulate real life cameras.
  25164. */
  25165. static readonly PERSPECTIVE_CAMERA: number;
  25166. /**
  25167. * This helps creating camera with an orthographic mode.
  25168. * 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.
  25169. */
  25170. static readonly ORTHOGRAPHIC_CAMERA: number;
  25171. /**
  25172. * This is the default FOV mode for perspective cameras.
  25173. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25174. */
  25175. static readonly FOVMODE_VERTICAL_FIXED: number;
  25176. /**
  25177. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25178. */
  25179. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25180. /**
  25181. * This specifies ther is no need for a camera rig.
  25182. * Basically only one eye is rendered corresponding to the camera.
  25183. */
  25184. static readonly RIG_MODE_NONE: number;
  25185. /**
  25186. * Simulates a camera Rig with one blue eye and one red eye.
  25187. * This can be use with 3d blue and red glasses.
  25188. */
  25189. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25190. /**
  25191. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25192. */
  25193. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25194. /**
  25195. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25196. */
  25197. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25198. /**
  25199. * Defines that both eyes of the camera will be rendered over under each other.
  25200. */
  25201. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25202. /**
  25203. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25204. */
  25205. static readonly RIG_MODE_VR: number;
  25206. /**
  25207. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25208. */
  25209. static readonly RIG_MODE_WEBVR: number;
  25210. /**
  25211. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25212. */
  25213. static readonly RIG_MODE_CUSTOM: number;
  25214. /**
  25215. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25216. */
  25217. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25218. /**
  25219. * Define the input manager associated with the camera.
  25220. */
  25221. inputs: CameraInputsManager<Camera>;
  25222. /** @hidden */
  25223. _position: Vector3;
  25224. /**
  25225. * Define the current local position of the camera in the scene
  25226. */
  25227. get position(): Vector3;
  25228. set position(newPosition: Vector3);
  25229. /**
  25230. * The vector the camera should consider as up.
  25231. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25232. */
  25233. upVector: Vector3;
  25234. /**
  25235. * Define the current limit on the left side for an orthographic camera
  25236. * In scene unit
  25237. */
  25238. orthoLeft: Nullable<number>;
  25239. /**
  25240. * Define the current limit on the right side for an orthographic camera
  25241. * In scene unit
  25242. */
  25243. orthoRight: Nullable<number>;
  25244. /**
  25245. * Define the current limit on the bottom side for an orthographic camera
  25246. * In scene unit
  25247. */
  25248. orthoBottom: Nullable<number>;
  25249. /**
  25250. * Define the current limit on the top side for an orthographic camera
  25251. * In scene unit
  25252. */
  25253. orthoTop: Nullable<number>;
  25254. /**
  25255. * Field Of View is set in Radians. (default is 0.8)
  25256. */
  25257. fov: number;
  25258. /**
  25259. * Define the minimum distance the camera can see from.
  25260. * This is important to note that the depth buffer are not infinite and the closer it starts
  25261. * the more your scene might encounter depth fighting issue.
  25262. */
  25263. minZ: number;
  25264. /**
  25265. * Define the maximum distance the camera can see to.
  25266. * This is important to note that the depth buffer are not infinite and the further it end
  25267. * the more your scene might encounter depth fighting issue.
  25268. */
  25269. maxZ: number;
  25270. /**
  25271. * Define the default inertia of the camera.
  25272. * This helps giving a smooth feeling to the camera movement.
  25273. */
  25274. inertia: number;
  25275. /**
  25276. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25277. */
  25278. mode: number;
  25279. /**
  25280. * Define wether the camera is intermediate.
  25281. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25282. */
  25283. isIntermediate: boolean;
  25284. /**
  25285. * Define the viewport of the camera.
  25286. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25287. */
  25288. viewport: Viewport;
  25289. /**
  25290. * Restricts the camera to viewing objects with the same layerMask.
  25291. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25292. */
  25293. layerMask: number;
  25294. /**
  25295. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25296. */
  25297. fovMode: number;
  25298. /**
  25299. * Rig mode of the camera.
  25300. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25301. * This is normally controlled byt the camera themselves as internal use.
  25302. */
  25303. cameraRigMode: number;
  25304. /**
  25305. * Defines the distance between both "eyes" in case of a RIG
  25306. */
  25307. interaxialDistance: number;
  25308. /**
  25309. * Defines if stereoscopic rendering is done side by side or over under.
  25310. */
  25311. isStereoscopicSideBySide: boolean;
  25312. /**
  25313. * 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
  25314. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25315. * else in the scene. (Eg. security camera)
  25316. *
  25317. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25318. */
  25319. customRenderTargets: RenderTargetTexture[];
  25320. /**
  25321. * When set, the camera will render to this render target instead of the default canvas
  25322. *
  25323. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25324. */
  25325. outputRenderTarget: Nullable<RenderTargetTexture>;
  25326. /**
  25327. * Observable triggered when the camera view matrix has changed.
  25328. */
  25329. onViewMatrixChangedObservable: Observable<Camera>;
  25330. /**
  25331. * Observable triggered when the camera Projection matrix has changed.
  25332. */
  25333. onProjectionMatrixChangedObservable: Observable<Camera>;
  25334. /**
  25335. * Observable triggered when the inputs have been processed.
  25336. */
  25337. onAfterCheckInputsObservable: Observable<Camera>;
  25338. /**
  25339. * Observable triggered when reset has been called and applied to the camera.
  25340. */
  25341. onRestoreStateObservable: Observable<Camera>;
  25342. /** @hidden */
  25343. _cameraRigParams: any;
  25344. /** @hidden */
  25345. _rigCameras: Camera[];
  25346. /** @hidden */
  25347. _rigPostProcess: Nullable<PostProcess>;
  25348. protected _webvrViewMatrix: Matrix;
  25349. /** @hidden */
  25350. _skipRendering: boolean;
  25351. /** @hidden */
  25352. _projectionMatrix: Matrix;
  25353. /** @hidden */
  25354. _postProcesses: Nullable<PostProcess>[];
  25355. /** @hidden */
  25356. _activeMeshes: SmartArray<AbstractMesh>;
  25357. protected _globalPosition: Vector3;
  25358. /** @hidden */
  25359. _computedViewMatrix: Matrix;
  25360. private _doNotComputeProjectionMatrix;
  25361. private _transformMatrix;
  25362. private _frustumPlanes;
  25363. private _refreshFrustumPlanes;
  25364. private _storedFov;
  25365. private _stateStored;
  25366. /**
  25367. * Instantiates a new camera object.
  25368. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. * @param name Defines the name of the camera in the scene
  25371. * @param position Defines the position of the camera
  25372. * @param scene Defines the scene the camera belongs too
  25373. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25374. */
  25375. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25376. /**
  25377. * Store current camera state (fov, position, etc..)
  25378. * @returns the camera
  25379. */
  25380. storeState(): Camera;
  25381. /**
  25382. * Restores the camera state values if it has been stored. You must call storeState() first
  25383. */
  25384. protected _restoreStateValues(): boolean;
  25385. /**
  25386. * Restored camera state. You must call storeState() first.
  25387. * @returns true if restored and false otherwise
  25388. */
  25389. restoreState(): boolean;
  25390. /**
  25391. * Gets the class name of the camera.
  25392. * @returns the class name
  25393. */
  25394. getClassName(): string;
  25395. /** @hidden */
  25396. readonly _isCamera: boolean;
  25397. /**
  25398. * Gets a string representation of the camera useful for debug purpose.
  25399. * @param fullDetails Defines that a more verboe level of logging is required
  25400. * @returns the string representation
  25401. */
  25402. toString(fullDetails?: boolean): string;
  25403. /**
  25404. * Gets the current world space position of the camera.
  25405. */
  25406. get globalPosition(): Vector3;
  25407. /**
  25408. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25409. * @returns the active meshe list
  25410. */
  25411. getActiveMeshes(): SmartArray<AbstractMesh>;
  25412. /**
  25413. * Check wether a mesh is part of the current active mesh list of the camera
  25414. * @param mesh Defines the mesh to check
  25415. * @returns true if active, false otherwise
  25416. */
  25417. isActiveMesh(mesh: Mesh): boolean;
  25418. /**
  25419. * Is this camera ready to be used/rendered
  25420. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25421. * @return true if the camera is ready
  25422. */
  25423. isReady(completeCheck?: boolean): boolean;
  25424. /** @hidden */
  25425. _initCache(): void;
  25426. /** @hidden */
  25427. _updateCache(ignoreParentClass?: boolean): void;
  25428. /** @hidden */
  25429. _isSynchronized(): boolean;
  25430. /** @hidden */
  25431. _isSynchronizedViewMatrix(): boolean;
  25432. /** @hidden */
  25433. _isSynchronizedProjectionMatrix(): boolean;
  25434. /**
  25435. * Attach the input controls to a specific dom element to get the input from.
  25436. * @param element Defines the element the controls should be listened from
  25437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25438. */
  25439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25440. /**
  25441. * Detach the current controls from the specified dom element.
  25442. * @param element Defines the element to stop listening the inputs from
  25443. */
  25444. detachControl(element: HTMLElement): void;
  25445. /**
  25446. * Update the camera state according to the different inputs gathered during the frame.
  25447. */
  25448. update(): void;
  25449. /** @hidden */
  25450. _checkInputs(): void;
  25451. /** @hidden */
  25452. get rigCameras(): Camera[];
  25453. /**
  25454. * Gets the post process used by the rig cameras
  25455. */
  25456. get rigPostProcess(): Nullable<PostProcess>;
  25457. /**
  25458. * Internal, gets the first post proces.
  25459. * @returns the first post process to be run on this camera.
  25460. */
  25461. _getFirstPostProcess(): Nullable<PostProcess>;
  25462. private _cascadePostProcessesToRigCams;
  25463. /**
  25464. * Attach a post process to the camera.
  25465. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25466. * @param postProcess The post process to attach to the camera
  25467. * @param insertAt The position of the post process in case several of them are in use in the scene
  25468. * @returns the position the post process has been inserted at
  25469. */
  25470. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25471. /**
  25472. * Detach a post process to the camera.
  25473. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25474. * @param postProcess The post process to detach from the camera
  25475. */
  25476. detachPostProcess(postProcess: PostProcess): void;
  25477. /**
  25478. * Gets the current world matrix of the camera
  25479. */
  25480. getWorldMatrix(): Matrix;
  25481. /** @hidden */
  25482. _getViewMatrix(): Matrix;
  25483. /**
  25484. * Gets the current view matrix of the camera.
  25485. * @param force forces the camera to recompute the matrix without looking at the cached state
  25486. * @returns the view matrix
  25487. */
  25488. getViewMatrix(force?: boolean): Matrix;
  25489. /**
  25490. * Freeze the projection matrix.
  25491. * It will prevent the cache check of the camera projection compute and can speed up perf
  25492. * if no parameter of the camera are meant to change
  25493. * @param projection Defines manually a projection if necessary
  25494. */
  25495. freezeProjectionMatrix(projection?: Matrix): void;
  25496. /**
  25497. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25498. */
  25499. unfreezeProjectionMatrix(): void;
  25500. /**
  25501. * Gets the current projection matrix of the camera.
  25502. * @param force forces the camera to recompute the matrix without looking at the cached state
  25503. * @returns the projection matrix
  25504. */
  25505. getProjectionMatrix(force?: boolean): Matrix;
  25506. /**
  25507. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25508. * @returns a Matrix
  25509. */
  25510. getTransformationMatrix(): Matrix;
  25511. private _updateFrustumPlanes;
  25512. /**
  25513. * Checks if a cullable object (mesh...) is in the camera frustum
  25514. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25515. * @param target The object to check
  25516. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25517. * @returns true if the object is in frustum otherwise false
  25518. */
  25519. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25520. /**
  25521. * Checks if a cullable object (mesh...) is in the camera frustum
  25522. * Unlike isInFrustum this cheks the full bounding box
  25523. * @param target The object to check
  25524. * @returns true if the object is in frustum otherwise false
  25525. */
  25526. isCompletelyInFrustum(target: ICullable): boolean;
  25527. /**
  25528. * Gets a ray in the forward direction from the camera.
  25529. * @param length Defines the length of the ray to create
  25530. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25531. * @param origin Defines the start point of the ray which defaults to the camera position
  25532. * @returns the forward ray
  25533. */
  25534. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25535. /**
  25536. * Releases resources associated with this node.
  25537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25539. */
  25540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25541. /** @hidden */
  25542. _isLeftCamera: boolean;
  25543. /**
  25544. * Gets the left camera of a rig setup in case of Rigged Camera
  25545. */
  25546. get isLeftCamera(): boolean;
  25547. /** @hidden */
  25548. _isRightCamera: boolean;
  25549. /**
  25550. * Gets the right camera of a rig setup in case of Rigged Camera
  25551. */
  25552. get isRightCamera(): boolean;
  25553. /**
  25554. * Gets the left camera of a rig setup in case of Rigged Camera
  25555. */
  25556. get leftCamera(): Nullable<FreeCamera>;
  25557. /**
  25558. * Gets the right camera of a rig setup in case of Rigged Camera
  25559. */
  25560. get rightCamera(): Nullable<FreeCamera>;
  25561. /**
  25562. * Gets the left camera target of a rig setup in case of Rigged Camera
  25563. * @returns the target position
  25564. */
  25565. getLeftTarget(): Nullable<Vector3>;
  25566. /**
  25567. * Gets the right camera target of a rig setup in case of Rigged Camera
  25568. * @returns the target position
  25569. */
  25570. getRightTarget(): Nullable<Vector3>;
  25571. /**
  25572. * @hidden
  25573. */
  25574. setCameraRigMode(mode: number, rigParams: any): void;
  25575. /** @hidden */
  25576. static _setStereoscopicRigMode(camera: Camera): void;
  25577. /** @hidden */
  25578. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25579. /** @hidden */
  25580. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25581. /** @hidden */
  25582. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25583. /** @hidden */
  25584. _getVRProjectionMatrix(): Matrix;
  25585. protected _updateCameraRotationMatrix(): void;
  25586. protected _updateWebVRCameraRotationMatrix(): void;
  25587. /**
  25588. * This function MUST be overwritten by the different WebVR cameras available.
  25589. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25590. * @hidden
  25591. */
  25592. _getWebVRProjectionMatrix(): Matrix;
  25593. /**
  25594. * This function MUST be overwritten by the different WebVR cameras available.
  25595. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25596. * @hidden
  25597. */
  25598. _getWebVRViewMatrix(): Matrix;
  25599. /** @hidden */
  25600. setCameraRigParameter(name: string, value: any): void;
  25601. /**
  25602. * needs to be overridden by children so sub has required properties to be copied
  25603. * @hidden
  25604. */
  25605. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25606. /**
  25607. * May need to be overridden by children
  25608. * @hidden
  25609. */
  25610. _updateRigCameras(): void;
  25611. /** @hidden */
  25612. _setupInputs(): void;
  25613. /**
  25614. * Serialiaze the camera setup to a json represention
  25615. * @returns the JSON representation
  25616. */
  25617. serialize(): any;
  25618. /**
  25619. * Clones the current camera.
  25620. * @param name The cloned camera name
  25621. * @returns the cloned camera
  25622. */
  25623. clone(name: string): Camera;
  25624. /**
  25625. * Gets the direction of the camera relative to a given local axis.
  25626. * @param localAxis Defines the reference axis to provide a relative direction.
  25627. * @return the direction
  25628. */
  25629. getDirection(localAxis: Vector3): Vector3;
  25630. /**
  25631. * Returns the current camera absolute rotation
  25632. */
  25633. get absoluteRotation(): Quaternion;
  25634. /**
  25635. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25636. * @param localAxis Defines the reference axis to provide a relative direction.
  25637. * @param result Defines the vector to store the result in
  25638. */
  25639. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25640. /**
  25641. * Gets a camera constructor for a given camera type
  25642. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25643. * @param name The name of the camera the result will be able to instantiate
  25644. * @param scene The scene the result will construct the camera in
  25645. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25646. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25647. * @returns a factory method to construc the camera
  25648. */
  25649. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25650. /**
  25651. * Compute the world matrix of the camera.
  25652. * @returns the camera world matrix
  25653. */
  25654. computeWorldMatrix(): Matrix;
  25655. /**
  25656. * Parse a JSON and creates the camera from the parsed information
  25657. * @param parsedCamera The JSON to parse
  25658. * @param scene The scene to instantiate the camera in
  25659. * @returns the newly constructed camera
  25660. */
  25661. static Parse(parsedCamera: any, scene: Scene): Camera;
  25662. }
  25663. }
  25664. declare module BABYLON {
  25665. /**
  25666. * Class containing static functions to help procedurally build meshes
  25667. */
  25668. export class DiscBuilder {
  25669. /**
  25670. * Creates a plane polygonal mesh. By default, this is a disc
  25671. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25672. * * 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
  25673. * * 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
  25674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25675. * * 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
  25676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25677. * @param name defines the name of the mesh
  25678. * @param options defines the options used to create the mesh
  25679. * @param scene defines the hosting scene
  25680. * @returns the plane polygonal mesh
  25681. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25682. */
  25683. static CreateDisc(name: string, options: {
  25684. radius?: number;
  25685. tessellation?: number;
  25686. arc?: number;
  25687. updatable?: boolean;
  25688. sideOrientation?: number;
  25689. frontUVs?: Vector4;
  25690. backUVs?: Vector4;
  25691. }, scene?: Nullable<Scene>): Mesh;
  25692. }
  25693. }
  25694. declare module BABYLON {
  25695. /**
  25696. * This represents all the required information to add a fresnel effect on a material:
  25697. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25698. */
  25699. export class FresnelParameters {
  25700. private _isEnabled;
  25701. /**
  25702. * Define if the fresnel effect is enable or not.
  25703. */
  25704. get isEnabled(): boolean;
  25705. set isEnabled(value: boolean);
  25706. /**
  25707. * Define the color used on edges (grazing angle)
  25708. */
  25709. leftColor: Color3;
  25710. /**
  25711. * Define the color used on center
  25712. */
  25713. rightColor: Color3;
  25714. /**
  25715. * Define bias applied to computed fresnel term
  25716. */
  25717. bias: number;
  25718. /**
  25719. * Defined the power exponent applied to fresnel term
  25720. */
  25721. power: number;
  25722. /**
  25723. * Clones the current fresnel and its valuues
  25724. * @returns a clone fresnel configuration
  25725. */
  25726. clone(): FresnelParameters;
  25727. /**
  25728. * Serializes the current fresnel parameters to a JSON representation.
  25729. * @return the JSON serialization
  25730. */
  25731. serialize(): any;
  25732. /**
  25733. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25734. * @param parsedFresnelParameters Define the JSON representation
  25735. * @returns the parsed parameters
  25736. */
  25737. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25738. }
  25739. }
  25740. declare module BABYLON {
  25741. /**
  25742. * Base class of materials working in push mode in babylon JS
  25743. * @hidden
  25744. */
  25745. export class PushMaterial extends Material {
  25746. protected _activeEffect: Effect;
  25747. protected _normalMatrix: Matrix;
  25748. /**
  25749. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25750. * This means that the material can keep using a previous shader while a new one is being compiled.
  25751. * This is mostly used when shader parallel compilation is supported (true by default)
  25752. */
  25753. allowShaderHotSwapping: boolean;
  25754. constructor(name: string, scene: Scene);
  25755. getEffect(): Effect;
  25756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25757. /**
  25758. * Binds the given world matrix to the active effect
  25759. *
  25760. * @param world the matrix to bind
  25761. */
  25762. bindOnlyWorldMatrix(world: Matrix): void;
  25763. /**
  25764. * Binds the given normal matrix to the active effect
  25765. *
  25766. * @param normalMatrix the matrix to bind
  25767. */
  25768. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25769. bind(world: Matrix, mesh?: Mesh): void;
  25770. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25771. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25772. }
  25773. }
  25774. declare module BABYLON {
  25775. /**
  25776. * This groups all the flags used to control the materials channel.
  25777. */
  25778. export class MaterialFlags {
  25779. private static _DiffuseTextureEnabled;
  25780. /**
  25781. * Are diffuse textures enabled in the application.
  25782. */
  25783. static get DiffuseTextureEnabled(): boolean;
  25784. static set DiffuseTextureEnabled(value: boolean);
  25785. private static _AmbientTextureEnabled;
  25786. /**
  25787. * Are ambient textures enabled in the application.
  25788. */
  25789. static get AmbientTextureEnabled(): boolean;
  25790. static set AmbientTextureEnabled(value: boolean);
  25791. private static _OpacityTextureEnabled;
  25792. /**
  25793. * Are opacity textures enabled in the application.
  25794. */
  25795. static get OpacityTextureEnabled(): boolean;
  25796. static set OpacityTextureEnabled(value: boolean);
  25797. private static _ReflectionTextureEnabled;
  25798. /**
  25799. * Are reflection textures enabled in the application.
  25800. */
  25801. static get ReflectionTextureEnabled(): boolean;
  25802. static set ReflectionTextureEnabled(value: boolean);
  25803. private static _EmissiveTextureEnabled;
  25804. /**
  25805. * Are emissive textures enabled in the application.
  25806. */
  25807. static get EmissiveTextureEnabled(): boolean;
  25808. static set EmissiveTextureEnabled(value: boolean);
  25809. private static _SpecularTextureEnabled;
  25810. /**
  25811. * Are specular textures enabled in the application.
  25812. */
  25813. static get SpecularTextureEnabled(): boolean;
  25814. static set SpecularTextureEnabled(value: boolean);
  25815. private static _BumpTextureEnabled;
  25816. /**
  25817. * Are bump textures enabled in the application.
  25818. */
  25819. static get BumpTextureEnabled(): boolean;
  25820. static set BumpTextureEnabled(value: boolean);
  25821. private static _LightmapTextureEnabled;
  25822. /**
  25823. * Are lightmap textures enabled in the application.
  25824. */
  25825. static get LightmapTextureEnabled(): boolean;
  25826. static set LightmapTextureEnabled(value: boolean);
  25827. private static _RefractionTextureEnabled;
  25828. /**
  25829. * Are refraction textures enabled in the application.
  25830. */
  25831. static get RefractionTextureEnabled(): boolean;
  25832. static set RefractionTextureEnabled(value: boolean);
  25833. private static _ColorGradingTextureEnabled;
  25834. /**
  25835. * Are color grading textures enabled in the application.
  25836. */
  25837. static get ColorGradingTextureEnabled(): boolean;
  25838. static set ColorGradingTextureEnabled(value: boolean);
  25839. private static _FresnelEnabled;
  25840. /**
  25841. * Are fresnels enabled in the application.
  25842. */
  25843. static get FresnelEnabled(): boolean;
  25844. static set FresnelEnabled(value: boolean);
  25845. private static _ClearCoatTextureEnabled;
  25846. /**
  25847. * Are clear coat textures enabled in the application.
  25848. */
  25849. static get ClearCoatTextureEnabled(): boolean;
  25850. static set ClearCoatTextureEnabled(value: boolean);
  25851. private static _ClearCoatBumpTextureEnabled;
  25852. /**
  25853. * Are clear coat bump textures enabled in the application.
  25854. */
  25855. static get ClearCoatBumpTextureEnabled(): boolean;
  25856. static set ClearCoatBumpTextureEnabled(value: boolean);
  25857. private static _ClearCoatTintTextureEnabled;
  25858. /**
  25859. * Are clear coat tint textures enabled in the application.
  25860. */
  25861. static get ClearCoatTintTextureEnabled(): boolean;
  25862. static set ClearCoatTintTextureEnabled(value: boolean);
  25863. private static _SheenTextureEnabled;
  25864. /**
  25865. * Are sheen textures enabled in the application.
  25866. */
  25867. static get SheenTextureEnabled(): boolean;
  25868. static set SheenTextureEnabled(value: boolean);
  25869. private static _AnisotropicTextureEnabled;
  25870. /**
  25871. * Are anisotropic textures enabled in the application.
  25872. */
  25873. static get AnisotropicTextureEnabled(): boolean;
  25874. static set AnisotropicTextureEnabled(value: boolean);
  25875. private static _ThicknessTextureEnabled;
  25876. /**
  25877. * Are thickness textures enabled in the application.
  25878. */
  25879. static get ThicknessTextureEnabled(): boolean;
  25880. static set ThicknessTextureEnabled(value: boolean);
  25881. }
  25882. }
  25883. declare module BABYLON {
  25884. /** @hidden */
  25885. export var defaultFragmentDeclaration: {
  25886. name: string;
  25887. shader: string;
  25888. };
  25889. }
  25890. declare module BABYLON {
  25891. /** @hidden */
  25892. export var defaultUboDeclaration: {
  25893. name: string;
  25894. shader: string;
  25895. };
  25896. }
  25897. declare module BABYLON {
  25898. /** @hidden */
  25899. export var lightFragmentDeclaration: {
  25900. name: string;
  25901. shader: string;
  25902. };
  25903. }
  25904. declare module BABYLON {
  25905. /** @hidden */
  25906. export var lightUboDeclaration: {
  25907. name: string;
  25908. shader: string;
  25909. };
  25910. }
  25911. declare module BABYLON {
  25912. /** @hidden */
  25913. export var lightsFragmentFunctions: {
  25914. name: string;
  25915. shader: string;
  25916. };
  25917. }
  25918. declare module BABYLON {
  25919. /** @hidden */
  25920. export var shadowsFragmentFunctions: {
  25921. name: string;
  25922. shader: string;
  25923. };
  25924. }
  25925. declare module BABYLON {
  25926. /** @hidden */
  25927. export var fresnelFunction: {
  25928. name: string;
  25929. shader: string;
  25930. };
  25931. }
  25932. declare module BABYLON {
  25933. /** @hidden */
  25934. export var reflectionFunction: {
  25935. name: string;
  25936. shader: string;
  25937. };
  25938. }
  25939. declare module BABYLON {
  25940. /** @hidden */
  25941. export var bumpFragmentFunctions: {
  25942. name: string;
  25943. shader: string;
  25944. };
  25945. }
  25946. declare module BABYLON {
  25947. /** @hidden */
  25948. export var logDepthDeclaration: {
  25949. name: string;
  25950. shader: string;
  25951. };
  25952. }
  25953. declare module BABYLON {
  25954. /** @hidden */
  25955. export var bumpFragment: {
  25956. name: string;
  25957. shader: string;
  25958. };
  25959. }
  25960. declare module BABYLON {
  25961. /** @hidden */
  25962. export var depthPrePass: {
  25963. name: string;
  25964. shader: string;
  25965. };
  25966. }
  25967. declare module BABYLON {
  25968. /** @hidden */
  25969. export var lightFragment: {
  25970. name: string;
  25971. shader: string;
  25972. };
  25973. }
  25974. declare module BABYLON {
  25975. /** @hidden */
  25976. export var logDepthFragment: {
  25977. name: string;
  25978. shader: string;
  25979. };
  25980. }
  25981. declare module BABYLON {
  25982. /** @hidden */
  25983. export var defaultPixelShader: {
  25984. name: string;
  25985. shader: string;
  25986. };
  25987. }
  25988. declare module BABYLON {
  25989. /** @hidden */
  25990. export var defaultVertexDeclaration: {
  25991. name: string;
  25992. shader: string;
  25993. };
  25994. }
  25995. declare module BABYLON {
  25996. /** @hidden */
  25997. export var bumpVertexDeclaration: {
  25998. name: string;
  25999. shader: string;
  26000. };
  26001. }
  26002. declare module BABYLON {
  26003. /** @hidden */
  26004. export var bumpVertex: {
  26005. name: string;
  26006. shader: string;
  26007. };
  26008. }
  26009. declare module BABYLON {
  26010. /** @hidden */
  26011. export var fogVertex: {
  26012. name: string;
  26013. shader: string;
  26014. };
  26015. }
  26016. declare module BABYLON {
  26017. /** @hidden */
  26018. export var shadowsVertex: {
  26019. name: string;
  26020. shader: string;
  26021. };
  26022. }
  26023. declare module BABYLON {
  26024. /** @hidden */
  26025. export var pointCloudVertex: {
  26026. name: string;
  26027. shader: string;
  26028. };
  26029. }
  26030. declare module BABYLON {
  26031. /** @hidden */
  26032. export var logDepthVertex: {
  26033. name: string;
  26034. shader: string;
  26035. };
  26036. }
  26037. declare module BABYLON {
  26038. /** @hidden */
  26039. export var defaultVertexShader: {
  26040. name: string;
  26041. shader: string;
  26042. };
  26043. }
  26044. declare module BABYLON {
  26045. /** @hidden */
  26046. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26047. MAINUV1: boolean;
  26048. MAINUV2: boolean;
  26049. DIFFUSE: boolean;
  26050. DIFFUSEDIRECTUV: number;
  26051. AMBIENT: boolean;
  26052. AMBIENTDIRECTUV: number;
  26053. OPACITY: boolean;
  26054. OPACITYDIRECTUV: number;
  26055. OPACITYRGB: boolean;
  26056. REFLECTION: boolean;
  26057. EMISSIVE: boolean;
  26058. EMISSIVEDIRECTUV: number;
  26059. SPECULAR: boolean;
  26060. SPECULARDIRECTUV: number;
  26061. BUMP: boolean;
  26062. BUMPDIRECTUV: number;
  26063. PARALLAX: boolean;
  26064. PARALLAXOCCLUSION: boolean;
  26065. SPECULAROVERALPHA: boolean;
  26066. CLIPPLANE: boolean;
  26067. CLIPPLANE2: boolean;
  26068. CLIPPLANE3: boolean;
  26069. CLIPPLANE4: boolean;
  26070. CLIPPLANE5: boolean;
  26071. CLIPPLANE6: boolean;
  26072. ALPHATEST: boolean;
  26073. DEPTHPREPASS: boolean;
  26074. ALPHAFROMDIFFUSE: boolean;
  26075. POINTSIZE: boolean;
  26076. FOG: boolean;
  26077. SPECULARTERM: boolean;
  26078. DIFFUSEFRESNEL: boolean;
  26079. OPACITYFRESNEL: boolean;
  26080. REFLECTIONFRESNEL: boolean;
  26081. REFRACTIONFRESNEL: boolean;
  26082. EMISSIVEFRESNEL: boolean;
  26083. FRESNEL: boolean;
  26084. NORMAL: boolean;
  26085. UV1: boolean;
  26086. UV2: boolean;
  26087. VERTEXCOLOR: boolean;
  26088. VERTEXALPHA: boolean;
  26089. NUM_BONE_INFLUENCERS: number;
  26090. BonesPerMesh: number;
  26091. BONETEXTURE: boolean;
  26092. INSTANCES: boolean;
  26093. GLOSSINESS: boolean;
  26094. ROUGHNESS: boolean;
  26095. EMISSIVEASILLUMINATION: boolean;
  26096. LINKEMISSIVEWITHDIFFUSE: boolean;
  26097. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26098. LIGHTMAP: boolean;
  26099. LIGHTMAPDIRECTUV: number;
  26100. OBJECTSPACE_NORMALMAP: boolean;
  26101. USELIGHTMAPASSHADOWMAP: boolean;
  26102. REFLECTIONMAP_3D: boolean;
  26103. REFLECTIONMAP_SPHERICAL: boolean;
  26104. REFLECTIONMAP_PLANAR: boolean;
  26105. REFLECTIONMAP_CUBIC: boolean;
  26106. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26107. REFLECTIONMAP_PROJECTION: boolean;
  26108. REFLECTIONMAP_SKYBOX: boolean;
  26109. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26110. REFLECTIONMAP_EXPLICIT: boolean;
  26111. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26112. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26113. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26114. INVERTCUBICMAP: boolean;
  26115. LOGARITHMICDEPTH: boolean;
  26116. REFRACTION: boolean;
  26117. REFRACTIONMAP_3D: boolean;
  26118. REFLECTIONOVERALPHA: boolean;
  26119. TWOSIDEDLIGHTING: boolean;
  26120. SHADOWFLOAT: boolean;
  26121. MORPHTARGETS: boolean;
  26122. MORPHTARGETS_NORMAL: boolean;
  26123. MORPHTARGETS_TANGENT: boolean;
  26124. MORPHTARGETS_UV: boolean;
  26125. NUM_MORPH_INFLUENCERS: number;
  26126. NONUNIFORMSCALING: boolean;
  26127. PREMULTIPLYALPHA: boolean;
  26128. IMAGEPROCESSING: boolean;
  26129. VIGNETTE: boolean;
  26130. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26131. VIGNETTEBLENDMODEOPAQUE: boolean;
  26132. TONEMAPPING: boolean;
  26133. TONEMAPPING_ACES: boolean;
  26134. CONTRAST: boolean;
  26135. COLORCURVES: boolean;
  26136. COLORGRADING: boolean;
  26137. COLORGRADING3D: boolean;
  26138. SAMPLER3DGREENDEPTH: boolean;
  26139. SAMPLER3DBGRMAP: boolean;
  26140. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26141. MULTIVIEW: boolean;
  26142. /**
  26143. * If the reflection texture on this material is in linear color space
  26144. * @hidden
  26145. */
  26146. IS_REFLECTION_LINEAR: boolean;
  26147. /**
  26148. * If the refraction texture on this material is in linear color space
  26149. * @hidden
  26150. */
  26151. IS_REFRACTION_LINEAR: boolean;
  26152. EXPOSURE: boolean;
  26153. constructor();
  26154. setReflectionMode(modeToEnable: string): void;
  26155. }
  26156. /**
  26157. * This is the default material used in Babylon. It is the best trade off between quality
  26158. * and performances.
  26159. * @see http://doc.babylonjs.com/babylon101/materials
  26160. */
  26161. export class StandardMaterial extends PushMaterial {
  26162. private _diffuseTexture;
  26163. /**
  26164. * The basic texture of the material as viewed under a light.
  26165. */
  26166. diffuseTexture: Nullable<BaseTexture>;
  26167. private _ambientTexture;
  26168. /**
  26169. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26170. */
  26171. ambientTexture: Nullable<BaseTexture>;
  26172. private _opacityTexture;
  26173. /**
  26174. * Define the transparency of the material from a texture.
  26175. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26176. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26177. */
  26178. opacityTexture: Nullable<BaseTexture>;
  26179. private _reflectionTexture;
  26180. /**
  26181. * Define the texture used to display the reflection.
  26182. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26183. */
  26184. reflectionTexture: Nullable<BaseTexture>;
  26185. private _emissiveTexture;
  26186. /**
  26187. * Define texture of the material as if self lit.
  26188. * This will be mixed in the final result even in the absence of light.
  26189. */
  26190. emissiveTexture: Nullable<BaseTexture>;
  26191. private _specularTexture;
  26192. /**
  26193. * Define how the color and intensity of the highlight given by the light in the material.
  26194. */
  26195. specularTexture: Nullable<BaseTexture>;
  26196. private _bumpTexture;
  26197. /**
  26198. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26199. * 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.
  26200. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26201. */
  26202. bumpTexture: Nullable<BaseTexture>;
  26203. private _lightmapTexture;
  26204. /**
  26205. * Complex lighting can be computationally expensive to compute at runtime.
  26206. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26207. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26208. */
  26209. lightmapTexture: Nullable<BaseTexture>;
  26210. private _refractionTexture;
  26211. /**
  26212. * Define the texture used to display the refraction.
  26213. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26214. */
  26215. refractionTexture: Nullable<BaseTexture>;
  26216. /**
  26217. * The color of the material lit by the environmental background lighting.
  26218. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26219. */
  26220. ambientColor: Color3;
  26221. /**
  26222. * The basic color of the material as viewed under a light.
  26223. */
  26224. diffuseColor: Color3;
  26225. /**
  26226. * Define how the color and intensity of the highlight given by the light in the material.
  26227. */
  26228. specularColor: Color3;
  26229. /**
  26230. * Define the color of the material as if self lit.
  26231. * This will be mixed in the final result even in the absence of light.
  26232. */
  26233. emissiveColor: Color3;
  26234. /**
  26235. * Defines how sharp are the highlights in the material.
  26236. * The bigger the value the sharper giving a more glossy feeling to the result.
  26237. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26238. */
  26239. specularPower: number;
  26240. private _useAlphaFromDiffuseTexture;
  26241. /**
  26242. * Does the transparency come from the diffuse texture alpha channel.
  26243. */
  26244. useAlphaFromDiffuseTexture: boolean;
  26245. private _useEmissiveAsIllumination;
  26246. /**
  26247. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26248. */
  26249. useEmissiveAsIllumination: boolean;
  26250. private _linkEmissiveWithDiffuse;
  26251. /**
  26252. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26253. * the emissive level when the final color is close to one.
  26254. */
  26255. linkEmissiveWithDiffuse: boolean;
  26256. private _useSpecularOverAlpha;
  26257. /**
  26258. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26260. */
  26261. useSpecularOverAlpha: boolean;
  26262. private _useReflectionOverAlpha;
  26263. /**
  26264. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26265. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26266. */
  26267. useReflectionOverAlpha: boolean;
  26268. private _disableLighting;
  26269. /**
  26270. * Does lights from the scene impacts this material.
  26271. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26272. */
  26273. disableLighting: boolean;
  26274. private _useObjectSpaceNormalMap;
  26275. /**
  26276. * Allows using an object space normal map (instead of tangent space).
  26277. */
  26278. useObjectSpaceNormalMap: boolean;
  26279. private _useParallax;
  26280. /**
  26281. * Is parallax enabled or not.
  26282. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26283. */
  26284. useParallax: boolean;
  26285. private _useParallaxOcclusion;
  26286. /**
  26287. * Is parallax occlusion enabled or not.
  26288. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26289. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26290. */
  26291. useParallaxOcclusion: boolean;
  26292. /**
  26293. * 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.
  26294. */
  26295. parallaxScaleBias: number;
  26296. private _roughness;
  26297. /**
  26298. * Helps to define how blurry the reflections should appears in the material.
  26299. */
  26300. roughness: number;
  26301. /**
  26302. * In case of refraction, define the value of the index of refraction.
  26303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26304. */
  26305. indexOfRefraction: number;
  26306. /**
  26307. * Invert the refraction texture alongside the y axis.
  26308. * It can be useful with procedural textures or probe for instance.
  26309. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26310. */
  26311. invertRefractionY: boolean;
  26312. /**
  26313. * Defines the alpha limits in alpha test mode.
  26314. */
  26315. alphaCutOff: number;
  26316. private _useLightmapAsShadowmap;
  26317. /**
  26318. * In case of light mapping, define whether the map contains light or shadow informations.
  26319. */
  26320. useLightmapAsShadowmap: boolean;
  26321. private _diffuseFresnelParameters;
  26322. /**
  26323. * Define the diffuse fresnel parameters of the material.
  26324. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26325. */
  26326. diffuseFresnelParameters: FresnelParameters;
  26327. private _opacityFresnelParameters;
  26328. /**
  26329. * Define the opacity fresnel parameters of the material.
  26330. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26331. */
  26332. opacityFresnelParameters: FresnelParameters;
  26333. private _reflectionFresnelParameters;
  26334. /**
  26335. * Define the reflection fresnel parameters of the material.
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26337. */
  26338. reflectionFresnelParameters: FresnelParameters;
  26339. private _refractionFresnelParameters;
  26340. /**
  26341. * Define the refraction fresnel parameters of the material.
  26342. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26343. */
  26344. refractionFresnelParameters: FresnelParameters;
  26345. private _emissiveFresnelParameters;
  26346. /**
  26347. * Define the emissive fresnel parameters of the material.
  26348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26349. */
  26350. emissiveFresnelParameters: FresnelParameters;
  26351. private _useReflectionFresnelFromSpecular;
  26352. /**
  26353. * If true automatically deducts the fresnels values from the material specularity.
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26355. */
  26356. useReflectionFresnelFromSpecular: boolean;
  26357. private _useGlossinessFromSpecularMapAlpha;
  26358. /**
  26359. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26360. */
  26361. useGlossinessFromSpecularMapAlpha: boolean;
  26362. private _maxSimultaneousLights;
  26363. /**
  26364. * Defines the maximum number of lights that can be used in the material
  26365. */
  26366. maxSimultaneousLights: number;
  26367. private _invertNormalMapX;
  26368. /**
  26369. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26370. */
  26371. invertNormalMapX: boolean;
  26372. private _invertNormalMapY;
  26373. /**
  26374. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26375. */
  26376. invertNormalMapY: boolean;
  26377. private _twoSidedLighting;
  26378. /**
  26379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26380. */
  26381. twoSidedLighting: boolean;
  26382. /**
  26383. * Default configuration related to image processing available in the standard Material.
  26384. */
  26385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26386. /**
  26387. * Gets the image processing configuration used either in this material.
  26388. */
  26389. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26390. /**
  26391. * Sets the Default image processing configuration used either in the this material.
  26392. *
  26393. * If sets to null, the scene one is in use.
  26394. */
  26395. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26396. /**
  26397. * Keep track of the image processing observer to allow dispose and replace.
  26398. */
  26399. private _imageProcessingObserver;
  26400. /**
  26401. * Attaches a new image processing configuration to the Standard Material.
  26402. * @param configuration
  26403. */
  26404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26405. /**
  26406. * Gets wether the color curves effect is enabled.
  26407. */
  26408. get cameraColorCurvesEnabled(): boolean;
  26409. /**
  26410. * Sets wether the color curves effect is enabled.
  26411. */
  26412. set cameraColorCurvesEnabled(value: boolean);
  26413. /**
  26414. * Gets wether the color grading effect is enabled.
  26415. */
  26416. get cameraColorGradingEnabled(): boolean;
  26417. /**
  26418. * Gets wether the color grading effect is enabled.
  26419. */
  26420. set cameraColorGradingEnabled(value: boolean);
  26421. /**
  26422. * Gets wether tonemapping is enabled or not.
  26423. */
  26424. get cameraToneMappingEnabled(): boolean;
  26425. /**
  26426. * Sets wether tonemapping is enabled or not
  26427. */
  26428. set cameraToneMappingEnabled(value: boolean);
  26429. /**
  26430. * The camera exposure used on this material.
  26431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26432. * This corresponds to a photographic exposure.
  26433. */
  26434. get cameraExposure(): number;
  26435. /**
  26436. * The camera exposure used on this material.
  26437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26438. * This corresponds to a photographic exposure.
  26439. */
  26440. set cameraExposure(value: number);
  26441. /**
  26442. * Gets The camera contrast used on this material.
  26443. */
  26444. get cameraContrast(): number;
  26445. /**
  26446. * Sets The camera contrast used on this material.
  26447. */
  26448. set cameraContrast(value: number);
  26449. /**
  26450. * Gets the Color Grading 2D Lookup Texture.
  26451. */
  26452. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26453. /**
  26454. * Sets the Color Grading 2D Lookup Texture.
  26455. */
  26456. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26457. /**
  26458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26460. * 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;
  26461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26462. */
  26463. get cameraColorCurves(): Nullable<ColorCurves>;
  26464. /**
  26465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26467. * 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;
  26468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26469. */
  26470. set cameraColorCurves(value: Nullable<ColorCurves>);
  26471. /**
  26472. * Custom callback helping to override the default shader used in the material.
  26473. */
  26474. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26475. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26476. protected _worldViewProjectionMatrix: Matrix;
  26477. protected _globalAmbientColor: Color3;
  26478. protected _useLogarithmicDepth: boolean;
  26479. protected _rebuildInParallel: boolean;
  26480. /**
  26481. * Instantiates a new standard material.
  26482. * This is the default material used in Babylon. It is the best trade off between quality
  26483. * and performances.
  26484. * @see http://doc.babylonjs.com/babylon101/materials
  26485. * @param name Define the name of the material in the scene
  26486. * @param scene Define the scene the material belong to
  26487. */
  26488. constructor(name: string, scene: Scene);
  26489. /**
  26490. * Gets a boolean indicating that current material needs to register RTT
  26491. */
  26492. get hasRenderTargetTextures(): boolean;
  26493. /**
  26494. * Gets the current class name of the material e.g. "StandardMaterial"
  26495. * Mainly use in serialization.
  26496. * @returns the class name
  26497. */
  26498. getClassName(): string;
  26499. /**
  26500. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26501. * You can try switching to logarithmic depth.
  26502. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26503. */
  26504. get useLogarithmicDepth(): boolean;
  26505. set useLogarithmicDepth(value: boolean);
  26506. /**
  26507. * Specifies if the material will require alpha blending
  26508. * @returns a boolean specifying if alpha blending is needed
  26509. */
  26510. needAlphaBlending(): boolean;
  26511. /**
  26512. * Specifies if this material should be rendered in alpha test mode
  26513. * @returns a boolean specifying if an alpha test is needed.
  26514. */
  26515. needAlphaTesting(): boolean;
  26516. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26517. /**
  26518. * Get the texture used for alpha test purpose.
  26519. * @returns the diffuse texture in case of the standard material.
  26520. */
  26521. getAlphaTestTexture(): Nullable<BaseTexture>;
  26522. /**
  26523. * Get if the submesh is ready to be used and all its information available.
  26524. * Child classes can use it to update shaders
  26525. * @param mesh defines the mesh to check
  26526. * @param subMesh defines which submesh to check
  26527. * @param useInstances specifies that instances should be used
  26528. * @returns a boolean indicating that the submesh is ready or not
  26529. */
  26530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26531. /**
  26532. * Builds the material UBO layouts.
  26533. * Used internally during the effect preparation.
  26534. */
  26535. buildUniformLayout(): void;
  26536. /**
  26537. * Unbinds the material from the mesh
  26538. */
  26539. unbind(): void;
  26540. /**
  26541. * Binds the submesh to this material by preparing the effect and shader to draw
  26542. * @param world defines the world transformation matrix
  26543. * @param mesh defines the mesh containing the submesh
  26544. * @param subMesh defines the submesh to bind the material to
  26545. */
  26546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26547. /**
  26548. * Get the list of animatables in the material.
  26549. * @returns the list of animatables object used in the material
  26550. */
  26551. getAnimatables(): IAnimatable[];
  26552. /**
  26553. * Gets the active textures from the material
  26554. * @returns an array of textures
  26555. */
  26556. getActiveTextures(): BaseTexture[];
  26557. /**
  26558. * Specifies if the material uses a texture
  26559. * @param texture defines the texture to check against the material
  26560. * @returns a boolean specifying if the material uses the texture
  26561. */
  26562. hasTexture(texture: BaseTexture): boolean;
  26563. /**
  26564. * Disposes the material
  26565. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26566. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26567. */
  26568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26569. /**
  26570. * Makes a duplicate of the material, and gives it a new name
  26571. * @param name defines the new name for the duplicated material
  26572. * @returns the cloned material
  26573. */
  26574. clone(name: string): StandardMaterial;
  26575. /**
  26576. * Serializes this material in a JSON representation
  26577. * @returns the serialized material object
  26578. */
  26579. serialize(): any;
  26580. /**
  26581. * Creates a standard material from parsed material data
  26582. * @param source defines the JSON representation of the material
  26583. * @param scene defines the hosting scene
  26584. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26585. * @returns a new standard material
  26586. */
  26587. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26588. /**
  26589. * Are diffuse textures enabled in the application.
  26590. */
  26591. static get DiffuseTextureEnabled(): boolean;
  26592. static set DiffuseTextureEnabled(value: boolean);
  26593. /**
  26594. * Are ambient textures enabled in the application.
  26595. */
  26596. static get AmbientTextureEnabled(): boolean;
  26597. static set AmbientTextureEnabled(value: boolean);
  26598. /**
  26599. * Are opacity textures enabled in the application.
  26600. */
  26601. static get OpacityTextureEnabled(): boolean;
  26602. static set OpacityTextureEnabled(value: boolean);
  26603. /**
  26604. * Are reflection textures enabled in the application.
  26605. */
  26606. static get ReflectionTextureEnabled(): boolean;
  26607. static set ReflectionTextureEnabled(value: boolean);
  26608. /**
  26609. * Are emissive textures enabled in the application.
  26610. */
  26611. static get EmissiveTextureEnabled(): boolean;
  26612. static set EmissiveTextureEnabled(value: boolean);
  26613. /**
  26614. * Are specular textures enabled in the application.
  26615. */
  26616. static get SpecularTextureEnabled(): boolean;
  26617. static set SpecularTextureEnabled(value: boolean);
  26618. /**
  26619. * Are bump textures enabled in the application.
  26620. */
  26621. static get BumpTextureEnabled(): boolean;
  26622. static set BumpTextureEnabled(value: boolean);
  26623. /**
  26624. * Are lightmap textures enabled in the application.
  26625. */
  26626. static get LightmapTextureEnabled(): boolean;
  26627. static set LightmapTextureEnabled(value: boolean);
  26628. /**
  26629. * Are refraction textures enabled in the application.
  26630. */
  26631. static get RefractionTextureEnabled(): boolean;
  26632. static set RefractionTextureEnabled(value: boolean);
  26633. /**
  26634. * Are color grading textures enabled in the application.
  26635. */
  26636. static get ColorGradingTextureEnabled(): boolean;
  26637. static set ColorGradingTextureEnabled(value: boolean);
  26638. /**
  26639. * Are fresnels enabled in the application.
  26640. */
  26641. static get FresnelEnabled(): boolean;
  26642. static set FresnelEnabled(value: boolean);
  26643. }
  26644. }
  26645. declare module BABYLON {
  26646. /**
  26647. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26648. *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.
  26649. * The SPS is also a particle system. It provides some methods to manage the particles.
  26650. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26651. *
  26652. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26653. */
  26654. export class SolidParticleSystem implements IDisposable {
  26655. /**
  26656. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26657. * Example : var p = SPS.particles[i];
  26658. */
  26659. particles: SolidParticle[];
  26660. /**
  26661. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26662. */
  26663. nbParticles: number;
  26664. /**
  26665. * If the particles must ever face the camera (default false). Useful for planar particles.
  26666. */
  26667. billboard: boolean;
  26668. /**
  26669. * Recompute normals when adding a shape
  26670. */
  26671. recomputeNormals: boolean;
  26672. /**
  26673. * This a counter ofr your own usage. It's not set by any SPS functions.
  26674. */
  26675. counter: number;
  26676. /**
  26677. * The SPS name. This name is also given to the underlying mesh.
  26678. */
  26679. name: string;
  26680. /**
  26681. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26682. */
  26683. mesh: Mesh;
  26684. /**
  26685. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26686. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26687. */
  26688. vars: any;
  26689. /**
  26690. * This array is populated when the SPS is set as 'pickable'.
  26691. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26692. * Each element of this array is an object `{idx: int, faceId: int}`.
  26693. * `idx` is the picked particle index in the `SPS.particles` array
  26694. * `faceId` is the picked face index counted within this particle.
  26695. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26696. */
  26697. pickedParticles: {
  26698. idx: number;
  26699. faceId: number;
  26700. }[];
  26701. /**
  26702. * This array is populated when `enableDepthSort` is set to true.
  26703. * Each element of this array is an instance of the class DepthSortedParticle.
  26704. */
  26705. depthSortedParticles: DepthSortedParticle[];
  26706. /**
  26707. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26708. * @hidden
  26709. */
  26710. _bSphereOnly: boolean;
  26711. /**
  26712. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26713. * @hidden
  26714. */
  26715. _bSphereRadiusFactor: number;
  26716. private _scene;
  26717. private _positions;
  26718. private _indices;
  26719. private _normals;
  26720. private _colors;
  26721. private _uvs;
  26722. private _indices32;
  26723. private _positions32;
  26724. private _normals32;
  26725. private _fixedNormal32;
  26726. private _colors32;
  26727. private _uvs32;
  26728. private _index;
  26729. private _updatable;
  26730. private _pickable;
  26731. private _isVisibilityBoxLocked;
  26732. private _alwaysVisible;
  26733. private _depthSort;
  26734. private _expandable;
  26735. private _shapeCounter;
  26736. private _copy;
  26737. private _color;
  26738. private _computeParticleColor;
  26739. private _computeParticleTexture;
  26740. private _computeParticleRotation;
  26741. private _computeParticleVertex;
  26742. private _computeBoundingBox;
  26743. private _depthSortParticles;
  26744. private _camera;
  26745. private _mustUnrotateFixedNormals;
  26746. private _particlesIntersect;
  26747. private _needs32Bits;
  26748. private _isNotBuilt;
  26749. private _lastParticleId;
  26750. private _idxOfId;
  26751. private _multimaterialEnabled;
  26752. private _useModelMaterial;
  26753. private _indicesByMaterial;
  26754. private _materialIndexes;
  26755. private _depthSortFunction;
  26756. private _materialSortFunction;
  26757. private _materials;
  26758. private _multimaterial;
  26759. private _materialIndexesById;
  26760. private _defaultMaterial;
  26761. private _autoUpdateSubMeshes;
  26762. /**
  26763. * Creates a SPS (Solid Particle System) object.
  26764. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26765. * @param scene (Scene) is the scene in which the SPS is added.
  26766. * @param options defines the options of the sps e.g.
  26767. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26768. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26769. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26770. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  26771. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26772. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26773. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26774. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26775. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26776. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26777. */
  26778. constructor(name: string, scene: Scene, options?: {
  26779. updatable?: boolean;
  26780. isPickable?: boolean;
  26781. enableDepthSort?: boolean;
  26782. particleIntersection?: boolean;
  26783. boundingSphereOnly?: boolean;
  26784. bSphereRadiusFactor?: number;
  26785. expandable?: boolean;
  26786. useModelMaterial?: boolean;
  26787. enableMultiMaterial?: boolean;
  26788. });
  26789. /**
  26790. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26791. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26792. * @returns the created mesh
  26793. */
  26794. buildMesh(): Mesh;
  26795. /**
  26796. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26797. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26798. * Thus the particles generated from `digest()` have their property `position` set yet.
  26799. * @param mesh ( Mesh ) is the mesh to be digested
  26800. * @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
  26801. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26802. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26803. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26804. * @returns the current SPS
  26805. */
  26806. digest(mesh: Mesh, options?: {
  26807. facetNb?: number;
  26808. number?: number;
  26809. delta?: number;
  26810. storage?: [];
  26811. }): SolidParticleSystem;
  26812. /**
  26813. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26814. * @hidden
  26815. */
  26816. private _unrotateFixedNormals;
  26817. /**
  26818. * Resets the temporary working copy particle
  26819. * @hidden
  26820. */
  26821. private _resetCopy;
  26822. /**
  26823. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26824. * @param p the current index in the positions array to be updated
  26825. * @param ind the current index in the indices array
  26826. * @param shape a Vector3 array, the shape geometry
  26827. * @param positions the positions array to be updated
  26828. * @param meshInd the shape indices array
  26829. * @param indices the indices array to be updated
  26830. * @param meshUV the shape uv array
  26831. * @param uvs the uv array to be updated
  26832. * @param meshCol the shape color array
  26833. * @param colors the color array to be updated
  26834. * @param meshNor the shape normals array
  26835. * @param normals the normals array to be updated
  26836. * @param idx the particle index
  26837. * @param idxInShape the particle index in its shape
  26838. * @param options the addShape() method passed options
  26839. * @model the particle model
  26840. * @hidden
  26841. */
  26842. private _meshBuilder;
  26843. /**
  26844. * Returns a shape Vector3 array from positions float array
  26845. * @param positions float array
  26846. * @returns a vector3 array
  26847. * @hidden
  26848. */
  26849. private _posToShape;
  26850. /**
  26851. * Returns a shapeUV array from a float uvs (array deep copy)
  26852. * @param uvs as a float array
  26853. * @returns a shapeUV array
  26854. * @hidden
  26855. */
  26856. private _uvsToShapeUV;
  26857. /**
  26858. * Adds a new particle object in the particles array
  26859. * @param idx particle index in particles array
  26860. * @param id particle id
  26861. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26862. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26863. * @param model particle ModelShape object
  26864. * @param shapeId model shape identifier
  26865. * @param idxInShape index of the particle in the current model
  26866. * @param bInfo model bounding info object
  26867. * @param storage target storage array, if any
  26868. * @hidden
  26869. */
  26870. private _addParticle;
  26871. /**
  26872. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26873. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26874. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26875. * @param nb (positive integer) the number of particles to be created from this model
  26876. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26877. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26878. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26879. * @returns the number of shapes in the system
  26880. */
  26881. addShape(mesh: Mesh, nb: number, options?: {
  26882. positionFunction?: any;
  26883. vertexFunction?: any;
  26884. storage?: [];
  26885. }): number;
  26886. /**
  26887. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26888. * @hidden
  26889. */
  26890. private _rebuildParticle;
  26891. /**
  26892. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26893. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26894. * @returns the SPS.
  26895. */
  26896. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26897. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26898. * Returns an array with the removed particles.
  26899. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26900. * The SPS can't be empty so at least one particle needs to remain in place.
  26901. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26902. * @param start index of the first particle to remove
  26903. * @param end index of the last particle to remove (included)
  26904. * @returns an array populated with the removed particles
  26905. */
  26906. removeParticles(start: number, end: number): SolidParticle[];
  26907. /**
  26908. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26909. * @param solidParticleArray an array populated with Solid Particles objects
  26910. * @returns the SPS
  26911. */
  26912. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26913. /**
  26914. * Creates a new particle and modifies the SPS mesh geometry :
  26915. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26916. * - calls _addParticle() to populate the particle array
  26917. * factorized code from addShape() and insertParticlesFromArray()
  26918. * @param idx particle index in the particles array
  26919. * @param i particle index in its shape
  26920. * @param modelShape particle ModelShape object
  26921. * @param shape shape vertex array
  26922. * @param meshInd shape indices array
  26923. * @param meshUV shape uv array
  26924. * @param meshCol shape color array
  26925. * @param meshNor shape normals array
  26926. * @param bbInfo shape bounding info
  26927. * @param storage target particle storage
  26928. * @options addShape() passed options
  26929. * @hidden
  26930. */
  26931. private _insertNewParticle;
  26932. /**
  26933. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26934. * This method calls `updateParticle()` for each particle of the SPS.
  26935. * For an animated SPS, it is usually called within the render loop.
  26936. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26937. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26938. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26939. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26940. * @returns the SPS.
  26941. */
  26942. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26943. /**
  26944. * Disposes the SPS.
  26945. */
  26946. dispose(): void;
  26947. /**
  26948. * Returns a SolidParticle object from its identifier : particle.id
  26949. * @param id (integer) the particle Id
  26950. * @returns the searched particle or null if not found in the SPS.
  26951. */
  26952. getParticleById(id: number): Nullable<SolidParticle>;
  26953. /**
  26954. * Returns a new array populated with the particles having the passed shapeId.
  26955. * @param shapeId (integer) the shape identifier
  26956. * @returns a new solid particle array
  26957. */
  26958. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26959. /**
  26960. * Populates the passed array "ref" with the particles having the passed shapeId.
  26961. * @param shapeId the shape identifier
  26962. * @returns the SPS
  26963. * @param ref
  26964. */
  26965. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26966. /**
  26967. * Computes the required SubMeshes according the materials assigned to the particles.
  26968. * @returns the solid particle system.
  26969. * Does nothing if called before the SPS mesh is built.
  26970. */
  26971. computeSubMeshes(): SolidParticleSystem;
  26972. /**
  26973. * Sorts the solid particles by material when MultiMaterial is enabled.
  26974. * Updates the indices32 array.
  26975. * Updates the indicesByMaterial array.
  26976. * Updates the mesh indices array.
  26977. * @returns the SPS
  26978. * @hidden
  26979. */
  26980. private _sortParticlesByMaterial;
  26981. /**
  26982. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26983. * @hidden
  26984. */
  26985. private _setMaterialIndexesById;
  26986. /**
  26987. * Returns an array with unique values of Materials from the passed array
  26988. * @param array the material array to be checked and filtered
  26989. * @hidden
  26990. */
  26991. private _filterUniqueMaterialId;
  26992. /**
  26993. * Sets a new Standard Material as _defaultMaterial if not already set.
  26994. * @hidden
  26995. */
  26996. private _setDefaultMaterial;
  26997. /**
  26998. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26999. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27000. * @returns the SPS.
  27001. */
  27002. refreshVisibleSize(): SolidParticleSystem;
  27003. /**
  27004. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27005. * @param size the size (float) of the visibility box
  27006. * note : this doesn't lock the SPS mesh bounding box.
  27007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27008. */
  27009. setVisibilityBox(size: number): void;
  27010. /**
  27011. * Gets whether the SPS as always visible or not
  27012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27013. */
  27014. get isAlwaysVisible(): boolean;
  27015. /**
  27016. * Sets the SPS as always visible or not
  27017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27018. */
  27019. set isAlwaysVisible(val: boolean);
  27020. /**
  27021. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27022. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27023. */
  27024. set isVisibilityBoxLocked(val: boolean);
  27025. /**
  27026. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27027. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27028. */
  27029. get isVisibilityBoxLocked(): boolean;
  27030. /**
  27031. * Tells to `setParticles()` to compute the particle rotations or not.
  27032. * Default value : true. The SPS is faster when it's set to false.
  27033. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27034. */
  27035. set computeParticleRotation(val: boolean);
  27036. /**
  27037. * Tells to `setParticles()` to compute the particle colors or not.
  27038. * Default value : true. The SPS is faster when it's set to false.
  27039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27040. */
  27041. set computeParticleColor(val: boolean);
  27042. set computeParticleTexture(val: boolean);
  27043. /**
  27044. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27045. * Default value : false. The SPS is faster when it's set to false.
  27046. * Note : the particle custom vertex positions aren't stored values.
  27047. */
  27048. set computeParticleVertex(val: boolean);
  27049. /**
  27050. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27051. */
  27052. set computeBoundingBox(val: boolean);
  27053. /**
  27054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27056. * Default : `true`
  27057. */
  27058. set depthSortParticles(val: boolean);
  27059. /**
  27060. * Gets if `setParticles()` computes the particle rotations or not.
  27061. * Default value : true. The SPS is faster when it's set to false.
  27062. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27063. */
  27064. get computeParticleRotation(): boolean;
  27065. /**
  27066. * Gets if `setParticles()` computes the particle colors or not.
  27067. * Default value : true. The SPS is faster when it's set to false.
  27068. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27069. */
  27070. get computeParticleColor(): boolean;
  27071. /**
  27072. * Gets if `setParticles()` computes the particle textures or not.
  27073. * Default value : true. The SPS is faster when it's set to false.
  27074. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27075. */
  27076. get computeParticleTexture(): boolean;
  27077. /**
  27078. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27079. * Default value : false. The SPS is faster when it's set to false.
  27080. * Note : the particle custom vertex positions aren't stored values.
  27081. */
  27082. get computeParticleVertex(): boolean;
  27083. /**
  27084. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27085. */
  27086. get computeBoundingBox(): boolean;
  27087. /**
  27088. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27089. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27090. * Default : `true`
  27091. */
  27092. get depthSortParticles(): boolean;
  27093. /**
  27094. * Gets if the SPS is created as expandable at construction time.
  27095. * Default : `false`
  27096. */
  27097. get expandable(): boolean;
  27098. /**
  27099. * Gets if the SPS supports the Multi Materials
  27100. */
  27101. get multimaterialEnabled(): boolean;
  27102. /**
  27103. * Gets if the SPS uses the model materials for its own multimaterial.
  27104. */
  27105. get useModelMaterial(): boolean;
  27106. /**
  27107. * The SPS used material array.
  27108. */
  27109. get materials(): Material[];
  27110. /**
  27111. * Sets the SPS MultiMaterial from the passed materials.
  27112. * Note : the passed array is internally copied and not used then by reference.
  27113. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27114. */
  27115. setMultiMaterial(materials: Material[]): void;
  27116. /**
  27117. * The SPS computed multimaterial object
  27118. */
  27119. get multimaterial(): MultiMaterial;
  27120. set multimaterial(mm: MultiMaterial);
  27121. /**
  27122. * If the subMeshes must be updated on the next call to setParticles()
  27123. */
  27124. get autoUpdateSubMeshes(): boolean;
  27125. set autoUpdateSubMeshes(val: boolean);
  27126. /**
  27127. * This function does nothing. It may be overwritten to set all the particle first values.
  27128. * The SPS doesn't call this function, you may have to call it by your own.
  27129. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27130. */
  27131. initParticles(): void;
  27132. /**
  27133. * This function does nothing. It may be overwritten to recycle a particle.
  27134. * The SPS doesn't call this function, you may have to call it by your own.
  27135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27136. * @param particle The particle to recycle
  27137. * @returns the recycled particle
  27138. */
  27139. recycleParticle(particle: SolidParticle): SolidParticle;
  27140. /**
  27141. * Updates a particle : this function should be overwritten by the user.
  27142. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27143. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27144. * @example : just set a particle position or velocity and recycle conditions
  27145. * @param particle The particle to update
  27146. * @returns the updated particle
  27147. */
  27148. updateParticle(particle: SolidParticle): SolidParticle;
  27149. /**
  27150. * Updates a vertex of a particle : it can be overwritten by the user.
  27151. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27152. * @param particle the current particle
  27153. * @param vertex the current index of the current particle
  27154. * @param pt the index of the current vertex in the particle shape
  27155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27156. * @example : just set a vertex particle position
  27157. * @returns the updated vertex
  27158. */
  27159. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27160. /**
  27161. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27162. * This does nothing and may be overwritten by the user.
  27163. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27164. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27165. * @param update the boolean update value actually passed to setParticles()
  27166. */
  27167. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27168. /**
  27169. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27170. * This will be passed three parameters.
  27171. * This does nothing and may be overwritten by the user.
  27172. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27173. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27174. * @param update the boolean update value actually passed to setParticles()
  27175. */
  27176. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27177. }
  27178. }
  27179. declare module BABYLON {
  27180. /**
  27181. * Represents one particle of a solid particle system.
  27182. */
  27183. export class SolidParticle {
  27184. /**
  27185. * particle global index
  27186. */
  27187. idx: number;
  27188. /**
  27189. * particle identifier
  27190. */
  27191. id: number;
  27192. /**
  27193. * The color of the particle
  27194. */
  27195. color: Nullable<Color4>;
  27196. /**
  27197. * The world space position of the particle.
  27198. */
  27199. position: Vector3;
  27200. /**
  27201. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27202. */
  27203. rotation: Vector3;
  27204. /**
  27205. * The world space rotation quaternion of the particle.
  27206. */
  27207. rotationQuaternion: Nullable<Quaternion>;
  27208. /**
  27209. * The scaling of the particle.
  27210. */
  27211. scaling: Vector3;
  27212. /**
  27213. * The uvs of the particle.
  27214. */
  27215. uvs: Vector4;
  27216. /**
  27217. * The current speed of the particle.
  27218. */
  27219. velocity: Vector3;
  27220. /**
  27221. * The pivot point in the particle local space.
  27222. */
  27223. pivot: Vector3;
  27224. /**
  27225. * Must the particle be translated from its pivot point in its local space ?
  27226. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27227. * Default : false
  27228. */
  27229. translateFromPivot: boolean;
  27230. /**
  27231. * Is the particle active or not ?
  27232. */
  27233. alive: boolean;
  27234. /**
  27235. * Is the particle visible or not ?
  27236. */
  27237. isVisible: boolean;
  27238. /**
  27239. * Index of this particle in the global "positions" array (Internal use)
  27240. * @hidden
  27241. */
  27242. _pos: number;
  27243. /**
  27244. * @hidden Index of this particle in the global "indices" array (Internal use)
  27245. */
  27246. _ind: number;
  27247. /**
  27248. * @hidden ModelShape of this particle (Internal use)
  27249. */
  27250. _model: ModelShape;
  27251. /**
  27252. * ModelShape id of this particle
  27253. */
  27254. shapeId: number;
  27255. /**
  27256. * Index of the particle in its shape id
  27257. */
  27258. idxInShape: number;
  27259. /**
  27260. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27261. */
  27262. _modelBoundingInfo: BoundingInfo;
  27263. /**
  27264. * @hidden Particle BoundingInfo object (Internal use)
  27265. */
  27266. _boundingInfo: BoundingInfo;
  27267. /**
  27268. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27269. */
  27270. _sps: SolidParticleSystem;
  27271. /**
  27272. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27273. */
  27274. _stillInvisible: boolean;
  27275. /**
  27276. * @hidden Last computed particle rotation matrix
  27277. */
  27278. _rotationMatrix: number[];
  27279. /**
  27280. * Parent particle Id, if any.
  27281. * Default null.
  27282. */
  27283. parentId: Nullable<number>;
  27284. /**
  27285. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27286. */
  27287. materialIndex: Nullable<number>;
  27288. /**
  27289. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27290. * The possible values are :
  27291. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27292. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27294. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27295. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27296. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27297. * */
  27298. cullingStrategy: number;
  27299. /**
  27300. * @hidden Internal global position in the SPS.
  27301. */
  27302. _globalPosition: Vector3;
  27303. /**
  27304. * Creates a Solid Particle object.
  27305. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27306. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27307. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27308. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27309. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27310. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27311. * @param shapeId (integer) is the model shape identifier in the SPS.
  27312. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27313. * @param sps defines the sps it is associated to
  27314. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27315. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27316. */
  27317. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27318. /**
  27319. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27320. * @param target the particle target
  27321. * @returns the current particle
  27322. */
  27323. copyToRef(target: SolidParticle): SolidParticle;
  27324. /**
  27325. * Legacy support, changed scale to scaling
  27326. */
  27327. get scale(): Vector3;
  27328. /**
  27329. * Legacy support, changed scale to scaling
  27330. */
  27331. set scale(scale: Vector3);
  27332. /**
  27333. * Legacy support, changed quaternion to rotationQuaternion
  27334. */
  27335. get quaternion(): Nullable<Quaternion>;
  27336. /**
  27337. * Legacy support, changed quaternion to rotationQuaternion
  27338. */
  27339. set quaternion(q: Nullable<Quaternion>);
  27340. /**
  27341. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27342. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27343. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27344. * @returns true if it intersects
  27345. */
  27346. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27347. /**
  27348. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27349. * A particle is in the frustum if its bounding box intersects the frustum
  27350. * @param frustumPlanes defines the frustum to test
  27351. * @returns true if the particle is in the frustum planes
  27352. */
  27353. isInFrustum(frustumPlanes: Plane[]): boolean;
  27354. /**
  27355. * get the rotation matrix of the particle
  27356. * @hidden
  27357. */
  27358. getRotationMatrix(m: Matrix): void;
  27359. }
  27360. /**
  27361. * Represents the shape of the model used by one particle of a solid particle system.
  27362. * SPS internal tool, don't use it manually.
  27363. */
  27364. export class ModelShape {
  27365. /**
  27366. * The shape id
  27367. * @hidden
  27368. */
  27369. shapeID: number;
  27370. /**
  27371. * flat array of model positions (internal use)
  27372. * @hidden
  27373. */
  27374. _shape: Vector3[];
  27375. /**
  27376. * flat array of model UVs (internal use)
  27377. * @hidden
  27378. */
  27379. _shapeUV: number[];
  27380. /**
  27381. * color array of the model
  27382. * @hidden
  27383. */
  27384. _shapeColors: number[];
  27385. /**
  27386. * indices array of the model
  27387. * @hidden
  27388. */
  27389. _indices: number[];
  27390. /**
  27391. * normals array of the model
  27392. * @hidden
  27393. */
  27394. _normals: number[];
  27395. /**
  27396. * length of the shape in the model indices array (internal use)
  27397. * @hidden
  27398. */
  27399. _indicesLength: number;
  27400. /**
  27401. * Custom position function (internal use)
  27402. * @hidden
  27403. */
  27404. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27405. /**
  27406. * Custom vertex function (internal use)
  27407. * @hidden
  27408. */
  27409. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27410. /**
  27411. * Model material (internal use)
  27412. * @hidden
  27413. */
  27414. _material: Nullable<Material>;
  27415. /**
  27416. * 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.
  27417. * SPS internal tool, don't use it manually.
  27418. * @hidden
  27419. */
  27420. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27421. }
  27422. /**
  27423. * Represents a Depth Sorted Particle in the solid particle system.
  27424. * @hidden
  27425. */
  27426. export class DepthSortedParticle {
  27427. /**
  27428. * Index of the particle in the "indices" array
  27429. */
  27430. ind: number;
  27431. /**
  27432. * Length of the particle shape in the "indices" array
  27433. */
  27434. indicesLength: number;
  27435. /**
  27436. * Squared distance from the particle to the camera
  27437. */
  27438. sqDistance: number;
  27439. /**
  27440. * Material index when used with MultiMaterials
  27441. */
  27442. materialIndex: number;
  27443. /**
  27444. * Creates a new sorted particle
  27445. * @param materialIndex
  27446. */
  27447. constructor(ind: number, indLength: number, materialIndex: number);
  27448. }
  27449. }
  27450. declare module BABYLON {
  27451. /**
  27452. * @hidden
  27453. */
  27454. export class _MeshCollisionData {
  27455. _checkCollisions: boolean;
  27456. _collisionMask: number;
  27457. _collisionGroup: number;
  27458. _collider: Nullable<Collider>;
  27459. _oldPositionForCollisions: Vector3;
  27460. _diffPositionForCollisions: Vector3;
  27461. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27462. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27463. }
  27464. }
  27465. declare module BABYLON {
  27466. /** @hidden */
  27467. class _FacetDataStorage {
  27468. facetPositions: Vector3[];
  27469. facetNormals: Vector3[];
  27470. facetPartitioning: number[][];
  27471. facetNb: number;
  27472. partitioningSubdivisions: number;
  27473. partitioningBBoxRatio: number;
  27474. facetDataEnabled: boolean;
  27475. facetParameters: any;
  27476. bbSize: Vector3;
  27477. subDiv: {
  27478. max: number;
  27479. X: number;
  27480. Y: number;
  27481. Z: number;
  27482. };
  27483. facetDepthSort: boolean;
  27484. facetDepthSortEnabled: boolean;
  27485. depthSortedIndices: IndicesArray;
  27486. depthSortedFacets: {
  27487. ind: number;
  27488. sqDistance: number;
  27489. }[];
  27490. facetDepthSortFunction: (f1: {
  27491. ind: number;
  27492. sqDistance: number;
  27493. }, f2: {
  27494. ind: number;
  27495. sqDistance: number;
  27496. }) => number;
  27497. facetDepthSortFrom: Vector3;
  27498. facetDepthSortOrigin: Vector3;
  27499. invertedMatrix: Matrix;
  27500. }
  27501. /**
  27502. * @hidden
  27503. **/
  27504. class _InternalAbstractMeshDataInfo {
  27505. _hasVertexAlpha: boolean;
  27506. _useVertexColors: boolean;
  27507. _numBoneInfluencers: number;
  27508. _applyFog: boolean;
  27509. _receiveShadows: boolean;
  27510. _facetData: _FacetDataStorage;
  27511. _visibility: number;
  27512. _skeleton: Nullable<Skeleton>;
  27513. _layerMask: number;
  27514. _computeBonesUsingShaders: boolean;
  27515. _isActive: boolean;
  27516. _onlyForInstances: boolean;
  27517. _isActiveIntermediate: boolean;
  27518. _onlyForInstancesIntermediate: boolean;
  27519. _actAsRegularMesh: boolean;
  27520. }
  27521. /**
  27522. * Class used to store all common mesh properties
  27523. */
  27524. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27525. /** No occlusion */
  27526. static OCCLUSION_TYPE_NONE: number;
  27527. /** Occlusion set to optimisitic */
  27528. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27529. /** Occlusion set to strict */
  27530. static OCCLUSION_TYPE_STRICT: number;
  27531. /** Use an accurante occlusion algorithm */
  27532. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27533. /** Use a conservative occlusion algorithm */
  27534. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27535. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27536. * Test order :
  27537. * Is the bounding sphere outside the frustum ?
  27538. * If not, are the bounding box vertices outside the frustum ?
  27539. * It not, then the cullable object is in the frustum.
  27540. */
  27541. static readonly CULLINGSTRATEGY_STANDARD: number;
  27542. /** Culling strategy : Bounding Sphere Only.
  27543. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27544. * It's also less accurate than the standard because some not visible objects can still be selected.
  27545. * Test : is the bounding sphere outside the frustum ?
  27546. * If not, then the cullable object is in the frustum.
  27547. */
  27548. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27549. /** Culling strategy : Optimistic Inclusion.
  27550. * This in an inclusion test first, then the standard exclusion test.
  27551. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27552. * 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.
  27553. * Anyway, it's as accurate as the standard strategy.
  27554. * Test :
  27555. * Is the cullable object bounding sphere center in the frustum ?
  27556. * If not, apply the default culling strategy.
  27557. */
  27558. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27559. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27560. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27561. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27562. * 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.
  27563. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27564. * Test :
  27565. * Is the cullable object bounding sphere center in the frustum ?
  27566. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27567. */
  27568. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27569. /**
  27570. * No billboard
  27571. */
  27572. static get BILLBOARDMODE_NONE(): number;
  27573. /** Billboard on X axis */
  27574. static get BILLBOARDMODE_X(): number;
  27575. /** Billboard on Y axis */
  27576. static get BILLBOARDMODE_Y(): number;
  27577. /** Billboard on Z axis */
  27578. static get BILLBOARDMODE_Z(): number;
  27579. /** Billboard on all axes */
  27580. static get BILLBOARDMODE_ALL(): number;
  27581. /** Billboard on using position instead of orientation */
  27582. static get BILLBOARDMODE_USE_POSITION(): number;
  27583. /** @hidden */
  27584. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27585. /**
  27586. * The culling strategy to use to check whether the mesh must be rendered or not.
  27587. * This value can be changed at any time and will be used on the next render mesh selection.
  27588. * The possible values are :
  27589. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27590. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27591. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27592. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27593. * Please read each static variable documentation to get details about the culling process.
  27594. * */
  27595. cullingStrategy: number;
  27596. /**
  27597. * Gets the number of facets in the mesh
  27598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27599. */
  27600. get facetNb(): number;
  27601. /**
  27602. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27604. */
  27605. get partitioningSubdivisions(): number;
  27606. set partitioningSubdivisions(nb: number);
  27607. /**
  27608. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27609. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27611. */
  27612. get partitioningBBoxRatio(): number;
  27613. set partitioningBBoxRatio(ratio: number);
  27614. /**
  27615. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27616. * Works only for updatable meshes.
  27617. * Doesn't work with multi-materials
  27618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27619. */
  27620. get mustDepthSortFacets(): boolean;
  27621. set mustDepthSortFacets(sort: boolean);
  27622. /**
  27623. * The location (Vector3) where the facet depth sort must be computed from.
  27624. * By default, the active camera position.
  27625. * Used only when facet depth sort is enabled
  27626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27627. */
  27628. get facetDepthSortFrom(): Vector3;
  27629. set facetDepthSortFrom(location: Vector3);
  27630. /**
  27631. * gets a boolean indicating if facetData is enabled
  27632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27633. */
  27634. get isFacetDataEnabled(): boolean;
  27635. /** @hidden */
  27636. _updateNonUniformScalingState(value: boolean): boolean;
  27637. /**
  27638. * An event triggered when this mesh collides with another one
  27639. */
  27640. onCollideObservable: Observable<AbstractMesh>;
  27641. /** Set a function to call when this mesh collides with another one */
  27642. set onCollide(callback: () => void);
  27643. /**
  27644. * An event triggered when the collision's position changes
  27645. */
  27646. onCollisionPositionChangeObservable: Observable<Vector3>;
  27647. /** Set a function to call when the collision's position changes */
  27648. set onCollisionPositionChange(callback: () => void);
  27649. /**
  27650. * An event triggered when material is changed
  27651. */
  27652. onMaterialChangedObservable: Observable<AbstractMesh>;
  27653. /**
  27654. * Gets or sets the orientation for POV movement & rotation
  27655. */
  27656. definedFacingForward: boolean;
  27657. /** @hidden */
  27658. _occlusionQuery: Nullable<WebGLQuery>;
  27659. /** @hidden */
  27660. _renderingGroup: Nullable<RenderingGroup>;
  27661. /**
  27662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27663. */
  27664. get visibility(): number;
  27665. /**
  27666. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27667. */
  27668. set visibility(value: number);
  27669. /** Gets or sets the alpha index used to sort transparent meshes
  27670. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27671. */
  27672. alphaIndex: number;
  27673. /**
  27674. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27675. */
  27676. isVisible: boolean;
  27677. /**
  27678. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27679. */
  27680. isPickable: boolean;
  27681. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27682. showSubMeshesBoundingBox: boolean;
  27683. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27685. */
  27686. isBlocker: boolean;
  27687. /**
  27688. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27689. */
  27690. enablePointerMoveEvents: boolean;
  27691. /**
  27692. * Specifies the rendering group id for this mesh (0 by default)
  27693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27694. */
  27695. renderingGroupId: number;
  27696. private _material;
  27697. /** Gets or sets current material */
  27698. get material(): Nullable<Material>;
  27699. set material(value: Nullable<Material>);
  27700. /**
  27701. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27702. * @see http://doc.babylonjs.com/babylon101/shadows
  27703. */
  27704. get receiveShadows(): boolean;
  27705. set receiveShadows(value: boolean);
  27706. /** Defines color to use when rendering outline */
  27707. outlineColor: Color3;
  27708. /** Define width to use when rendering outline */
  27709. outlineWidth: number;
  27710. /** Defines color to use when rendering overlay */
  27711. overlayColor: Color3;
  27712. /** Defines alpha to use when rendering overlay */
  27713. overlayAlpha: number;
  27714. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27715. get hasVertexAlpha(): boolean;
  27716. set hasVertexAlpha(value: boolean);
  27717. /** 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) */
  27718. get useVertexColors(): boolean;
  27719. set useVertexColors(value: boolean);
  27720. /**
  27721. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27722. */
  27723. get computeBonesUsingShaders(): boolean;
  27724. set computeBonesUsingShaders(value: boolean);
  27725. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27726. get numBoneInfluencers(): number;
  27727. set numBoneInfluencers(value: number);
  27728. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27729. get applyFog(): boolean;
  27730. set applyFog(value: boolean);
  27731. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27732. useOctreeForRenderingSelection: boolean;
  27733. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27734. useOctreeForPicking: boolean;
  27735. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27736. useOctreeForCollisions: boolean;
  27737. /**
  27738. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27739. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27740. */
  27741. get layerMask(): number;
  27742. set layerMask(value: number);
  27743. /**
  27744. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27745. */
  27746. alwaysSelectAsActiveMesh: boolean;
  27747. /**
  27748. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27749. */
  27750. doNotSyncBoundingInfo: boolean;
  27751. /**
  27752. * Gets or sets the current action manager
  27753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27754. */
  27755. actionManager: Nullable<AbstractActionManager>;
  27756. private _meshCollisionData;
  27757. /**
  27758. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27760. */
  27761. ellipsoid: Vector3;
  27762. /**
  27763. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27765. */
  27766. ellipsoidOffset: Vector3;
  27767. /**
  27768. * Gets or sets a collision mask used to mask collisions (default is -1).
  27769. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27770. */
  27771. get collisionMask(): number;
  27772. set collisionMask(mask: number);
  27773. /**
  27774. * Gets or sets the current collision group mask (-1 by default).
  27775. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27776. */
  27777. get collisionGroup(): number;
  27778. set collisionGroup(mask: number);
  27779. /**
  27780. * Defines edge width used when edgesRenderer is enabled
  27781. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27782. */
  27783. edgesWidth: number;
  27784. /**
  27785. * Defines edge color used when edgesRenderer is enabled
  27786. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27787. */
  27788. edgesColor: Color4;
  27789. /** @hidden */
  27790. _edgesRenderer: Nullable<IEdgesRenderer>;
  27791. /** @hidden */
  27792. _masterMesh: Nullable<AbstractMesh>;
  27793. /** @hidden */
  27794. _boundingInfo: Nullable<BoundingInfo>;
  27795. /** @hidden */
  27796. _renderId: number;
  27797. /**
  27798. * Gets or sets the list of subMeshes
  27799. * @see http://doc.babylonjs.com/how_to/multi_materials
  27800. */
  27801. subMeshes: SubMesh[];
  27802. /** @hidden */
  27803. _intersectionsInProgress: AbstractMesh[];
  27804. /** @hidden */
  27805. _unIndexed: boolean;
  27806. /** @hidden */
  27807. _lightSources: Light[];
  27808. /** Gets the list of lights affecting that mesh */
  27809. get lightSources(): Light[];
  27810. /** @hidden */
  27811. get _positions(): Nullable<Vector3[]>;
  27812. /** @hidden */
  27813. _waitingData: {
  27814. lods: Nullable<any>;
  27815. actions: Nullable<any>;
  27816. freezeWorldMatrix: Nullable<boolean>;
  27817. };
  27818. /** @hidden */
  27819. _bonesTransformMatrices: Nullable<Float32Array>;
  27820. /** @hidden */
  27821. _transformMatrixTexture: Nullable<RawTexture>;
  27822. /**
  27823. * Gets or sets a skeleton to apply skining transformations
  27824. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27825. */
  27826. set skeleton(value: Nullable<Skeleton>);
  27827. get skeleton(): Nullable<Skeleton>;
  27828. /**
  27829. * An event triggered when the mesh is rebuilt.
  27830. */
  27831. onRebuildObservable: Observable<AbstractMesh>;
  27832. /**
  27833. * Creates a new AbstractMesh
  27834. * @param name defines the name of the mesh
  27835. * @param scene defines the hosting scene
  27836. */
  27837. constructor(name: string, scene?: Nullable<Scene>);
  27838. /**
  27839. * Returns the string "AbstractMesh"
  27840. * @returns "AbstractMesh"
  27841. */
  27842. getClassName(): string;
  27843. /**
  27844. * Gets a string representation of the current mesh
  27845. * @param fullDetails defines a boolean indicating if full details must be included
  27846. * @returns a string representation of the current mesh
  27847. */
  27848. toString(fullDetails?: boolean): string;
  27849. /**
  27850. * @hidden
  27851. */
  27852. protected _getEffectiveParent(): Nullable<Node>;
  27853. /** @hidden */
  27854. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27855. /** @hidden */
  27856. _rebuild(): void;
  27857. /** @hidden */
  27858. _resyncLightSources(): void;
  27859. /** @hidden */
  27860. _resyncLightSource(light: Light): void;
  27861. /** @hidden */
  27862. _unBindEffect(): void;
  27863. /** @hidden */
  27864. _removeLightSource(light: Light, dispose: boolean): void;
  27865. private _markSubMeshesAsDirty;
  27866. /** @hidden */
  27867. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27868. /** @hidden */
  27869. _markSubMeshesAsAttributesDirty(): void;
  27870. /** @hidden */
  27871. _markSubMeshesAsMiscDirty(): void;
  27872. /**
  27873. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27874. */
  27875. get scaling(): Vector3;
  27876. set scaling(newScaling: Vector3);
  27877. /**
  27878. * Returns true if the mesh is blocked. Implemented by child classes
  27879. */
  27880. get isBlocked(): boolean;
  27881. /**
  27882. * Returns the mesh itself by default. Implemented by child classes
  27883. * @param camera defines the camera to use to pick the right LOD level
  27884. * @returns the currentAbstractMesh
  27885. */
  27886. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27887. /**
  27888. * Returns 0 by default. Implemented by child classes
  27889. * @returns an integer
  27890. */
  27891. getTotalVertices(): number;
  27892. /**
  27893. * Returns a positive integer : the total number of indices in this mesh geometry.
  27894. * @returns the numner of indices or zero if the mesh has no geometry.
  27895. */
  27896. getTotalIndices(): number;
  27897. /**
  27898. * Returns null by default. Implemented by child classes
  27899. * @returns null
  27900. */
  27901. getIndices(): Nullable<IndicesArray>;
  27902. /**
  27903. * Returns the array of the requested vertex data kind. Implemented by child classes
  27904. * @param kind defines the vertex data kind to use
  27905. * @returns null
  27906. */
  27907. getVerticesData(kind: string): Nullable<FloatArray>;
  27908. /**
  27909. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27910. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27911. * Note that a new underlying VertexBuffer object is created each call.
  27912. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27913. * @param kind defines vertex data kind:
  27914. * * VertexBuffer.PositionKind
  27915. * * VertexBuffer.UVKind
  27916. * * VertexBuffer.UV2Kind
  27917. * * VertexBuffer.UV3Kind
  27918. * * VertexBuffer.UV4Kind
  27919. * * VertexBuffer.UV5Kind
  27920. * * VertexBuffer.UV6Kind
  27921. * * VertexBuffer.ColorKind
  27922. * * VertexBuffer.MatricesIndicesKind
  27923. * * VertexBuffer.MatricesIndicesExtraKind
  27924. * * VertexBuffer.MatricesWeightsKind
  27925. * * VertexBuffer.MatricesWeightsExtraKind
  27926. * @param data defines the data source
  27927. * @param updatable defines if the data must be flagged as updatable (or static)
  27928. * @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
  27929. * @returns the current mesh
  27930. */
  27931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27932. /**
  27933. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27934. * If the mesh has no geometry, it is simply returned as it is.
  27935. * @param kind defines vertex data kind:
  27936. * * VertexBuffer.PositionKind
  27937. * * VertexBuffer.UVKind
  27938. * * VertexBuffer.UV2Kind
  27939. * * VertexBuffer.UV3Kind
  27940. * * VertexBuffer.UV4Kind
  27941. * * VertexBuffer.UV5Kind
  27942. * * VertexBuffer.UV6Kind
  27943. * * VertexBuffer.ColorKind
  27944. * * VertexBuffer.MatricesIndicesKind
  27945. * * VertexBuffer.MatricesIndicesExtraKind
  27946. * * VertexBuffer.MatricesWeightsKind
  27947. * * VertexBuffer.MatricesWeightsExtraKind
  27948. * @param data defines the data source
  27949. * @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
  27950. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27951. * @returns the current mesh
  27952. */
  27953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27954. /**
  27955. * Sets the mesh indices,
  27956. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27957. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27958. * @param totalVertices Defines the total number of vertices
  27959. * @returns the current mesh
  27960. */
  27961. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27962. /**
  27963. * Gets a boolean indicating if specific vertex data is present
  27964. * @param kind defines the vertex data kind to use
  27965. * @returns true is data kind is present
  27966. */
  27967. isVerticesDataPresent(kind: string): boolean;
  27968. /**
  27969. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27970. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27971. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27972. * @returns a BoundingInfo
  27973. */
  27974. getBoundingInfo(): BoundingInfo;
  27975. /**
  27976. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27977. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27978. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27979. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27980. * @returns the current mesh
  27981. */
  27982. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27983. /**
  27984. * Overwrite the current bounding info
  27985. * @param boundingInfo defines the new bounding info
  27986. * @returns the current mesh
  27987. */
  27988. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27989. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27990. get useBones(): boolean;
  27991. /** @hidden */
  27992. _preActivate(): void;
  27993. /** @hidden */
  27994. _preActivateForIntermediateRendering(renderId: number): void;
  27995. /** @hidden */
  27996. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27997. /** @hidden */
  27998. _postActivate(): void;
  27999. /** @hidden */
  28000. _freeze(): void;
  28001. /** @hidden */
  28002. _unFreeze(): void;
  28003. /**
  28004. * Gets the current world matrix
  28005. * @returns a Matrix
  28006. */
  28007. getWorldMatrix(): Matrix;
  28008. /** @hidden */
  28009. _getWorldMatrixDeterminant(): number;
  28010. /**
  28011. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28012. */
  28013. get isAnInstance(): boolean;
  28014. /**
  28015. * Gets a boolean indicating if this mesh has instances
  28016. */
  28017. get hasInstances(): boolean;
  28018. /**
  28019. * Perform relative position change from the point of view of behind the front of the mesh.
  28020. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28021. * Supports definition of mesh facing forward or backward
  28022. * @param amountRight defines the distance on the right axis
  28023. * @param amountUp defines the distance on the up axis
  28024. * @param amountForward defines the distance on the forward axis
  28025. * @returns the current mesh
  28026. */
  28027. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28028. /**
  28029. * Calculate relative position change from the point of view of behind the front of the mesh.
  28030. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28031. * Supports definition of mesh facing forward or backward
  28032. * @param amountRight defines the distance on the right axis
  28033. * @param amountUp defines the distance on the up axis
  28034. * @param amountForward defines the distance on the forward axis
  28035. * @returns the new displacement vector
  28036. */
  28037. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28038. /**
  28039. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28040. * Supports definition of mesh facing forward or backward
  28041. * @param flipBack defines the flip
  28042. * @param twirlClockwise defines the twirl
  28043. * @param tiltRight defines the tilt
  28044. * @returns the current mesh
  28045. */
  28046. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28047. /**
  28048. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28049. * Supports definition of mesh facing forward or backward.
  28050. * @param flipBack defines the flip
  28051. * @param twirlClockwise defines the twirl
  28052. * @param tiltRight defines the tilt
  28053. * @returns the new rotation vector
  28054. */
  28055. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28056. /**
  28057. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28058. * This means the mesh underlying bounding box and sphere are recomputed.
  28059. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28060. * @returns the current mesh
  28061. */
  28062. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28063. /** @hidden */
  28064. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28065. /** @hidden */
  28066. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28067. /** @hidden */
  28068. _updateBoundingInfo(): AbstractMesh;
  28069. /** @hidden */
  28070. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28071. /** @hidden */
  28072. protected _afterComputeWorldMatrix(): void;
  28073. /** @hidden */
  28074. get _effectiveMesh(): AbstractMesh;
  28075. /**
  28076. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28077. * A mesh is in the frustum if its bounding box intersects the frustum
  28078. * @param frustumPlanes defines the frustum to test
  28079. * @returns true if the mesh is in the frustum planes
  28080. */
  28081. isInFrustum(frustumPlanes: Plane[]): boolean;
  28082. /**
  28083. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28084. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28085. * @param frustumPlanes defines the frustum to test
  28086. * @returns true if the mesh is completely in the frustum planes
  28087. */
  28088. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28089. /**
  28090. * True if the mesh intersects another mesh or a SolidParticle object
  28091. * @param mesh defines a target mesh or SolidParticle to test
  28092. * @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)
  28093. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28094. * @returns true if there is an intersection
  28095. */
  28096. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28097. /**
  28098. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28099. * @param point defines the point to test
  28100. * @returns true if there is an intersection
  28101. */
  28102. intersectsPoint(point: Vector3): boolean;
  28103. /**
  28104. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28106. */
  28107. get checkCollisions(): boolean;
  28108. set checkCollisions(collisionEnabled: boolean);
  28109. /**
  28110. * Gets Collider object used to compute collisions (not physics)
  28111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28112. */
  28113. get collider(): Nullable<Collider>;
  28114. /**
  28115. * Move the mesh using collision engine
  28116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28117. * @param displacement defines the requested displacement vector
  28118. * @returns the current mesh
  28119. */
  28120. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28121. private _onCollisionPositionChange;
  28122. /** @hidden */
  28123. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28124. /** @hidden */
  28125. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28126. /** @hidden */
  28127. _checkCollision(collider: Collider): AbstractMesh;
  28128. /** @hidden */
  28129. _generatePointsArray(): boolean;
  28130. /**
  28131. * Checks if the passed Ray intersects with the mesh
  28132. * @param ray defines the ray to use
  28133. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28135. * @returns the picking info
  28136. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28137. */
  28138. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28139. /**
  28140. * Clones the current mesh
  28141. * @param name defines the mesh name
  28142. * @param newParent defines the new mesh parent
  28143. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28144. * @returns the new mesh
  28145. */
  28146. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28147. /**
  28148. * Disposes all the submeshes of the current meshnp
  28149. * @returns the current mesh
  28150. */
  28151. releaseSubMeshes(): AbstractMesh;
  28152. /**
  28153. * Releases resources associated with this abstract mesh.
  28154. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28155. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28156. */
  28157. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28158. /**
  28159. * Adds the passed mesh as a child to the current mesh
  28160. * @param mesh defines the child mesh
  28161. * @returns the current mesh
  28162. */
  28163. addChild(mesh: AbstractMesh): AbstractMesh;
  28164. /**
  28165. * Removes the passed mesh from the current mesh children list
  28166. * @param mesh defines the child mesh
  28167. * @returns the current mesh
  28168. */
  28169. removeChild(mesh: AbstractMesh): AbstractMesh;
  28170. /** @hidden */
  28171. private _initFacetData;
  28172. /**
  28173. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28174. * This method can be called within the render loop.
  28175. * 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
  28176. * @returns the current mesh
  28177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28178. */
  28179. updateFacetData(): AbstractMesh;
  28180. /**
  28181. * Returns the facetLocalNormals array.
  28182. * The normals are expressed in the mesh local spac
  28183. * @returns an array of Vector3
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28185. */
  28186. getFacetLocalNormals(): Vector3[];
  28187. /**
  28188. * Returns the facetLocalPositions array.
  28189. * The facet positions are expressed in the mesh local space
  28190. * @returns an array of Vector3
  28191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28192. */
  28193. getFacetLocalPositions(): Vector3[];
  28194. /**
  28195. * Returns the facetLocalPartioning array
  28196. * @returns an array of array of numbers
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28198. */
  28199. getFacetLocalPartitioning(): number[][];
  28200. /**
  28201. * Returns the i-th facet position in the world system.
  28202. * This method allocates a new Vector3 per call
  28203. * @param i defines the facet index
  28204. * @returns a new Vector3
  28205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28206. */
  28207. getFacetPosition(i: number): Vector3;
  28208. /**
  28209. * Sets the reference Vector3 with the i-th facet position in the world system
  28210. * @param i defines the facet index
  28211. * @param ref defines the target vector
  28212. * @returns the current mesh
  28213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28214. */
  28215. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28216. /**
  28217. * Returns the i-th facet normal in the world system.
  28218. * This method allocates a new Vector3 per call
  28219. * @param i defines the facet index
  28220. * @returns a new Vector3
  28221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28222. */
  28223. getFacetNormal(i: number): Vector3;
  28224. /**
  28225. * Sets the reference Vector3 with the i-th facet normal in the world system
  28226. * @param i defines the facet index
  28227. * @param ref defines the target vector
  28228. * @returns the current mesh
  28229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28230. */
  28231. getFacetNormalToRef(i: number, ref: Vector3): this;
  28232. /**
  28233. * 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)
  28234. * @param x defines x coordinate
  28235. * @param y defines y coordinate
  28236. * @param z defines z coordinate
  28237. * @returns the array of facet indexes
  28238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28239. */
  28240. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28241. /**
  28242. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28243. * @param projected sets as the (x,y,z) world projection on the facet
  28244. * @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
  28245. * @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
  28246. * @param x defines x coordinate
  28247. * @param y defines y coordinate
  28248. * @param z defines z coordinate
  28249. * @returns the face index if found (or null instead)
  28250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28251. */
  28252. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28253. /**
  28254. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28255. * @param projected sets as the (x,y,z) local projection on the facet
  28256. * @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
  28257. * @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
  28258. * @param x defines x coordinate
  28259. * @param y defines y coordinate
  28260. * @param z defines z coordinate
  28261. * @returns the face index if found (or null instead)
  28262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28263. */
  28264. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28265. /**
  28266. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28267. * @returns the parameters
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28269. */
  28270. getFacetDataParameters(): any;
  28271. /**
  28272. * Disables the feature FacetData and frees the related memory
  28273. * @returns the current mesh
  28274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28275. */
  28276. disableFacetData(): AbstractMesh;
  28277. /**
  28278. * Updates the AbstractMesh indices array
  28279. * @param indices defines the data source
  28280. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28281. * @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)
  28282. * @returns the current mesh
  28283. */
  28284. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28285. /**
  28286. * Creates new normals data for the mesh
  28287. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28288. * @returns the current mesh
  28289. */
  28290. createNormals(updatable: boolean): AbstractMesh;
  28291. /**
  28292. * Align the mesh with a normal
  28293. * @param normal defines the normal to use
  28294. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28295. * @returns the current mesh
  28296. */
  28297. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28298. /** @hidden */
  28299. _checkOcclusionQuery(): boolean;
  28300. /**
  28301. * Disables the mesh edge rendering mode
  28302. * @returns the currentAbstractMesh
  28303. */
  28304. disableEdgesRendering(): AbstractMesh;
  28305. /**
  28306. * Enables the edge rendering mode on the mesh.
  28307. * This mode makes the mesh edges visible
  28308. * @param epsilon defines the maximal distance between two angles to detect a face
  28309. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28310. * @returns the currentAbstractMesh
  28311. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28312. */
  28313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28314. }
  28315. }
  28316. declare module BABYLON {
  28317. /**
  28318. * Interface used to define ActionEvent
  28319. */
  28320. export interface IActionEvent {
  28321. /** The mesh or sprite that triggered the action */
  28322. source: any;
  28323. /** The X mouse cursor position at the time of the event */
  28324. pointerX: number;
  28325. /** The Y mouse cursor position at the time of the event */
  28326. pointerY: number;
  28327. /** The mesh that is currently pointed at (can be null) */
  28328. meshUnderPointer: Nullable<AbstractMesh>;
  28329. /** the original (browser) event that triggered the ActionEvent */
  28330. sourceEvent?: any;
  28331. /** additional data for the event */
  28332. additionalData?: any;
  28333. }
  28334. /**
  28335. * ActionEvent is the event being sent when an action is triggered.
  28336. */
  28337. export class ActionEvent implements IActionEvent {
  28338. /** The mesh or sprite that triggered the action */
  28339. source: any;
  28340. /** The X mouse cursor position at the time of the event */
  28341. pointerX: number;
  28342. /** The Y mouse cursor position at the time of the event */
  28343. pointerY: number;
  28344. /** The mesh that is currently pointed at (can be null) */
  28345. meshUnderPointer: Nullable<AbstractMesh>;
  28346. /** the original (browser) event that triggered the ActionEvent */
  28347. sourceEvent?: any;
  28348. /** additional data for the event */
  28349. additionalData?: any;
  28350. /**
  28351. * Creates a new ActionEvent
  28352. * @param source The mesh or sprite that triggered the action
  28353. * @param pointerX The X mouse cursor position at the time of the event
  28354. * @param pointerY The Y mouse cursor position at the time of the event
  28355. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28356. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28357. * @param additionalData additional data for the event
  28358. */
  28359. constructor(
  28360. /** The mesh or sprite that triggered the action */
  28361. source: any,
  28362. /** The X mouse cursor position at the time of the event */
  28363. pointerX: number,
  28364. /** The Y mouse cursor position at the time of the event */
  28365. pointerY: number,
  28366. /** The mesh that is currently pointed at (can be null) */
  28367. meshUnderPointer: Nullable<AbstractMesh>,
  28368. /** the original (browser) event that triggered the ActionEvent */
  28369. sourceEvent?: any,
  28370. /** additional data for the event */
  28371. additionalData?: any);
  28372. /**
  28373. * Helper function to auto-create an ActionEvent from a source mesh.
  28374. * @param source The source mesh that triggered the event
  28375. * @param evt The original (browser) event
  28376. * @param additionalData additional data for the event
  28377. * @returns the new ActionEvent
  28378. */
  28379. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28380. /**
  28381. * Helper function to auto-create an ActionEvent from a source sprite
  28382. * @param source The source sprite that triggered the event
  28383. * @param scene Scene associated with the sprite
  28384. * @param evt The original (browser) event
  28385. * @param additionalData additional data for the event
  28386. * @returns the new ActionEvent
  28387. */
  28388. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28389. /**
  28390. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28391. * @param scene the scene where the event occurred
  28392. * @param evt The original (browser) event
  28393. * @returns the new ActionEvent
  28394. */
  28395. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28396. /**
  28397. * Helper function to auto-create an ActionEvent from a primitive
  28398. * @param prim defines the target primitive
  28399. * @param pointerPos defines the pointer position
  28400. * @param evt The original (browser) event
  28401. * @param additionalData additional data for the event
  28402. * @returns the new ActionEvent
  28403. */
  28404. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28405. }
  28406. }
  28407. declare module BABYLON {
  28408. /**
  28409. * Abstract class used to decouple action Manager from scene and meshes.
  28410. * Do not instantiate.
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28412. */
  28413. export abstract class AbstractActionManager implements IDisposable {
  28414. /** Gets the list of active triggers */
  28415. static Triggers: {
  28416. [key: string]: number;
  28417. };
  28418. /** Gets the cursor to use when hovering items */
  28419. hoverCursor: string;
  28420. /** Gets the list of actions */
  28421. actions: IAction[];
  28422. /**
  28423. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28424. */
  28425. isRecursive: boolean;
  28426. /**
  28427. * Releases all associated resources
  28428. */
  28429. abstract dispose(): void;
  28430. /**
  28431. * Does this action manager has pointer triggers
  28432. */
  28433. abstract get hasPointerTriggers(): boolean;
  28434. /**
  28435. * Does this action manager has pick triggers
  28436. */
  28437. abstract get hasPickTriggers(): boolean;
  28438. /**
  28439. * Process a specific trigger
  28440. * @param trigger defines the trigger to process
  28441. * @param evt defines the event details to be processed
  28442. */
  28443. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28444. /**
  28445. * Does this action manager handles actions of any of the given triggers
  28446. * @param triggers defines the triggers to be tested
  28447. * @return a boolean indicating whether one (or more) of the triggers is handled
  28448. */
  28449. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28450. /**
  28451. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28452. * speed.
  28453. * @param triggerA defines the trigger to be tested
  28454. * @param triggerB defines the trigger to be tested
  28455. * @return a boolean indicating whether one (or more) of the triggers is handled
  28456. */
  28457. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28458. /**
  28459. * Does this action manager handles actions of a given trigger
  28460. * @param trigger defines the trigger to be tested
  28461. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28462. * @return whether the trigger is handled
  28463. */
  28464. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28465. /**
  28466. * Serialize this manager to a JSON object
  28467. * @param name defines the property name to store this manager
  28468. * @returns a JSON representation of this manager
  28469. */
  28470. abstract serialize(name: string): any;
  28471. /**
  28472. * Registers an action to this action manager
  28473. * @param action defines the action to be registered
  28474. * @return the action amended (prepared) after registration
  28475. */
  28476. abstract registerAction(action: IAction): Nullable<IAction>;
  28477. /**
  28478. * Unregisters an action to this action manager
  28479. * @param action defines the action to be unregistered
  28480. * @return a boolean indicating whether the action has been unregistered
  28481. */
  28482. abstract unregisterAction(action: IAction): Boolean;
  28483. /**
  28484. * Does exist one action manager with at least one trigger
  28485. **/
  28486. static get HasTriggers(): boolean;
  28487. /**
  28488. * Does exist one action manager with at least one pick trigger
  28489. **/
  28490. static get HasPickTriggers(): boolean;
  28491. /**
  28492. * Does exist one action manager that handles actions of a given trigger
  28493. * @param trigger defines the trigger to be tested
  28494. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28495. **/
  28496. static HasSpecificTrigger(trigger: number): boolean;
  28497. }
  28498. }
  28499. declare module BABYLON {
  28500. /**
  28501. * Defines how a node can be built from a string name.
  28502. */
  28503. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28504. /**
  28505. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28506. */
  28507. export class Node implements IBehaviorAware<Node> {
  28508. /** @hidden */
  28509. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28510. private static _NodeConstructors;
  28511. /**
  28512. * Add a new node constructor
  28513. * @param type defines the type name of the node to construct
  28514. * @param constructorFunc defines the constructor function
  28515. */
  28516. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28517. /**
  28518. * Returns a node constructor based on type name
  28519. * @param type defines the type name
  28520. * @param name defines the new node name
  28521. * @param scene defines the hosting scene
  28522. * @param options defines optional options to transmit to constructors
  28523. * @returns the new constructor or null
  28524. */
  28525. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28526. /**
  28527. * Gets or sets the name of the node
  28528. */
  28529. name: string;
  28530. /**
  28531. * Gets or sets the id of the node
  28532. */
  28533. id: string;
  28534. /**
  28535. * Gets or sets the unique id of the node
  28536. */
  28537. uniqueId: number;
  28538. /**
  28539. * Gets or sets a string used to store user defined state for the node
  28540. */
  28541. state: string;
  28542. /**
  28543. * Gets or sets an object used to store user defined information for the node
  28544. */
  28545. metadata: any;
  28546. /**
  28547. * For internal use only. Please do not use.
  28548. */
  28549. reservedDataStore: any;
  28550. /**
  28551. * List of inspectable custom properties (used by the Inspector)
  28552. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28553. */
  28554. inspectableCustomProperties: IInspectable[];
  28555. private _doNotSerialize;
  28556. /**
  28557. * Gets or sets a boolean used to define if the node must be serialized
  28558. */
  28559. get doNotSerialize(): boolean;
  28560. set doNotSerialize(value: boolean);
  28561. /** @hidden */
  28562. _isDisposed: boolean;
  28563. /**
  28564. * Gets a list of Animations associated with the node
  28565. */
  28566. animations: Animation[];
  28567. protected _ranges: {
  28568. [name: string]: Nullable<AnimationRange>;
  28569. };
  28570. /**
  28571. * Callback raised when the node is ready to be used
  28572. */
  28573. onReady: Nullable<(node: Node) => void>;
  28574. private _isEnabled;
  28575. private _isParentEnabled;
  28576. private _isReady;
  28577. /** @hidden */
  28578. _currentRenderId: number;
  28579. private _parentUpdateId;
  28580. /** @hidden */
  28581. _childUpdateId: number;
  28582. /** @hidden */
  28583. _waitingParentId: Nullable<string>;
  28584. /** @hidden */
  28585. _scene: Scene;
  28586. /** @hidden */
  28587. _cache: any;
  28588. private _parentNode;
  28589. private _children;
  28590. /** @hidden */
  28591. _worldMatrix: Matrix;
  28592. /** @hidden */
  28593. _worldMatrixDeterminant: number;
  28594. /** @hidden */
  28595. _worldMatrixDeterminantIsDirty: boolean;
  28596. /** @hidden */
  28597. private _sceneRootNodesIndex;
  28598. /**
  28599. * Gets a boolean indicating if the node has been disposed
  28600. * @returns true if the node was disposed
  28601. */
  28602. isDisposed(): boolean;
  28603. /**
  28604. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28605. * @see https://doc.babylonjs.com/how_to/parenting
  28606. */
  28607. set parent(parent: Nullable<Node>);
  28608. get parent(): Nullable<Node>;
  28609. /** @hidden */
  28610. _addToSceneRootNodes(): void;
  28611. /** @hidden */
  28612. _removeFromSceneRootNodes(): void;
  28613. private _animationPropertiesOverride;
  28614. /**
  28615. * Gets or sets the animation properties override
  28616. */
  28617. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28618. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28619. /**
  28620. * Gets a string idenfifying the name of the class
  28621. * @returns "Node" string
  28622. */
  28623. getClassName(): string;
  28624. /** @hidden */
  28625. readonly _isNode: boolean;
  28626. /**
  28627. * An event triggered when the mesh is disposed
  28628. */
  28629. onDisposeObservable: Observable<Node>;
  28630. private _onDisposeObserver;
  28631. /**
  28632. * Sets a callback that will be raised when the node will be disposed
  28633. */
  28634. set onDispose(callback: () => void);
  28635. /**
  28636. * Creates a new Node
  28637. * @param name the name and id to be given to this node
  28638. * @param scene the scene this node will be added to
  28639. */
  28640. constructor(name: string, scene?: Nullable<Scene>);
  28641. /**
  28642. * Gets the scene of the node
  28643. * @returns a scene
  28644. */
  28645. getScene(): Scene;
  28646. /**
  28647. * Gets the engine of the node
  28648. * @returns a Engine
  28649. */
  28650. getEngine(): Engine;
  28651. private _behaviors;
  28652. /**
  28653. * Attach a behavior to the node
  28654. * @see http://doc.babylonjs.com/features/behaviour
  28655. * @param behavior defines the behavior to attach
  28656. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28657. * @returns the current Node
  28658. */
  28659. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28660. /**
  28661. * Remove an attached behavior
  28662. * @see http://doc.babylonjs.com/features/behaviour
  28663. * @param behavior defines the behavior to attach
  28664. * @returns the current Node
  28665. */
  28666. removeBehavior(behavior: Behavior<Node>): Node;
  28667. /**
  28668. * Gets the list of attached behaviors
  28669. * @see http://doc.babylonjs.com/features/behaviour
  28670. */
  28671. get behaviors(): Behavior<Node>[];
  28672. /**
  28673. * Gets an attached behavior by name
  28674. * @param name defines the name of the behavior to look for
  28675. * @see http://doc.babylonjs.com/features/behaviour
  28676. * @returns null if behavior was not found else the requested behavior
  28677. */
  28678. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28679. /**
  28680. * Returns the latest update of the World matrix
  28681. * @returns a Matrix
  28682. */
  28683. getWorldMatrix(): Matrix;
  28684. /** @hidden */
  28685. _getWorldMatrixDeterminant(): number;
  28686. /**
  28687. * Returns directly the latest state of the mesh World matrix.
  28688. * A Matrix is returned.
  28689. */
  28690. get worldMatrixFromCache(): Matrix;
  28691. /** @hidden */
  28692. _initCache(): void;
  28693. /** @hidden */
  28694. updateCache(force?: boolean): void;
  28695. /** @hidden */
  28696. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28697. /** @hidden */
  28698. _updateCache(ignoreParentClass?: boolean): void;
  28699. /** @hidden */
  28700. _isSynchronized(): boolean;
  28701. /** @hidden */
  28702. _markSyncedWithParent(): void;
  28703. /** @hidden */
  28704. isSynchronizedWithParent(): boolean;
  28705. /** @hidden */
  28706. isSynchronized(): boolean;
  28707. /**
  28708. * Is this node ready to be used/rendered
  28709. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28710. * @return true if the node is ready
  28711. */
  28712. isReady(completeCheck?: boolean): boolean;
  28713. /**
  28714. * Is this node enabled?
  28715. * 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
  28716. * @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
  28717. * @return whether this node (and its parent) is enabled
  28718. */
  28719. isEnabled(checkAncestors?: boolean): boolean;
  28720. /** @hidden */
  28721. protected _syncParentEnabledState(): void;
  28722. /**
  28723. * Set the enabled state of this node
  28724. * @param value defines the new enabled state
  28725. */
  28726. setEnabled(value: boolean): void;
  28727. /**
  28728. * Is this node a descendant of the given node?
  28729. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28730. * @param ancestor defines the parent node to inspect
  28731. * @returns a boolean indicating if this node is a descendant of the given node
  28732. */
  28733. isDescendantOf(ancestor: Node): boolean;
  28734. /** @hidden */
  28735. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28736. /**
  28737. * Will return all nodes that have this node as ascendant
  28738. * @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
  28739. * @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
  28740. * @return all children nodes of all types
  28741. */
  28742. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28743. /**
  28744. * Get all child-meshes of this node
  28745. * @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)
  28746. * @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
  28747. * @returns an array of AbstractMesh
  28748. */
  28749. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28750. /**
  28751. * Get all direct children of this node
  28752. * @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
  28753. * @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)
  28754. * @returns an array of Node
  28755. */
  28756. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28757. /** @hidden */
  28758. _setReady(state: boolean): void;
  28759. /**
  28760. * Get an animation by name
  28761. * @param name defines the name of the animation to look for
  28762. * @returns null if not found else the requested animation
  28763. */
  28764. getAnimationByName(name: string): Nullable<Animation>;
  28765. /**
  28766. * Creates an animation range for this node
  28767. * @param name defines the name of the range
  28768. * @param from defines the starting key
  28769. * @param to defines the end key
  28770. */
  28771. createAnimationRange(name: string, from: number, to: number): void;
  28772. /**
  28773. * Delete a specific animation range
  28774. * @param name defines the name of the range to delete
  28775. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28776. */
  28777. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28778. /**
  28779. * Get an animation range by name
  28780. * @param name defines the name of the animation range to look for
  28781. * @returns null if not found else the requested animation range
  28782. */
  28783. getAnimationRange(name: string): Nullable<AnimationRange>;
  28784. /**
  28785. * Gets the list of all animation ranges defined on this node
  28786. * @returns an array
  28787. */
  28788. getAnimationRanges(): Nullable<AnimationRange>[];
  28789. /**
  28790. * Will start the animation sequence
  28791. * @param name defines the range frames for animation sequence
  28792. * @param loop defines if the animation should loop (false by default)
  28793. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28794. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28795. * @returns the object created for this animation. If range does not exist, it will return null
  28796. */
  28797. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28798. /**
  28799. * Serialize animation ranges into a JSON compatible object
  28800. * @returns serialization object
  28801. */
  28802. serializeAnimationRanges(): any;
  28803. /**
  28804. * Computes the world matrix of the node
  28805. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28806. * @returns the world matrix
  28807. */
  28808. computeWorldMatrix(force?: boolean): Matrix;
  28809. /**
  28810. * Releases resources associated with this node.
  28811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28813. */
  28814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28815. /**
  28816. * Parse animation range data from a serialization object and store them into a given node
  28817. * @param node defines where to store the animation ranges
  28818. * @param parsedNode defines the serialization object to read data from
  28819. * @param scene defines the hosting scene
  28820. */
  28821. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28822. /**
  28823. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28824. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28825. * @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
  28826. * @returns the new bounding vectors
  28827. */
  28828. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28829. min: Vector3;
  28830. max: Vector3;
  28831. };
  28832. }
  28833. }
  28834. declare module BABYLON {
  28835. /**
  28836. * @hidden
  28837. */
  28838. export class _IAnimationState {
  28839. key: number;
  28840. repeatCount: number;
  28841. workValue?: any;
  28842. loopMode?: number;
  28843. offsetValue?: any;
  28844. highLimitValue?: any;
  28845. }
  28846. /**
  28847. * Class used to store any kind of animation
  28848. */
  28849. export class Animation {
  28850. /**Name of the animation */
  28851. name: string;
  28852. /**Property to animate */
  28853. targetProperty: string;
  28854. /**The frames per second of the animation */
  28855. framePerSecond: number;
  28856. /**The data type of the animation */
  28857. dataType: number;
  28858. /**The loop mode of the animation */
  28859. loopMode?: number | undefined;
  28860. /**Specifies if blending should be enabled */
  28861. enableBlending?: boolean | undefined;
  28862. /**
  28863. * Use matrix interpolation instead of using direct key value when animating matrices
  28864. */
  28865. static AllowMatricesInterpolation: boolean;
  28866. /**
  28867. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28868. */
  28869. static AllowMatrixDecomposeForInterpolation: boolean;
  28870. /**
  28871. * Stores the key frames of the animation
  28872. */
  28873. private _keys;
  28874. /**
  28875. * Stores the easing function of the animation
  28876. */
  28877. private _easingFunction;
  28878. /**
  28879. * @hidden Internal use only
  28880. */
  28881. _runtimeAnimations: RuntimeAnimation[];
  28882. /**
  28883. * The set of event that will be linked to this animation
  28884. */
  28885. private _events;
  28886. /**
  28887. * Stores an array of target property paths
  28888. */
  28889. targetPropertyPath: string[];
  28890. /**
  28891. * Stores the blending speed of the animation
  28892. */
  28893. blendingSpeed: number;
  28894. /**
  28895. * Stores the animation ranges for the animation
  28896. */
  28897. private _ranges;
  28898. /**
  28899. * @hidden Internal use
  28900. */
  28901. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28902. /**
  28903. * Sets up an animation
  28904. * @param property The property to animate
  28905. * @param animationType The animation type to apply
  28906. * @param framePerSecond The frames per second of the animation
  28907. * @param easingFunction The easing function used in the animation
  28908. * @returns The created animation
  28909. */
  28910. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28911. /**
  28912. * Create and start an animation on a node
  28913. * @param name defines the name of the global animation that will be run on all nodes
  28914. * @param node defines the root node where the animation will take place
  28915. * @param targetProperty defines property to animate
  28916. * @param framePerSecond defines the number of frame per second yo use
  28917. * @param totalFrame defines the number of frames in total
  28918. * @param from defines the initial value
  28919. * @param to defines the final value
  28920. * @param loopMode defines which loop mode you want to use (off by default)
  28921. * @param easingFunction defines the easing function to use (linear by default)
  28922. * @param onAnimationEnd defines the callback to call when animation end
  28923. * @returns the animatable created for this animation
  28924. */
  28925. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28926. /**
  28927. * Create and start an animation on a node and its descendants
  28928. * @param name defines the name of the global animation that will be run on all nodes
  28929. * @param node defines the root node where the animation will take place
  28930. * @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
  28931. * @param targetProperty defines property to animate
  28932. * @param framePerSecond defines the number of frame per second to use
  28933. * @param totalFrame defines the number of frames in total
  28934. * @param from defines the initial value
  28935. * @param to defines the final value
  28936. * @param loopMode defines which loop mode you want to use (off by default)
  28937. * @param easingFunction defines the easing function to use (linear by default)
  28938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28939. * @returns the list of animatables created for all nodes
  28940. * @example https://www.babylonjs-playground.com/#MH0VLI
  28941. */
  28942. 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[]>;
  28943. /**
  28944. * Creates a new animation, merges it with the existing animations and starts it
  28945. * @param name Name of the animation
  28946. * @param node Node which contains the scene that begins the animations
  28947. * @param targetProperty Specifies which property to animate
  28948. * @param framePerSecond The frames per second of the animation
  28949. * @param totalFrame The total number of frames
  28950. * @param from The frame at the beginning of the animation
  28951. * @param to The frame at the end of the animation
  28952. * @param loopMode Specifies the loop mode of the animation
  28953. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28954. * @param onAnimationEnd Callback to run once the animation is complete
  28955. * @returns Nullable animation
  28956. */
  28957. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28958. /**
  28959. * Transition property of an host to the target Value
  28960. * @param property The property to transition
  28961. * @param targetValue The target Value of the property
  28962. * @param host The object where the property to animate belongs
  28963. * @param scene Scene used to run the animation
  28964. * @param frameRate Framerate (in frame/s) to use
  28965. * @param transition The transition type we want to use
  28966. * @param duration The duration of the animation, in milliseconds
  28967. * @param onAnimationEnd Callback trigger at the end of the animation
  28968. * @returns Nullable animation
  28969. */
  28970. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28971. /**
  28972. * Return the array of runtime animations currently using this animation
  28973. */
  28974. get runtimeAnimations(): RuntimeAnimation[];
  28975. /**
  28976. * Specifies if any of the runtime animations are currently running
  28977. */
  28978. get hasRunningRuntimeAnimations(): boolean;
  28979. /**
  28980. * Initializes the animation
  28981. * @param name Name of the animation
  28982. * @param targetProperty Property to animate
  28983. * @param framePerSecond The frames per second of the animation
  28984. * @param dataType The data type of the animation
  28985. * @param loopMode The loop mode of the animation
  28986. * @param enableBlending Specifies if blending should be enabled
  28987. */
  28988. constructor(
  28989. /**Name of the animation */
  28990. name: string,
  28991. /**Property to animate */
  28992. targetProperty: string,
  28993. /**The frames per second of the animation */
  28994. framePerSecond: number,
  28995. /**The data type of the animation */
  28996. dataType: number,
  28997. /**The loop mode of the animation */
  28998. loopMode?: number | undefined,
  28999. /**Specifies if blending should be enabled */
  29000. enableBlending?: boolean | undefined);
  29001. /**
  29002. * Converts the animation to a string
  29003. * @param fullDetails support for multiple levels of logging within scene loading
  29004. * @returns String form of the animation
  29005. */
  29006. toString(fullDetails?: boolean): string;
  29007. /**
  29008. * Add an event to this animation
  29009. * @param event Event to add
  29010. */
  29011. addEvent(event: AnimationEvent): void;
  29012. /**
  29013. * Remove all events found at the given frame
  29014. * @param frame The frame to remove events from
  29015. */
  29016. removeEvents(frame: number): void;
  29017. /**
  29018. * Retrieves all the events from the animation
  29019. * @returns Events from the animation
  29020. */
  29021. getEvents(): AnimationEvent[];
  29022. /**
  29023. * Creates an animation range
  29024. * @param name Name of the animation range
  29025. * @param from Starting frame of the animation range
  29026. * @param to Ending frame of the animation
  29027. */
  29028. createRange(name: string, from: number, to: number): void;
  29029. /**
  29030. * Deletes an animation range by name
  29031. * @param name Name of the animation range to delete
  29032. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29033. */
  29034. deleteRange(name: string, deleteFrames?: boolean): void;
  29035. /**
  29036. * Gets the animation range by name, or null if not defined
  29037. * @param name Name of the animation range
  29038. * @returns Nullable animation range
  29039. */
  29040. getRange(name: string): Nullable<AnimationRange>;
  29041. /**
  29042. * Gets the key frames from the animation
  29043. * @returns The key frames of the animation
  29044. */
  29045. getKeys(): Array<IAnimationKey>;
  29046. /**
  29047. * Gets the highest frame rate of the animation
  29048. * @returns Highest frame rate of the animation
  29049. */
  29050. getHighestFrame(): number;
  29051. /**
  29052. * Gets the easing function of the animation
  29053. * @returns Easing function of the animation
  29054. */
  29055. getEasingFunction(): IEasingFunction;
  29056. /**
  29057. * Sets the easing function of the animation
  29058. * @param easingFunction A custom mathematical formula for animation
  29059. */
  29060. setEasingFunction(easingFunction: EasingFunction): void;
  29061. /**
  29062. * Interpolates a scalar linearly
  29063. * @param startValue Start value of the animation curve
  29064. * @param endValue End value of the animation curve
  29065. * @param gradient Scalar amount to interpolate
  29066. * @returns Interpolated scalar value
  29067. */
  29068. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29069. /**
  29070. * Interpolates a scalar cubically
  29071. * @param startValue Start value of the animation curve
  29072. * @param outTangent End tangent of the animation
  29073. * @param endValue End value of the animation curve
  29074. * @param inTangent Start tangent of the animation curve
  29075. * @param gradient Scalar amount to interpolate
  29076. * @returns Interpolated scalar value
  29077. */
  29078. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29079. /**
  29080. * Interpolates a quaternion using a spherical linear interpolation
  29081. * @param startValue Start value of the animation curve
  29082. * @param endValue End value of the animation curve
  29083. * @param gradient Scalar amount to interpolate
  29084. * @returns Interpolated quaternion value
  29085. */
  29086. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29087. /**
  29088. * Interpolates a quaternion cubically
  29089. * @param startValue Start value of the animation curve
  29090. * @param outTangent End tangent of the animation curve
  29091. * @param endValue End value of the animation curve
  29092. * @param inTangent Start tangent of the animation curve
  29093. * @param gradient Scalar amount to interpolate
  29094. * @returns Interpolated quaternion value
  29095. */
  29096. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29097. /**
  29098. * Interpolates a Vector3 linearl
  29099. * @param startValue Start value of the animation curve
  29100. * @param endValue End value of the animation curve
  29101. * @param gradient Scalar amount to interpolate
  29102. * @returns Interpolated scalar value
  29103. */
  29104. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29105. /**
  29106. * Interpolates a Vector3 cubically
  29107. * @param startValue Start value of the animation curve
  29108. * @param outTangent End tangent of the animation
  29109. * @param endValue End value of the animation curve
  29110. * @param inTangent Start tangent of the animation curve
  29111. * @param gradient Scalar amount to interpolate
  29112. * @returns InterpolatedVector3 value
  29113. */
  29114. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29115. /**
  29116. * Interpolates a Vector2 linearly
  29117. * @param startValue Start value of the animation curve
  29118. * @param endValue End value of the animation curve
  29119. * @param gradient Scalar amount to interpolate
  29120. * @returns Interpolated Vector2 value
  29121. */
  29122. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29123. /**
  29124. * Interpolates a Vector2 cubically
  29125. * @param startValue Start value of the animation curve
  29126. * @param outTangent End tangent of the animation
  29127. * @param endValue End value of the animation curve
  29128. * @param inTangent Start tangent of the animation curve
  29129. * @param gradient Scalar amount to interpolate
  29130. * @returns Interpolated Vector2 value
  29131. */
  29132. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29133. /**
  29134. * Interpolates a size linearly
  29135. * @param startValue Start value of the animation curve
  29136. * @param endValue End value of the animation curve
  29137. * @param gradient Scalar amount to interpolate
  29138. * @returns Interpolated Size value
  29139. */
  29140. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29141. /**
  29142. * Interpolates a Color3 linearly
  29143. * @param startValue Start value of the animation curve
  29144. * @param endValue End value of the animation curve
  29145. * @param gradient Scalar amount to interpolate
  29146. * @returns Interpolated Color3 value
  29147. */
  29148. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29149. /**
  29150. * Interpolates a Color4 linearly
  29151. * @param startValue Start value of the animation curve
  29152. * @param endValue End value of the animation curve
  29153. * @param gradient Scalar amount to interpolate
  29154. * @returns Interpolated Color3 value
  29155. */
  29156. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29157. /**
  29158. * @hidden Internal use only
  29159. */
  29160. _getKeyValue(value: any): any;
  29161. /**
  29162. * @hidden Internal use only
  29163. */
  29164. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29165. /**
  29166. * Defines the function to use to interpolate matrices
  29167. * @param startValue defines the start matrix
  29168. * @param endValue defines the end matrix
  29169. * @param gradient defines the gradient between both matrices
  29170. * @param result defines an optional target matrix where to store the interpolation
  29171. * @returns the interpolated matrix
  29172. */
  29173. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29174. /**
  29175. * Makes a copy of the animation
  29176. * @returns Cloned animation
  29177. */
  29178. clone(): Animation;
  29179. /**
  29180. * Sets the key frames of the animation
  29181. * @param values The animation key frames to set
  29182. */
  29183. setKeys(values: Array<IAnimationKey>): void;
  29184. /**
  29185. * Serializes the animation to an object
  29186. * @returns Serialized object
  29187. */
  29188. serialize(): any;
  29189. /**
  29190. * Float animation type
  29191. */
  29192. static readonly ANIMATIONTYPE_FLOAT: number;
  29193. /**
  29194. * Vector3 animation type
  29195. */
  29196. static readonly ANIMATIONTYPE_VECTOR3: number;
  29197. /**
  29198. * Quaternion animation type
  29199. */
  29200. static readonly ANIMATIONTYPE_QUATERNION: number;
  29201. /**
  29202. * Matrix animation type
  29203. */
  29204. static readonly ANIMATIONTYPE_MATRIX: number;
  29205. /**
  29206. * Color3 animation type
  29207. */
  29208. static readonly ANIMATIONTYPE_COLOR3: number;
  29209. /**
  29210. * Color3 animation type
  29211. */
  29212. static readonly ANIMATIONTYPE_COLOR4: number;
  29213. /**
  29214. * Vector2 animation type
  29215. */
  29216. static readonly ANIMATIONTYPE_VECTOR2: number;
  29217. /**
  29218. * Size animation type
  29219. */
  29220. static readonly ANIMATIONTYPE_SIZE: number;
  29221. /**
  29222. * Relative Loop Mode
  29223. */
  29224. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29225. /**
  29226. * Cycle Loop Mode
  29227. */
  29228. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29229. /**
  29230. * Constant Loop Mode
  29231. */
  29232. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29233. /** @hidden */
  29234. static _UniversalLerp(left: any, right: any, amount: number): any;
  29235. /**
  29236. * Parses an animation object and creates an animation
  29237. * @param parsedAnimation Parsed animation object
  29238. * @returns Animation object
  29239. */
  29240. static Parse(parsedAnimation: any): Animation;
  29241. /**
  29242. * Appends the serialized animations from the source animations
  29243. * @param source Source containing the animations
  29244. * @param destination Target to store the animations
  29245. */
  29246. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29247. }
  29248. }
  29249. declare module BABYLON {
  29250. /**
  29251. * Interface containing an array of animations
  29252. */
  29253. export interface IAnimatable {
  29254. /**
  29255. * Array of animations
  29256. */
  29257. animations: Nullable<Array<Animation>>;
  29258. }
  29259. }
  29260. declare module BABYLON {
  29261. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29262. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29263. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29264. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29265. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29266. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29267. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29268. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29269. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29270. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29271. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29272. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29273. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29274. /**
  29275. * Decorator used to define property that can be serialized as reference to a camera
  29276. * @param sourceName defines the name of the property to decorate
  29277. */
  29278. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29279. /**
  29280. * Class used to help serialization objects
  29281. */
  29282. export class SerializationHelper {
  29283. /** @hidden */
  29284. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29285. /** @hidden */
  29286. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29287. /** @hidden */
  29288. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29289. /** @hidden */
  29290. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29291. /**
  29292. * Appends the serialized animations from the source animations
  29293. * @param source Source containing the animations
  29294. * @param destination Target to store the animations
  29295. */
  29296. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29297. /**
  29298. * Static function used to serialized a specific entity
  29299. * @param entity defines the entity to serialize
  29300. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29301. * @returns a JSON compatible object representing the serialization of the entity
  29302. */
  29303. static Serialize<T>(entity: T, serializationObject?: any): any;
  29304. /**
  29305. * Creates a new entity from a serialization data object
  29306. * @param creationFunction defines a function used to instanciated the new entity
  29307. * @param source defines the source serialization data
  29308. * @param scene defines the hosting scene
  29309. * @param rootUrl defines the root url for resources
  29310. * @returns a new entity
  29311. */
  29312. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29313. /**
  29314. * Clones an object
  29315. * @param creationFunction defines the function used to instanciate the new object
  29316. * @param source defines the source object
  29317. * @returns the cloned object
  29318. */
  29319. static Clone<T>(creationFunction: () => T, source: T): T;
  29320. /**
  29321. * Instanciates a new object based on a source one (some data will be shared between both object)
  29322. * @param creationFunction defines the function used to instanciate the new object
  29323. * @param source defines the source object
  29324. * @returns the new object
  29325. */
  29326. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29327. }
  29328. }
  29329. declare module BABYLON {
  29330. /**
  29331. * Class used to manipulate GUIDs
  29332. */
  29333. export class GUID {
  29334. /**
  29335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29336. * Be aware Math.random() could cause collisions, but:
  29337. * "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"
  29338. * @returns a pseudo random id
  29339. */
  29340. static RandomId(): string;
  29341. }
  29342. }
  29343. declare module BABYLON {
  29344. /**
  29345. * Base class of all the textures in babylon.
  29346. * It groups all the common properties the materials, post process, lights... might need
  29347. * in order to make a correct use of the texture.
  29348. */
  29349. export class BaseTexture implements IAnimatable {
  29350. /**
  29351. * Default anisotropic filtering level for the application.
  29352. * It is set to 4 as a good tradeoff between perf and quality.
  29353. */
  29354. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29355. /**
  29356. * Gets or sets the unique id of the texture
  29357. */
  29358. uniqueId: number;
  29359. /**
  29360. * Define the name of the texture.
  29361. */
  29362. name: string;
  29363. /**
  29364. * Gets or sets an object used to store user defined information.
  29365. */
  29366. metadata: any;
  29367. /**
  29368. * For internal use only. Please do not use.
  29369. */
  29370. reservedDataStore: any;
  29371. private _hasAlpha;
  29372. /**
  29373. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29374. */
  29375. set hasAlpha(value: boolean);
  29376. get hasAlpha(): boolean;
  29377. /**
  29378. * Defines if the alpha value should be determined via the rgb values.
  29379. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29380. */
  29381. getAlphaFromRGB: boolean;
  29382. /**
  29383. * Intensity or strength of the texture.
  29384. * It is commonly used by materials to fine tune the intensity of the texture
  29385. */
  29386. level: number;
  29387. /**
  29388. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29389. * This is part of the texture as textures usually maps to one uv set.
  29390. */
  29391. coordinatesIndex: number;
  29392. private _coordinatesMode;
  29393. /**
  29394. * How a texture is mapped.
  29395. *
  29396. * | Value | Type | Description |
  29397. * | ----- | ----------------------------------- | ----------- |
  29398. * | 0 | EXPLICIT_MODE | |
  29399. * | 1 | SPHERICAL_MODE | |
  29400. * | 2 | PLANAR_MODE | |
  29401. * | 3 | CUBIC_MODE | |
  29402. * | 4 | PROJECTION_MODE | |
  29403. * | 5 | SKYBOX_MODE | |
  29404. * | 6 | INVCUBIC_MODE | |
  29405. * | 7 | EQUIRECTANGULAR_MODE | |
  29406. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29407. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29408. */
  29409. set coordinatesMode(value: number);
  29410. get coordinatesMode(): number;
  29411. /**
  29412. * | Value | Type | Description |
  29413. * | ----- | ------------------ | ----------- |
  29414. * | 0 | CLAMP_ADDRESSMODE | |
  29415. * | 1 | WRAP_ADDRESSMODE | |
  29416. * | 2 | MIRROR_ADDRESSMODE | |
  29417. */
  29418. wrapU: number;
  29419. /**
  29420. * | Value | Type | Description |
  29421. * | ----- | ------------------ | ----------- |
  29422. * | 0 | CLAMP_ADDRESSMODE | |
  29423. * | 1 | WRAP_ADDRESSMODE | |
  29424. * | 2 | MIRROR_ADDRESSMODE | |
  29425. */
  29426. wrapV: number;
  29427. /**
  29428. * | Value | Type | Description |
  29429. * | ----- | ------------------ | ----------- |
  29430. * | 0 | CLAMP_ADDRESSMODE | |
  29431. * | 1 | WRAP_ADDRESSMODE | |
  29432. * | 2 | MIRROR_ADDRESSMODE | |
  29433. */
  29434. wrapR: number;
  29435. /**
  29436. * With compliant hardware and browser (supporting anisotropic filtering)
  29437. * this defines the level of anisotropic filtering in the texture.
  29438. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29439. */
  29440. anisotropicFilteringLevel: number;
  29441. /**
  29442. * Define if the texture is a cube texture or if false a 2d texture.
  29443. */
  29444. get isCube(): boolean;
  29445. set isCube(value: boolean);
  29446. /**
  29447. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29448. */
  29449. get is3D(): boolean;
  29450. set is3D(value: boolean);
  29451. /**
  29452. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29453. */
  29454. get is2DArray(): boolean;
  29455. set is2DArray(value: boolean);
  29456. /**
  29457. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29458. * HDR texture are usually stored in linear space.
  29459. * This only impacts the PBR and Background materials
  29460. */
  29461. gammaSpace: boolean;
  29462. /**
  29463. * Gets or sets whether or not the texture contains RGBD data.
  29464. */
  29465. get isRGBD(): boolean;
  29466. set isRGBD(value: boolean);
  29467. /**
  29468. * Is Z inverted in the texture (useful in a cube texture).
  29469. */
  29470. invertZ: boolean;
  29471. /**
  29472. * Are mip maps generated for this texture or not.
  29473. */
  29474. get noMipmap(): boolean;
  29475. /**
  29476. * @hidden
  29477. */
  29478. lodLevelInAlpha: boolean;
  29479. /**
  29480. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29481. */
  29482. get lodGenerationOffset(): number;
  29483. set lodGenerationOffset(value: number);
  29484. /**
  29485. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29486. */
  29487. get lodGenerationScale(): number;
  29488. set lodGenerationScale(value: number);
  29489. /**
  29490. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29491. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29492. * average roughness values.
  29493. */
  29494. get linearSpecularLOD(): boolean;
  29495. set linearSpecularLOD(value: boolean);
  29496. /**
  29497. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29498. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29499. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29500. */
  29501. get irradianceTexture(): Nullable<BaseTexture>;
  29502. set irradianceTexture(value: Nullable<BaseTexture>);
  29503. /**
  29504. * Define if the texture is a render target.
  29505. */
  29506. isRenderTarget: boolean;
  29507. /**
  29508. * Define the unique id of the texture in the scene.
  29509. */
  29510. get uid(): string;
  29511. /**
  29512. * Return a string representation of the texture.
  29513. * @returns the texture as a string
  29514. */
  29515. toString(): string;
  29516. /**
  29517. * Get the class name of the texture.
  29518. * @returns "BaseTexture"
  29519. */
  29520. getClassName(): string;
  29521. /**
  29522. * Define the list of animation attached to the texture.
  29523. */
  29524. animations: Animation[];
  29525. /**
  29526. * An event triggered when the texture is disposed.
  29527. */
  29528. onDisposeObservable: Observable<BaseTexture>;
  29529. private _onDisposeObserver;
  29530. /**
  29531. * Callback triggered when the texture has been disposed.
  29532. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29533. */
  29534. set onDispose(callback: () => void);
  29535. /**
  29536. * Define the current state of the loading sequence when in delayed load mode.
  29537. */
  29538. delayLoadState: number;
  29539. private _scene;
  29540. /** @hidden */
  29541. _texture: Nullable<InternalTexture>;
  29542. private _uid;
  29543. /**
  29544. * Define if the texture is preventinga material to render or not.
  29545. * If not and the texture is not ready, the engine will use a default black texture instead.
  29546. */
  29547. get isBlocking(): boolean;
  29548. /**
  29549. * Instantiates a new BaseTexture.
  29550. * Base class of all the textures in babylon.
  29551. * It groups all the common properties the materials, post process, lights... might need
  29552. * in order to make a correct use of the texture.
  29553. * @param scene Define the scene the texture blongs to
  29554. */
  29555. constructor(scene: Nullable<Scene>);
  29556. /**
  29557. * Get the scene the texture belongs to.
  29558. * @returns the scene or null if undefined
  29559. */
  29560. getScene(): Nullable<Scene>;
  29561. /**
  29562. * Get the texture transform matrix used to offset tile the texture for istance.
  29563. * @returns the transformation matrix
  29564. */
  29565. getTextureMatrix(): Matrix;
  29566. /**
  29567. * Get the texture reflection matrix used to rotate/transform the reflection.
  29568. * @returns the reflection matrix
  29569. */
  29570. getReflectionTextureMatrix(): Matrix;
  29571. /**
  29572. * Get the underlying lower level texture from Babylon.
  29573. * @returns the insternal texture
  29574. */
  29575. getInternalTexture(): Nullable<InternalTexture>;
  29576. /**
  29577. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29578. * @returns true if ready or not blocking
  29579. */
  29580. isReadyOrNotBlocking(): boolean;
  29581. /**
  29582. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29583. * @returns true if fully ready
  29584. */
  29585. isReady(): boolean;
  29586. private _cachedSize;
  29587. /**
  29588. * Get the size of the texture.
  29589. * @returns the texture size.
  29590. */
  29591. getSize(): ISize;
  29592. /**
  29593. * Get the base size of the texture.
  29594. * It can be different from the size if the texture has been resized for POT for instance
  29595. * @returns the base size
  29596. */
  29597. getBaseSize(): ISize;
  29598. /**
  29599. * Update the sampling mode of the texture.
  29600. * Default is Trilinear mode.
  29601. *
  29602. * | Value | Type | Description |
  29603. * | ----- | ------------------ | ----------- |
  29604. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29605. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29606. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29607. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29608. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29609. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29610. * | 7 | NEAREST_LINEAR | |
  29611. * | 8 | NEAREST_NEAREST | |
  29612. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29613. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29614. * | 11 | LINEAR_LINEAR | |
  29615. * | 12 | LINEAR_NEAREST | |
  29616. *
  29617. * > _mag_: magnification filter (close to the viewer)
  29618. * > _min_: minification filter (far from the viewer)
  29619. * > _mip_: filter used between mip map levels
  29620. *@param samplingMode Define the new sampling mode of the texture
  29621. */
  29622. updateSamplingMode(samplingMode: number): void;
  29623. /**
  29624. * Scales the texture if is `canRescale()`
  29625. * @param ratio the resize factor we want to use to rescale
  29626. */
  29627. scale(ratio: number): void;
  29628. /**
  29629. * Get if the texture can rescale.
  29630. */
  29631. get canRescale(): boolean;
  29632. /** @hidden */
  29633. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29634. /** @hidden */
  29635. _rebuild(): void;
  29636. /**
  29637. * Triggers the load sequence in delayed load mode.
  29638. */
  29639. delayLoad(): void;
  29640. /**
  29641. * Clones the texture.
  29642. * @returns the cloned texture
  29643. */
  29644. clone(): Nullable<BaseTexture>;
  29645. /**
  29646. * Get the texture underlying type (INT, FLOAT...)
  29647. */
  29648. get textureType(): number;
  29649. /**
  29650. * Get the texture underlying format (RGB, RGBA...)
  29651. */
  29652. get textureFormat(): number;
  29653. /**
  29654. * Indicates that textures need to be re-calculated for all materials
  29655. */
  29656. protected _markAllSubMeshesAsTexturesDirty(): void;
  29657. /**
  29658. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29659. * This will returns an RGBA array buffer containing either in values (0-255) or
  29660. * float values (0-1) depending of the underlying buffer type.
  29661. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29662. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29663. * @param buffer defines a user defined buffer to fill with data (can be null)
  29664. * @returns The Array buffer containing the pixels data.
  29665. */
  29666. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29667. /**
  29668. * Release and destroy the underlying lower level texture aka internalTexture.
  29669. */
  29670. releaseInternalTexture(): void;
  29671. /** @hidden */
  29672. get _lodTextureHigh(): Nullable<BaseTexture>;
  29673. /** @hidden */
  29674. get _lodTextureMid(): Nullable<BaseTexture>;
  29675. /** @hidden */
  29676. get _lodTextureLow(): Nullable<BaseTexture>;
  29677. /**
  29678. * Dispose the texture and release its associated resources.
  29679. */
  29680. dispose(): void;
  29681. /**
  29682. * Serialize the texture into a JSON representation that can be parsed later on.
  29683. * @returns the JSON representation of the texture
  29684. */
  29685. serialize(): any;
  29686. /**
  29687. * Helper function to be called back once a list of texture contains only ready textures.
  29688. * @param textures Define the list of textures to wait for
  29689. * @param callback Define the callback triggered once the entire list will be ready
  29690. */
  29691. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29692. }
  29693. }
  29694. declare module BABYLON {
  29695. /**
  29696. * Options to be used when creating an effect.
  29697. */
  29698. export interface IEffectCreationOptions {
  29699. /**
  29700. * Atrributes that will be used in the shader.
  29701. */
  29702. attributes: string[];
  29703. /**
  29704. * Uniform varible names that will be set in the shader.
  29705. */
  29706. uniformsNames: string[];
  29707. /**
  29708. * Uniform buffer variable names that will be set in the shader.
  29709. */
  29710. uniformBuffersNames: string[];
  29711. /**
  29712. * Sampler texture variable names that will be set in the shader.
  29713. */
  29714. samplers: string[];
  29715. /**
  29716. * Define statements that will be set in the shader.
  29717. */
  29718. defines: any;
  29719. /**
  29720. * Possible fallbacks for this effect to improve performance when needed.
  29721. */
  29722. fallbacks: Nullable<IEffectFallbacks>;
  29723. /**
  29724. * Callback that will be called when the shader is compiled.
  29725. */
  29726. onCompiled: Nullable<(effect: Effect) => void>;
  29727. /**
  29728. * Callback that will be called if an error occurs during shader compilation.
  29729. */
  29730. onError: Nullable<(effect: Effect, errors: string) => void>;
  29731. /**
  29732. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29733. */
  29734. indexParameters?: any;
  29735. /**
  29736. * Max number of lights that can be used in the shader.
  29737. */
  29738. maxSimultaneousLights?: number;
  29739. /**
  29740. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29741. */
  29742. transformFeedbackVaryings?: Nullable<string[]>;
  29743. }
  29744. /**
  29745. * Effect containing vertex and fragment shader that can be executed on an object.
  29746. */
  29747. export class Effect implements IDisposable {
  29748. /**
  29749. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29750. */
  29751. static ShadersRepository: string;
  29752. /**
  29753. * Name of the effect.
  29754. */
  29755. name: any;
  29756. /**
  29757. * String container all the define statements that should be set on the shader.
  29758. */
  29759. defines: string;
  29760. /**
  29761. * Callback that will be called when the shader is compiled.
  29762. */
  29763. onCompiled: Nullable<(effect: Effect) => void>;
  29764. /**
  29765. * Callback that will be called if an error occurs during shader compilation.
  29766. */
  29767. onError: Nullable<(effect: Effect, errors: string) => void>;
  29768. /**
  29769. * Callback that will be called when effect is bound.
  29770. */
  29771. onBind: Nullable<(effect: Effect) => void>;
  29772. /**
  29773. * Unique ID of the effect.
  29774. */
  29775. uniqueId: number;
  29776. /**
  29777. * Observable that will be called when the shader is compiled.
  29778. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29779. */
  29780. onCompileObservable: Observable<Effect>;
  29781. /**
  29782. * Observable that will be called if an error occurs during shader compilation.
  29783. */
  29784. onErrorObservable: Observable<Effect>;
  29785. /** @hidden */
  29786. _onBindObservable: Nullable<Observable<Effect>>;
  29787. /**
  29788. * Observable that will be called when effect is bound.
  29789. */
  29790. get onBindObservable(): Observable<Effect>;
  29791. /** @hidden */
  29792. _bonesComputationForcedToCPU: boolean;
  29793. private static _uniqueIdSeed;
  29794. private _engine;
  29795. private _uniformBuffersNames;
  29796. private _uniformsNames;
  29797. private _samplerList;
  29798. private _samplers;
  29799. private _isReady;
  29800. private _compilationError;
  29801. private _allFallbacksProcessed;
  29802. private _attributesNames;
  29803. private _attributes;
  29804. private _attributeLocationByName;
  29805. private _uniforms;
  29806. /**
  29807. * Key for the effect.
  29808. * @hidden
  29809. */
  29810. _key: string;
  29811. private _indexParameters;
  29812. private _fallbacks;
  29813. private _vertexSourceCode;
  29814. private _fragmentSourceCode;
  29815. private _vertexSourceCodeOverride;
  29816. private _fragmentSourceCodeOverride;
  29817. private _transformFeedbackVaryings;
  29818. /**
  29819. * Compiled shader to webGL program.
  29820. * @hidden
  29821. */
  29822. _pipelineContext: Nullable<IPipelineContext>;
  29823. private _valueCache;
  29824. private static _baseCache;
  29825. /**
  29826. * Instantiates an effect.
  29827. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29828. * @param baseName Name of the effect.
  29829. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29830. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29831. * @param samplers List of sampler variables that will be passed to the shader.
  29832. * @param engine Engine to be used to render the effect
  29833. * @param defines Define statements to be added to the shader.
  29834. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29835. * @param onCompiled Callback that will be called when the shader is compiled.
  29836. * @param onError Callback that will be called if an error occurs during shader compilation.
  29837. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29838. */
  29839. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29840. private _useFinalCode;
  29841. /**
  29842. * Unique key for this effect
  29843. */
  29844. get key(): string;
  29845. /**
  29846. * If the effect has been compiled and prepared.
  29847. * @returns if the effect is compiled and prepared.
  29848. */
  29849. isReady(): boolean;
  29850. private _isReadyInternal;
  29851. /**
  29852. * The engine the effect was initialized with.
  29853. * @returns the engine.
  29854. */
  29855. getEngine(): Engine;
  29856. /**
  29857. * The pipeline context for this effect
  29858. * @returns the associated pipeline context
  29859. */
  29860. getPipelineContext(): Nullable<IPipelineContext>;
  29861. /**
  29862. * The set of names of attribute variables for the shader.
  29863. * @returns An array of attribute names.
  29864. */
  29865. getAttributesNames(): string[];
  29866. /**
  29867. * Returns the attribute at the given index.
  29868. * @param index The index of the attribute.
  29869. * @returns The location of the attribute.
  29870. */
  29871. getAttributeLocation(index: number): number;
  29872. /**
  29873. * Returns the attribute based on the name of the variable.
  29874. * @param name of the attribute to look up.
  29875. * @returns the attribute location.
  29876. */
  29877. getAttributeLocationByName(name: string): number;
  29878. /**
  29879. * The number of attributes.
  29880. * @returns the numnber of attributes.
  29881. */
  29882. getAttributesCount(): number;
  29883. /**
  29884. * Gets the index of a uniform variable.
  29885. * @param uniformName of the uniform to look up.
  29886. * @returns the index.
  29887. */
  29888. getUniformIndex(uniformName: string): number;
  29889. /**
  29890. * Returns the attribute based on the name of the variable.
  29891. * @param uniformName of the uniform to look up.
  29892. * @returns the location of the uniform.
  29893. */
  29894. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29895. /**
  29896. * Returns an array of sampler variable names
  29897. * @returns The array of sampler variable neames.
  29898. */
  29899. getSamplers(): string[];
  29900. /**
  29901. * The error from the last compilation.
  29902. * @returns the error string.
  29903. */
  29904. getCompilationError(): string;
  29905. /**
  29906. * Gets a boolean indicating that all fallbacks were used during compilation
  29907. * @returns true if all fallbacks were used
  29908. */
  29909. allFallbacksProcessed(): boolean;
  29910. /**
  29911. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29912. * @param func The callback to be used.
  29913. */
  29914. executeWhenCompiled(func: (effect: Effect) => void): void;
  29915. private _checkIsReady;
  29916. private _loadShader;
  29917. /**
  29918. * Recompiles the webGL program
  29919. * @param vertexSourceCode The source code for the vertex shader.
  29920. * @param fragmentSourceCode The source code for the fragment shader.
  29921. * @param onCompiled Callback called when completed.
  29922. * @param onError Callback called on error.
  29923. * @hidden
  29924. */
  29925. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29926. /**
  29927. * Prepares the effect
  29928. * @hidden
  29929. */
  29930. _prepareEffect(): void;
  29931. private _processCompilationErrors;
  29932. /**
  29933. * Checks if the effect is supported. (Must be called after compilation)
  29934. */
  29935. get isSupported(): boolean;
  29936. /**
  29937. * Binds a texture to the engine to be used as output of the shader.
  29938. * @param channel Name of the output variable.
  29939. * @param texture Texture to bind.
  29940. * @hidden
  29941. */
  29942. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29943. /**
  29944. * Sets a texture on the engine to be used in the shader.
  29945. * @param channel Name of the sampler variable.
  29946. * @param texture Texture to set.
  29947. */
  29948. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29949. /**
  29950. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29951. * @param channel Name of the sampler variable.
  29952. * @param texture Texture to set.
  29953. */
  29954. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29955. /**
  29956. * Sets an array of textures on the engine to be used in the shader.
  29957. * @param channel Name of the variable.
  29958. * @param textures Textures to set.
  29959. */
  29960. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29961. /**
  29962. * 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)
  29963. * @param channel Name of the sampler variable.
  29964. * @param postProcess Post process to get the input texture from.
  29965. */
  29966. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29967. /**
  29968. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29969. * 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)
  29970. * @param channel Name of the sampler variable.
  29971. * @param postProcess Post process to get the output texture from.
  29972. */
  29973. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29974. /** @hidden */
  29975. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29976. /** @hidden */
  29977. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29978. /** @hidden */
  29979. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29980. /** @hidden */
  29981. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29982. /**
  29983. * Binds a buffer to a uniform.
  29984. * @param buffer Buffer to bind.
  29985. * @param name Name of the uniform variable to bind to.
  29986. */
  29987. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29988. /**
  29989. * Binds block to a uniform.
  29990. * @param blockName Name of the block to bind.
  29991. * @param index Index to bind.
  29992. */
  29993. bindUniformBlock(blockName: string, index: number): void;
  29994. /**
  29995. * Sets an interger value on a uniform variable.
  29996. * @param uniformName Name of the variable.
  29997. * @param value Value to be set.
  29998. * @returns this effect.
  29999. */
  30000. setInt(uniformName: string, value: number): Effect;
  30001. /**
  30002. * Sets an int array on a uniform variable.
  30003. * @param uniformName Name of the variable.
  30004. * @param array array to be set.
  30005. * @returns this effect.
  30006. */
  30007. setIntArray(uniformName: string, array: Int32Array): Effect;
  30008. /**
  30009. * 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)
  30010. * @param uniformName Name of the variable.
  30011. * @param array array to be set.
  30012. * @returns this effect.
  30013. */
  30014. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30015. /**
  30016. * 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)
  30017. * @param uniformName Name of the variable.
  30018. * @param array array to be set.
  30019. * @returns this effect.
  30020. */
  30021. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30022. /**
  30023. * 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)
  30024. * @param uniformName Name of the variable.
  30025. * @param array array to be set.
  30026. * @returns this effect.
  30027. */
  30028. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30029. /**
  30030. * Sets an float array on a uniform variable.
  30031. * @param uniformName Name of the variable.
  30032. * @param array array to be set.
  30033. * @returns this effect.
  30034. */
  30035. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30036. /**
  30037. * 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)
  30038. * @param uniformName Name of the variable.
  30039. * @param array array to be set.
  30040. * @returns this effect.
  30041. */
  30042. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30043. /**
  30044. * 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)
  30045. * @param uniformName Name of the variable.
  30046. * @param array array to be set.
  30047. * @returns this effect.
  30048. */
  30049. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30050. /**
  30051. * 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)
  30052. * @param uniformName Name of the variable.
  30053. * @param array array to be set.
  30054. * @returns this effect.
  30055. */
  30056. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30057. /**
  30058. * Sets an array on a uniform variable.
  30059. * @param uniformName Name of the variable.
  30060. * @param array array to be set.
  30061. * @returns this effect.
  30062. */
  30063. setArray(uniformName: string, array: number[]): Effect;
  30064. /**
  30065. * 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)
  30066. * @param uniformName Name of the variable.
  30067. * @param array array to be set.
  30068. * @returns this effect.
  30069. */
  30070. setArray2(uniformName: string, array: number[]): Effect;
  30071. /**
  30072. * 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)
  30073. * @param uniformName Name of the variable.
  30074. * @param array array to be set.
  30075. * @returns this effect.
  30076. */
  30077. setArray3(uniformName: string, array: number[]): Effect;
  30078. /**
  30079. * 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)
  30080. * @param uniformName Name of the variable.
  30081. * @param array array to be set.
  30082. * @returns this effect.
  30083. */
  30084. setArray4(uniformName: string, array: number[]): Effect;
  30085. /**
  30086. * Sets matrices on a uniform variable.
  30087. * @param uniformName Name of the variable.
  30088. * @param matrices matrices to be set.
  30089. * @returns this effect.
  30090. */
  30091. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30092. /**
  30093. * Sets matrix on a uniform variable.
  30094. * @param uniformName Name of the variable.
  30095. * @param matrix matrix to be set.
  30096. * @returns this effect.
  30097. */
  30098. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30099. /**
  30100. * 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)
  30101. * @param uniformName Name of the variable.
  30102. * @param matrix matrix to be set.
  30103. * @returns this effect.
  30104. */
  30105. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30106. /**
  30107. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30108. * @param uniformName Name of the variable.
  30109. * @param matrix matrix to be set.
  30110. * @returns this effect.
  30111. */
  30112. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30113. /**
  30114. * Sets a float on a uniform variable.
  30115. * @param uniformName Name of the variable.
  30116. * @param value value to be set.
  30117. * @returns this effect.
  30118. */
  30119. setFloat(uniformName: string, value: number): Effect;
  30120. /**
  30121. * Sets a boolean on a uniform variable.
  30122. * @param uniformName Name of the variable.
  30123. * @param bool value to be set.
  30124. * @returns this effect.
  30125. */
  30126. setBool(uniformName: string, bool: boolean): Effect;
  30127. /**
  30128. * Sets a Vector2 on a uniform variable.
  30129. * @param uniformName Name of the variable.
  30130. * @param vector2 vector2 to be set.
  30131. * @returns this effect.
  30132. */
  30133. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30134. /**
  30135. * Sets a float2 on a uniform variable.
  30136. * @param uniformName Name of the variable.
  30137. * @param x First float in float2.
  30138. * @param y Second float in float2.
  30139. * @returns this effect.
  30140. */
  30141. setFloat2(uniformName: string, x: number, y: number): Effect;
  30142. /**
  30143. * Sets a Vector3 on a uniform variable.
  30144. * @param uniformName Name of the variable.
  30145. * @param vector3 Value to be set.
  30146. * @returns this effect.
  30147. */
  30148. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30149. /**
  30150. * Sets a float3 on a uniform variable.
  30151. * @param uniformName Name of the variable.
  30152. * @param x First float in float3.
  30153. * @param y Second float in float3.
  30154. * @param z Third float in float3.
  30155. * @returns this effect.
  30156. */
  30157. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30158. /**
  30159. * Sets a Vector4 on a uniform variable.
  30160. * @param uniformName Name of the variable.
  30161. * @param vector4 Value to be set.
  30162. * @returns this effect.
  30163. */
  30164. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30165. /**
  30166. * Sets a float4 on a uniform variable.
  30167. * @param uniformName Name of the variable.
  30168. * @param x First float in float4.
  30169. * @param y Second float in float4.
  30170. * @param z Third float in float4.
  30171. * @param w Fourth float in float4.
  30172. * @returns this effect.
  30173. */
  30174. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30175. /**
  30176. * Sets a Color3 on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param color3 Value to be set.
  30179. * @returns this effect.
  30180. */
  30181. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30182. /**
  30183. * Sets a Color4 on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param color3 Value to be set.
  30186. * @param alpha Alpha value to be set.
  30187. * @returns this effect.
  30188. */
  30189. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30190. /**
  30191. * Sets a Color4 on a uniform variable
  30192. * @param uniformName defines the name of the variable
  30193. * @param color4 defines the value to be set
  30194. * @returns this effect.
  30195. */
  30196. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30197. /** Release all associated resources */
  30198. dispose(): void;
  30199. /**
  30200. * This function will add a new shader to the shader store
  30201. * @param name the name of the shader
  30202. * @param pixelShader optional pixel shader content
  30203. * @param vertexShader optional vertex shader content
  30204. */
  30205. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30206. /**
  30207. * Store of each shader (The can be looked up using effect.key)
  30208. */
  30209. static ShadersStore: {
  30210. [key: string]: string;
  30211. };
  30212. /**
  30213. * Store of each included file for a shader (The can be looked up using effect.key)
  30214. */
  30215. static IncludesShadersStore: {
  30216. [key: string]: string;
  30217. };
  30218. /**
  30219. * Resets the cache of effects.
  30220. */
  30221. static ResetCache(): void;
  30222. }
  30223. }
  30224. declare module BABYLON {
  30225. /**
  30226. * Interface used to describe the capabilities of the engine relatively to the current browser
  30227. */
  30228. export interface EngineCapabilities {
  30229. /** Maximum textures units per fragment shader */
  30230. maxTexturesImageUnits: number;
  30231. /** Maximum texture units per vertex shader */
  30232. maxVertexTextureImageUnits: number;
  30233. /** Maximum textures units in the entire pipeline */
  30234. maxCombinedTexturesImageUnits: number;
  30235. /** Maximum texture size */
  30236. maxTextureSize: number;
  30237. /** Maximum texture samples */
  30238. maxSamples?: number;
  30239. /** Maximum cube texture size */
  30240. maxCubemapTextureSize: number;
  30241. /** Maximum render texture size */
  30242. maxRenderTextureSize: number;
  30243. /** Maximum number of vertex attributes */
  30244. maxVertexAttribs: number;
  30245. /** Maximum number of varyings */
  30246. maxVaryingVectors: number;
  30247. /** Maximum number of uniforms per vertex shader */
  30248. maxVertexUniformVectors: number;
  30249. /** Maximum number of uniforms per fragment shader */
  30250. maxFragmentUniformVectors: number;
  30251. /** Defines if standard derivates (dx/dy) are supported */
  30252. standardDerivatives: boolean;
  30253. /** Defines if s3tc texture compression is supported */
  30254. s3tc?: WEBGL_compressed_texture_s3tc;
  30255. /** Defines if pvrtc texture compression is supported */
  30256. pvrtc: any;
  30257. /** Defines if etc1 texture compression is supported */
  30258. etc1: any;
  30259. /** Defines if etc2 texture compression is supported */
  30260. etc2: any;
  30261. /** Defines if astc texture compression is supported */
  30262. astc: any;
  30263. /** Defines if float textures are supported */
  30264. textureFloat: boolean;
  30265. /** Defines if vertex array objects are supported */
  30266. vertexArrayObject: boolean;
  30267. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30268. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30269. /** Gets the maximum level of anisotropy supported */
  30270. maxAnisotropy: number;
  30271. /** Defines if instancing is supported */
  30272. instancedArrays: boolean;
  30273. /** Defines if 32 bits indices are supported */
  30274. uintIndices: boolean;
  30275. /** Defines if high precision shaders are supported */
  30276. highPrecisionShaderSupported: boolean;
  30277. /** Defines if depth reading in the fragment shader is supported */
  30278. fragmentDepthSupported: boolean;
  30279. /** Defines if float texture linear filtering is supported*/
  30280. textureFloatLinearFiltering: boolean;
  30281. /** Defines if rendering to float textures is supported */
  30282. textureFloatRender: boolean;
  30283. /** Defines if half float textures are supported*/
  30284. textureHalfFloat: boolean;
  30285. /** Defines if half float texture linear filtering is supported*/
  30286. textureHalfFloatLinearFiltering: boolean;
  30287. /** Defines if rendering to half float textures is supported */
  30288. textureHalfFloatRender: boolean;
  30289. /** Defines if textureLOD shader command is supported */
  30290. textureLOD: boolean;
  30291. /** Defines if draw buffers extension is supported */
  30292. drawBuffersExtension: boolean;
  30293. /** Defines if depth textures are supported */
  30294. depthTextureExtension: boolean;
  30295. /** Defines if float color buffer are supported */
  30296. colorBufferFloat: boolean;
  30297. /** Gets disjoint timer query extension (null if not supported) */
  30298. timerQuery?: EXT_disjoint_timer_query;
  30299. /** Defines if timestamp can be used with timer query */
  30300. canUseTimestampForTimerQuery: boolean;
  30301. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30302. multiview?: any;
  30303. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30304. oculusMultiview?: any;
  30305. /** Function used to let the system compiles shaders in background */
  30306. parallelShaderCompile?: {
  30307. COMPLETION_STATUS_KHR: number;
  30308. };
  30309. /** Max number of texture samples for MSAA */
  30310. maxMSAASamples: number;
  30311. /** Defines if the blend min max extension is supported */
  30312. blendMinMax: boolean;
  30313. }
  30314. }
  30315. declare module BABYLON {
  30316. /**
  30317. * @hidden
  30318. **/
  30319. export class DepthCullingState {
  30320. private _isDepthTestDirty;
  30321. private _isDepthMaskDirty;
  30322. private _isDepthFuncDirty;
  30323. private _isCullFaceDirty;
  30324. private _isCullDirty;
  30325. private _isZOffsetDirty;
  30326. private _isFrontFaceDirty;
  30327. private _depthTest;
  30328. private _depthMask;
  30329. private _depthFunc;
  30330. private _cull;
  30331. private _cullFace;
  30332. private _zOffset;
  30333. private _frontFace;
  30334. /**
  30335. * Initializes the state.
  30336. */
  30337. constructor();
  30338. get isDirty(): boolean;
  30339. get zOffset(): number;
  30340. set zOffset(value: number);
  30341. get cullFace(): Nullable<number>;
  30342. set cullFace(value: Nullable<number>);
  30343. get cull(): Nullable<boolean>;
  30344. set cull(value: Nullable<boolean>);
  30345. get depthFunc(): Nullable<number>;
  30346. set depthFunc(value: Nullable<number>);
  30347. get depthMask(): boolean;
  30348. set depthMask(value: boolean);
  30349. get depthTest(): boolean;
  30350. set depthTest(value: boolean);
  30351. get frontFace(): Nullable<number>;
  30352. set frontFace(value: Nullable<number>);
  30353. reset(): void;
  30354. apply(gl: WebGLRenderingContext): void;
  30355. }
  30356. }
  30357. declare module BABYLON {
  30358. /**
  30359. * @hidden
  30360. **/
  30361. export class StencilState {
  30362. /** 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 */
  30363. static readonly ALWAYS: number;
  30364. /** Passed to stencilOperation to specify that stencil value must be kept */
  30365. static readonly KEEP: number;
  30366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30367. static readonly REPLACE: number;
  30368. private _isStencilTestDirty;
  30369. private _isStencilMaskDirty;
  30370. private _isStencilFuncDirty;
  30371. private _isStencilOpDirty;
  30372. private _stencilTest;
  30373. private _stencilMask;
  30374. private _stencilFunc;
  30375. private _stencilFuncRef;
  30376. private _stencilFuncMask;
  30377. private _stencilOpStencilFail;
  30378. private _stencilOpDepthFail;
  30379. private _stencilOpStencilDepthPass;
  30380. get isDirty(): boolean;
  30381. get stencilFunc(): number;
  30382. set stencilFunc(value: number);
  30383. get stencilFuncRef(): number;
  30384. set stencilFuncRef(value: number);
  30385. get stencilFuncMask(): number;
  30386. set stencilFuncMask(value: number);
  30387. get stencilOpStencilFail(): number;
  30388. set stencilOpStencilFail(value: number);
  30389. get stencilOpDepthFail(): number;
  30390. set stencilOpDepthFail(value: number);
  30391. get stencilOpStencilDepthPass(): number;
  30392. set stencilOpStencilDepthPass(value: number);
  30393. get stencilMask(): number;
  30394. set stencilMask(value: number);
  30395. get stencilTest(): boolean;
  30396. set stencilTest(value: boolean);
  30397. constructor();
  30398. reset(): void;
  30399. apply(gl: WebGLRenderingContext): void;
  30400. }
  30401. }
  30402. declare module BABYLON {
  30403. /**
  30404. * @hidden
  30405. **/
  30406. export class AlphaState {
  30407. private _isAlphaBlendDirty;
  30408. private _isBlendFunctionParametersDirty;
  30409. private _isBlendEquationParametersDirty;
  30410. private _isBlendConstantsDirty;
  30411. private _alphaBlend;
  30412. private _blendFunctionParameters;
  30413. private _blendEquationParameters;
  30414. private _blendConstants;
  30415. /**
  30416. * Initializes the state.
  30417. */
  30418. constructor();
  30419. get isDirty(): boolean;
  30420. get alphaBlend(): boolean;
  30421. set alphaBlend(value: boolean);
  30422. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30423. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30424. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30425. reset(): void;
  30426. apply(gl: WebGLRenderingContext): void;
  30427. }
  30428. }
  30429. declare module BABYLON {
  30430. /** @hidden */
  30431. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30432. attributeProcessor(attribute: string): string;
  30433. varyingProcessor(varying: string, isFragment: boolean): string;
  30434. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30435. }
  30436. }
  30437. declare module BABYLON {
  30438. /**
  30439. * Interface for attribute information associated with buffer instanciation
  30440. */
  30441. export interface InstancingAttributeInfo {
  30442. /**
  30443. * Name of the GLSL attribute
  30444. * if attribute index is not specified, this is used to retrieve the index from the effect
  30445. */
  30446. attributeName: string;
  30447. /**
  30448. * Index/offset of the attribute in the vertex shader
  30449. * if not specified, this will be computes from the name.
  30450. */
  30451. index?: number;
  30452. /**
  30453. * size of the attribute, 1, 2, 3 or 4
  30454. */
  30455. attributeSize: number;
  30456. /**
  30457. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30458. */
  30459. offset: number;
  30460. /**
  30461. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30462. * default to 1
  30463. */
  30464. divisor?: number;
  30465. /**
  30466. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30467. * default is FLOAT
  30468. */
  30469. attributeType?: number;
  30470. /**
  30471. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30472. */
  30473. normalized?: boolean;
  30474. }
  30475. }
  30476. declare module BABYLON {
  30477. interface ThinEngine {
  30478. /**
  30479. * Update a video texture
  30480. * @param texture defines the texture to update
  30481. * @param video defines the video element to use
  30482. * @param invertY defines if data must be stored with Y axis inverted
  30483. */
  30484. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30485. }
  30486. }
  30487. declare module BABYLON {
  30488. /**
  30489. * Settings for finer control over video usage
  30490. */
  30491. export interface VideoTextureSettings {
  30492. /**
  30493. * Applies `autoplay` to video, if specified
  30494. */
  30495. autoPlay?: boolean;
  30496. /**
  30497. * Applies `loop` to video, if specified
  30498. */
  30499. loop?: boolean;
  30500. /**
  30501. * Automatically updates internal texture from video at every frame in the render loop
  30502. */
  30503. autoUpdateTexture: boolean;
  30504. /**
  30505. * Image src displayed during the video loading or until the user interacts with the video.
  30506. */
  30507. poster?: string;
  30508. }
  30509. /**
  30510. * If you want to display a video in your scene, this is the special texture for that.
  30511. * This special texture works similar to other textures, with the exception of a few parameters.
  30512. * @see https://doc.babylonjs.com/how_to/video_texture
  30513. */
  30514. export class VideoTexture extends Texture {
  30515. /**
  30516. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30517. */
  30518. readonly autoUpdateTexture: boolean;
  30519. /**
  30520. * The video instance used by the texture internally
  30521. */
  30522. readonly video: HTMLVideoElement;
  30523. private _onUserActionRequestedObservable;
  30524. /**
  30525. * Event triggerd when a dom action is required by the user to play the video.
  30526. * This happens due to recent changes in browser policies preventing video to auto start.
  30527. */
  30528. get onUserActionRequestedObservable(): Observable<Texture>;
  30529. private _generateMipMaps;
  30530. private _engine;
  30531. private _stillImageCaptured;
  30532. private _displayingPosterTexture;
  30533. private _settings;
  30534. private _createInternalTextureOnEvent;
  30535. private _frameId;
  30536. /**
  30537. * Creates a video texture.
  30538. * If you want to display a video in your scene, this is the special texture for that.
  30539. * This special texture works similar to other textures, with the exception of a few parameters.
  30540. * @see https://doc.babylonjs.com/how_to/video_texture
  30541. * @param name optional name, will detect from video source, if not defined
  30542. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30543. * @param scene is obviously the current scene.
  30544. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30545. * @param invertY is false by default but can be used to invert video on Y axis
  30546. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30547. * @param settings allows finer control over video usage
  30548. */
  30549. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30550. private _getName;
  30551. private _getVideo;
  30552. private _createInternalTexture;
  30553. private reset;
  30554. /**
  30555. * @hidden Internal method to initiate `update`.
  30556. */
  30557. _rebuild(): void;
  30558. /**
  30559. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30560. */
  30561. update(): void;
  30562. /**
  30563. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30564. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30565. */
  30566. updateTexture(isVisible: boolean): void;
  30567. protected _updateInternalTexture: () => void;
  30568. /**
  30569. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30570. * @param url New url.
  30571. */
  30572. updateURL(url: string): void;
  30573. /**
  30574. * Dispose the texture and release its associated resources.
  30575. */
  30576. dispose(): void;
  30577. /**
  30578. * Creates a video texture straight from a stream.
  30579. * @param scene Define the scene the texture should be created in
  30580. * @param stream Define the stream the texture should be created from
  30581. * @returns The created video texture as a promise
  30582. */
  30583. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30584. /**
  30585. * Creates a video texture straight from your WebCam video feed.
  30586. * @param scene Define the scene the texture should be created in
  30587. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30588. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30589. * @returns The created video texture as a promise
  30590. */
  30591. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30592. minWidth: number;
  30593. maxWidth: number;
  30594. minHeight: number;
  30595. maxHeight: number;
  30596. deviceId: string;
  30597. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30598. /**
  30599. * Creates a video texture straight from your WebCam video feed.
  30600. * @param scene Define the scene the texture should be created in
  30601. * @param onReady Define a callback to triggered once the texture will be ready
  30602. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30603. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30604. */
  30605. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30606. minWidth: number;
  30607. maxWidth: number;
  30608. minHeight: number;
  30609. maxHeight: number;
  30610. deviceId: string;
  30611. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * Defines the interface used by objects working like Scene
  30617. * @hidden
  30618. */
  30619. interface ISceneLike {
  30620. _addPendingData(data: any): void;
  30621. _removePendingData(data: any): void;
  30622. offlineProvider: IOfflineProvider;
  30623. }
  30624. /** Interface defining initialization parameters for Engine class */
  30625. export interface EngineOptions extends WebGLContextAttributes {
  30626. /**
  30627. * Defines if the engine should no exceed a specified device ratio
  30628. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30629. */
  30630. limitDeviceRatio?: number;
  30631. /**
  30632. * Defines if webvr should be enabled automatically
  30633. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30634. */
  30635. autoEnableWebVR?: boolean;
  30636. /**
  30637. * Defines if webgl2 should be turned off even if supported
  30638. * @see http://doc.babylonjs.com/features/webgl2
  30639. */
  30640. disableWebGL2Support?: boolean;
  30641. /**
  30642. * Defines if webaudio should be initialized as well
  30643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30644. */
  30645. audioEngine?: boolean;
  30646. /**
  30647. * Defines if animations should run using a deterministic lock step
  30648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30649. */
  30650. deterministicLockstep?: boolean;
  30651. /** Defines the maximum steps to use with deterministic lock step mode */
  30652. lockstepMaxSteps?: number;
  30653. /** Defines the seconds between each deterministic lock step */
  30654. timeStep?: number;
  30655. /**
  30656. * Defines that engine should ignore context lost events
  30657. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30658. */
  30659. doNotHandleContextLost?: boolean;
  30660. /**
  30661. * Defines that engine should ignore modifying touch action attribute and style
  30662. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30663. */
  30664. doNotHandleTouchAction?: boolean;
  30665. /**
  30666. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30667. */
  30668. useHighPrecisionFloats?: boolean;
  30669. }
  30670. /**
  30671. * The base engine class (root of all engines)
  30672. */
  30673. export class ThinEngine {
  30674. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30675. static ExceptionList: ({
  30676. key: string;
  30677. capture: string;
  30678. captureConstraint: number;
  30679. targets: string[];
  30680. } | {
  30681. key: string;
  30682. capture: null;
  30683. captureConstraint: null;
  30684. targets: string[];
  30685. })[];
  30686. /** @hidden */
  30687. static _TextureLoaders: IInternalTextureLoader[];
  30688. /**
  30689. * Returns the current npm package of the sdk
  30690. */
  30691. static get NpmPackage(): string;
  30692. /**
  30693. * Returns the current version of the framework
  30694. */
  30695. static get Version(): string;
  30696. /**
  30697. * Returns a string describing the current engine
  30698. */
  30699. get description(): string;
  30700. /**
  30701. * Gets or sets the epsilon value used by collision engine
  30702. */
  30703. static CollisionsEpsilon: number;
  30704. /**
  30705. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30706. */
  30707. static get ShadersRepository(): string;
  30708. static set ShadersRepository(value: string);
  30709. /**
  30710. * Gets or sets the textures that the engine should not attempt to load as compressed
  30711. */
  30712. protected _excludedCompressedTextures: string[];
  30713. /**
  30714. * Filters the compressed texture formats to only include
  30715. * files that are not included in the skippable list
  30716. *
  30717. * @param url the current extension
  30718. * @param textureFormatInUse the current compressed texture format
  30719. * @returns "format" string
  30720. */
  30721. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30722. /** @hidden */
  30723. _shaderProcessor: IShaderProcessor;
  30724. /**
  30725. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30726. */
  30727. forcePOTTextures: boolean;
  30728. /**
  30729. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30730. */
  30731. isFullscreen: boolean;
  30732. /**
  30733. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30734. */
  30735. cullBackFaces: boolean;
  30736. /**
  30737. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30738. */
  30739. renderEvenInBackground: boolean;
  30740. /**
  30741. * Gets or sets a boolean indicating that cache can be kept between frames
  30742. */
  30743. preventCacheWipeBetweenFrames: boolean;
  30744. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30745. validateShaderPrograms: boolean;
  30746. /**
  30747. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30748. * This can provide greater z depth for distant objects.
  30749. */
  30750. useReverseDepthBuffer: boolean;
  30751. /**
  30752. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30753. */
  30754. disableUniformBuffers: boolean;
  30755. /** @hidden */
  30756. _uniformBuffers: UniformBuffer[];
  30757. /**
  30758. * Gets a boolean indicating that the engine supports uniform buffers
  30759. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30760. */
  30761. get supportsUniformBuffers(): boolean;
  30762. /** @hidden */
  30763. _gl: WebGLRenderingContext;
  30764. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30765. protected _windowIsBackground: boolean;
  30766. protected _webGLVersion: number;
  30767. protected _creationOptions: EngineOptions;
  30768. protected _highPrecisionShadersAllowed: boolean;
  30769. /** @hidden */
  30770. get _shouldUseHighPrecisionShader(): boolean;
  30771. /**
  30772. * Gets a boolean indicating that only power of 2 textures are supported
  30773. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30774. */
  30775. get needPOTTextures(): boolean;
  30776. /** @hidden */
  30777. _badOS: boolean;
  30778. /** @hidden */
  30779. _badDesktopOS: boolean;
  30780. private _hardwareScalingLevel;
  30781. /** @hidden */
  30782. _caps: EngineCapabilities;
  30783. private _isStencilEnable;
  30784. private _glVersion;
  30785. private _glRenderer;
  30786. private _glVendor;
  30787. /** @hidden */
  30788. _videoTextureSupported: boolean;
  30789. protected _renderingQueueLaunched: boolean;
  30790. protected _activeRenderLoops: (() => void)[];
  30791. /**
  30792. * Observable signaled when a context lost event is raised
  30793. */
  30794. onContextLostObservable: Observable<ThinEngine>;
  30795. /**
  30796. * Observable signaled when a context restored event is raised
  30797. */
  30798. onContextRestoredObservable: Observable<ThinEngine>;
  30799. private _onContextLost;
  30800. private _onContextRestored;
  30801. protected _contextWasLost: boolean;
  30802. /** @hidden */
  30803. _doNotHandleContextLost: boolean;
  30804. /**
  30805. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30807. */
  30808. get doNotHandleContextLost(): boolean;
  30809. set doNotHandleContextLost(value: boolean);
  30810. /**
  30811. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30812. */
  30813. disableVertexArrayObjects: boolean;
  30814. /** @hidden */
  30815. protected _colorWrite: boolean;
  30816. /** @hidden */
  30817. protected _colorWriteChanged: boolean;
  30818. /** @hidden */
  30819. protected _depthCullingState: DepthCullingState;
  30820. /** @hidden */
  30821. protected _stencilState: StencilState;
  30822. /** @hidden */
  30823. _alphaState: AlphaState;
  30824. /** @hidden */
  30825. _alphaMode: number;
  30826. /** @hidden */
  30827. _alphaEquation: number;
  30828. /** @hidden */
  30829. _internalTexturesCache: InternalTexture[];
  30830. /** @hidden */
  30831. protected _activeChannel: number;
  30832. private _currentTextureChannel;
  30833. /** @hidden */
  30834. protected _boundTexturesCache: {
  30835. [key: string]: Nullable<InternalTexture>;
  30836. };
  30837. /** @hidden */
  30838. protected _currentEffect: Nullable<Effect>;
  30839. /** @hidden */
  30840. protected _currentProgram: Nullable<WebGLProgram>;
  30841. private _compiledEffects;
  30842. private _vertexAttribArraysEnabled;
  30843. /** @hidden */
  30844. protected _cachedViewport: Nullable<IViewportLike>;
  30845. private _cachedVertexArrayObject;
  30846. /** @hidden */
  30847. protected _cachedVertexBuffers: any;
  30848. /** @hidden */
  30849. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30850. /** @hidden */
  30851. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30852. /** @hidden */
  30853. _currentRenderTarget: Nullable<InternalTexture>;
  30854. private _uintIndicesCurrentlySet;
  30855. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30856. /** @hidden */
  30857. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30858. private _currentBufferPointers;
  30859. private _currentInstanceLocations;
  30860. private _currentInstanceBuffers;
  30861. private _textureUnits;
  30862. /** @hidden */
  30863. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30864. /** @hidden */
  30865. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30866. /** @hidden */
  30867. _boundRenderFunction: any;
  30868. private _vaoRecordInProgress;
  30869. private _mustWipeVertexAttributes;
  30870. private _emptyTexture;
  30871. private _emptyCubeTexture;
  30872. private _emptyTexture3D;
  30873. private _emptyTexture2DArray;
  30874. /** @hidden */
  30875. _frameHandler: number;
  30876. private _nextFreeTextureSlots;
  30877. private _maxSimultaneousTextures;
  30878. private _activeRequests;
  30879. protected _texturesSupported: string[];
  30880. /** @hidden */
  30881. _textureFormatInUse: Nullable<string>;
  30882. protected get _supportsHardwareTextureRescaling(): boolean;
  30883. /**
  30884. * Gets the list of texture formats supported
  30885. */
  30886. get texturesSupported(): Array<string>;
  30887. /**
  30888. * Gets the list of texture formats in use
  30889. */
  30890. get textureFormatInUse(): Nullable<string>;
  30891. /**
  30892. * Gets the current viewport
  30893. */
  30894. get currentViewport(): Nullable<IViewportLike>;
  30895. /**
  30896. * Gets the default empty texture
  30897. */
  30898. get emptyTexture(): InternalTexture;
  30899. /**
  30900. * Gets the default empty 3D texture
  30901. */
  30902. get emptyTexture3D(): InternalTexture;
  30903. /**
  30904. * Gets the default empty 2D array texture
  30905. */
  30906. get emptyTexture2DArray(): InternalTexture;
  30907. /**
  30908. * Gets the default empty cube texture
  30909. */
  30910. get emptyCubeTexture(): InternalTexture;
  30911. /**
  30912. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30913. */
  30914. readonly premultipliedAlpha: boolean;
  30915. /**
  30916. * Observable event triggered before each texture is initialized
  30917. */
  30918. onBeforeTextureInitObservable: Observable<Texture>;
  30919. /**
  30920. * Creates a new engine
  30921. * @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
  30922. * @param antialias defines enable antialiasing (default: false)
  30923. * @param options defines further options to be sent to the getContext() function
  30924. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30925. */
  30926. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30927. private _rebuildInternalTextures;
  30928. private _rebuildEffects;
  30929. /**
  30930. * Gets a boolean indicating if all created effects are ready
  30931. * @returns true if all effects are ready
  30932. */
  30933. areAllEffectsReady(): boolean;
  30934. protected _rebuildBuffers(): void;
  30935. private _initGLContext;
  30936. /**
  30937. * Gets version of the current webGL context
  30938. */
  30939. get webGLVersion(): number;
  30940. /**
  30941. * Gets a string idenfifying the name of the class
  30942. * @returns "Engine" string
  30943. */
  30944. getClassName(): string;
  30945. /**
  30946. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30947. */
  30948. get isStencilEnable(): boolean;
  30949. /** @hidden */
  30950. _prepareWorkingCanvas(): void;
  30951. /**
  30952. * Reset the texture cache to empty state
  30953. */
  30954. resetTextureCache(): void;
  30955. /**
  30956. * Gets an object containing information about the current webGL context
  30957. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30958. */
  30959. getGlInfo(): {
  30960. vendor: string;
  30961. renderer: string;
  30962. version: string;
  30963. };
  30964. /**
  30965. * Defines the hardware scaling level.
  30966. * By default the hardware scaling level is computed from the window device ratio.
  30967. * 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.
  30968. * @param level defines the level to use
  30969. */
  30970. setHardwareScalingLevel(level: number): void;
  30971. /**
  30972. * Gets the current hardware scaling level.
  30973. * By default the hardware scaling level is computed from the window device ratio.
  30974. * 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.
  30975. * @returns a number indicating the current hardware scaling level
  30976. */
  30977. getHardwareScalingLevel(): number;
  30978. /**
  30979. * Gets the list of loaded textures
  30980. * @returns an array containing all loaded textures
  30981. */
  30982. getLoadedTexturesCache(): InternalTexture[];
  30983. /**
  30984. * Gets the object containing all engine capabilities
  30985. * @returns the EngineCapabilities object
  30986. */
  30987. getCaps(): EngineCapabilities;
  30988. /**
  30989. * stop executing a render loop function and remove it from the execution array
  30990. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30991. */
  30992. stopRenderLoop(renderFunction?: () => void): void;
  30993. /** @hidden */
  30994. _renderLoop(): void;
  30995. /**
  30996. * Gets the HTML canvas attached with the current webGL context
  30997. * @returns a HTML canvas
  30998. */
  30999. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31000. /**
  31001. * Gets host window
  31002. * @returns the host window object
  31003. */
  31004. getHostWindow(): Nullable<Window>;
  31005. /**
  31006. * Gets the current render width
  31007. * @param useScreen defines if screen size must be used (or the current render target if any)
  31008. * @returns a number defining the current render width
  31009. */
  31010. getRenderWidth(useScreen?: boolean): number;
  31011. /**
  31012. * Gets the current render height
  31013. * @param useScreen defines if screen size must be used (or the current render target if any)
  31014. * @returns a number defining the current render height
  31015. */
  31016. getRenderHeight(useScreen?: boolean): number;
  31017. /**
  31018. * Can be used to override the current requestAnimationFrame requester.
  31019. * @hidden
  31020. */
  31021. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31022. /**
  31023. * Register and execute a render loop. The engine can have more than one render function
  31024. * @param renderFunction defines the function to continuously execute
  31025. */
  31026. runRenderLoop(renderFunction: () => void): void;
  31027. /**
  31028. * Clear the current render buffer or the current render target (if any is set up)
  31029. * @param color defines the color to use
  31030. * @param backBuffer defines if the back buffer must be cleared
  31031. * @param depth defines if the depth buffer must be cleared
  31032. * @param stencil defines if the stencil buffer must be cleared
  31033. */
  31034. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31035. private _viewportCached;
  31036. /** @hidden */
  31037. _viewport(x: number, y: number, width: number, height: number): void;
  31038. /**
  31039. * Set the WebGL's viewport
  31040. * @param viewport defines the viewport element to be used
  31041. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31042. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31043. */
  31044. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31045. /**
  31046. * Begin a new frame
  31047. */
  31048. beginFrame(): void;
  31049. /**
  31050. * Enf the current frame
  31051. */
  31052. endFrame(): void;
  31053. /**
  31054. * Resize the view according to the canvas' size
  31055. */
  31056. resize(): void;
  31057. /**
  31058. * Force a specific size of the canvas
  31059. * @param width defines the new canvas' width
  31060. * @param height defines the new canvas' height
  31061. */
  31062. setSize(width: number, height: number): void;
  31063. /**
  31064. * Binds the frame buffer to the specified texture.
  31065. * @param texture The texture to render to or null for the default canvas
  31066. * @param faceIndex The face of the texture to render to in case of cube texture
  31067. * @param requiredWidth The width of the target to render to
  31068. * @param requiredHeight The height of the target to render to
  31069. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31070. * @param depthStencilTexture The depth stencil texture to use to render
  31071. * @param lodLevel defines le lod level to bind to the frame buffer
  31072. */
  31073. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31074. /** @hidden */
  31075. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31076. /**
  31077. * Unbind the current render target texture from the webGL context
  31078. * @param texture defines the render target texture to unbind
  31079. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31080. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31081. */
  31082. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31083. /**
  31084. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31085. */
  31086. flushFramebuffer(): void;
  31087. /**
  31088. * Unbind the current render target and bind the default framebuffer
  31089. */
  31090. restoreDefaultFramebuffer(): void;
  31091. /** @hidden */
  31092. protected _resetVertexBufferBinding(): void;
  31093. /**
  31094. * Creates a vertex buffer
  31095. * @param data the data for the vertex buffer
  31096. * @returns the new WebGL static buffer
  31097. */
  31098. createVertexBuffer(data: DataArray): DataBuffer;
  31099. private _createVertexBuffer;
  31100. /**
  31101. * Creates a dynamic vertex buffer
  31102. * @param data the data for the dynamic vertex buffer
  31103. * @returns the new WebGL dynamic buffer
  31104. */
  31105. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31106. protected _resetIndexBufferBinding(): void;
  31107. /**
  31108. * Creates a new index buffer
  31109. * @param indices defines the content of the index buffer
  31110. * @param updatable defines if the index buffer must be updatable
  31111. * @returns a new webGL buffer
  31112. */
  31113. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31114. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31115. /**
  31116. * Bind a webGL buffer to the webGL context
  31117. * @param buffer defines the buffer to bind
  31118. */
  31119. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31120. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31121. private bindBuffer;
  31122. /**
  31123. * update the bound buffer with the given data
  31124. * @param data defines the data to update
  31125. */
  31126. updateArrayBuffer(data: Float32Array): void;
  31127. private _vertexAttribPointer;
  31128. private _bindIndexBufferWithCache;
  31129. private _bindVertexBuffersAttributes;
  31130. /**
  31131. * Records a vertex array object
  31132. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31133. * @param vertexBuffers defines the list of vertex buffers to store
  31134. * @param indexBuffer defines the index buffer to store
  31135. * @param effect defines the effect to store
  31136. * @returns the new vertex array object
  31137. */
  31138. recordVertexArrayObject(vertexBuffers: {
  31139. [key: string]: VertexBuffer;
  31140. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31141. /**
  31142. * Bind a specific vertex array object
  31143. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31144. * @param vertexArrayObject defines the vertex array object to bind
  31145. * @param indexBuffer defines the index buffer to bind
  31146. */
  31147. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31148. /**
  31149. * Bind webGl buffers directly to the webGL context
  31150. * @param vertexBuffer defines the vertex buffer to bind
  31151. * @param indexBuffer defines the index buffer to bind
  31152. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31153. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31154. * @param effect defines the effect associated with the vertex buffer
  31155. */
  31156. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31157. private _unbindVertexArrayObject;
  31158. /**
  31159. * Bind a list of vertex buffers to the webGL context
  31160. * @param vertexBuffers defines the list of vertex buffers to bind
  31161. * @param indexBuffer defines the index buffer to bind
  31162. * @param effect defines the effect associated with the vertex buffers
  31163. */
  31164. bindBuffers(vertexBuffers: {
  31165. [key: string]: Nullable<VertexBuffer>;
  31166. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31167. /**
  31168. * Unbind all instance attributes
  31169. */
  31170. unbindInstanceAttributes(): void;
  31171. /**
  31172. * Release and free the memory of a vertex array object
  31173. * @param vao defines the vertex array object to delete
  31174. */
  31175. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31176. /** @hidden */
  31177. _releaseBuffer(buffer: DataBuffer): boolean;
  31178. protected _deleteBuffer(buffer: DataBuffer): void;
  31179. /**
  31180. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31181. * @param instancesBuffer defines the webGL buffer to update and bind
  31182. * @param data defines the data to store in the buffer
  31183. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31184. */
  31185. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31186. /**
  31187. * Bind the content of a webGL buffer used with instanciation
  31188. * @param instancesBuffer defines the webGL buffer to bind
  31189. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31190. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31191. */
  31192. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31193. /**
  31194. * Disable the instance attribute corresponding to the name in parameter
  31195. * @param name defines the name of the attribute to disable
  31196. */
  31197. disableInstanceAttributeByName(name: string): void;
  31198. /**
  31199. * Disable the instance attribute corresponding to the location in parameter
  31200. * @param attributeLocation defines the attribute location of the attribute to disable
  31201. */
  31202. disableInstanceAttribute(attributeLocation: number): void;
  31203. /**
  31204. * Disable the attribute corresponding to the location in parameter
  31205. * @param attributeLocation defines the attribute location of the attribute to disable
  31206. */
  31207. disableAttributeByIndex(attributeLocation: number): void;
  31208. /**
  31209. * Send a draw order
  31210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31211. * @param indexStart defines the starting index
  31212. * @param indexCount defines the number of index to draw
  31213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31214. */
  31215. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31216. /**
  31217. * Draw a list of points
  31218. * @param verticesStart defines the index of first vertex to draw
  31219. * @param verticesCount defines the count of vertices to draw
  31220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31221. */
  31222. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31223. /**
  31224. * Draw a list of unindexed primitives
  31225. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31226. * @param verticesStart defines the index of first vertex to draw
  31227. * @param verticesCount defines the count of vertices to draw
  31228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31229. */
  31230. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31231. /**
  31232. * Draw a list of indexed primitives
  31233. * @param fillMode defines the primitive to use
  31234. * @param indexStart defines the starting index
  31235. * @param indexCount defines the number of index to draw
  31236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31237. */
  31238. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31239. /**
  31240. * Draw a list of unindexed primitives
  31241. * @param fillMode defines the primitive to use
  31242. * @param verticesStart defines the index of first vertex to draw
  31243. * @param verticesCount defines the count of vertices to draw
  31244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31245. */
  31246. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31247. private _drawMode;
  31248. /** @hidden */
  31249. protected _reportDrawCall(): void;
  31250. /** @hidden */
  31251. _releaseEffect(effect: Effect): void;
  31252. /** @hidden */
  31253. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31254. /**
  31255. * Create a new effect (used to store vertex/fragment shaders)
  31256. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31257. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31258. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31259. * @param samplers defines an array of string used to represent textures
  31260. * @param defines defines the string containing the defines to use to compile the shaders
  31261. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31262. * @param onCompiled defines a function to call when the effect creation is successful
  31263. * @param onError defines a function to call when the effect creation has failed
  31264. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31265. * @returns the new Effect
  31266. */
  31267. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31268. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31269. private _compileShader;
  31270. private _compileRawShader;
  31271. /**
  31272. * Directly creates a webGL program
  31273. * @param pipelineContext defines the pipeline context to attach to
  31274. * @param vertexCode defines the vertex shader code to use
  31275. * @param fragmentCode defines the fragment shader code to use
  31276. * @param context defines the webGL context to use (if not set, the current one will be used)
  31277. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31278. * @returns the new webGL program
  31279. */
  31280. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31281. /**
  31282. * Creates a webGL program
  31283. * @param pipelineContext defines the pipeline context to attach to
  31284. * @param vertexCode defines the vertex shader code to use
  31285. * @param fragmentCode defines the fragment shader code to use
  31286. * @param defines defines the string containing the defines to use to compile the shaders
  31287. * @param context defines the webGL context to use (if not set, the current one will be used)
  31288. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31289. * @returns the new webGL program
  31290. */
  31291. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31292. /**
  31293. * Creates a new pipeline context
  31294. * @returns the new pipeline
  31295. */
  31296. createPipelineContext(): IPipelineContext;
  31297. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31298. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31299. /** @hidden */
  31300. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31301. /** @hidden */
  31302. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31303. /** @hidden */
  31304. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31305. /**
  31306. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31307. * @param pipelineContext defines the pipeline context to use
  31308. * @param uniformsNames defines the list of uniform names
  31309. * @returns an array of webGL uniform locations
  31310. */
  31311. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31312. /**
  31313. * Gets the lsit of active attributes for a given webGL program
  31314. * @param pipelineContext defines the pipeline context to use
  31315. * @param attributesNames defines the list of attribute names to get
  31316. * @returns an array of indices indicating the offset of each attribute
  31317. */
  31318. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31319. /**
  31320. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31321. * @param effect defines the effect to activate
  31322. */
  31323. enableEffect(effect: Nullable<Effect>): void;
  31324. /**
  31325. * Set the value of an uniform to a number (int)
  31326. * @param uniform defines the webGL uniform location where to store the value
  31327. * @param value defines the int number to store
  31328. */
  31329. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31330. /**
  31331. * Set the value of an uniform to an array of int32
  31332. * @param uniform defines the webGL uniform location where to store the value
  31333. * @param array defines the array of int32 to store
  31334. */
  31335. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31336. /**
  31337. * Set the value of an uniform to an array of int32 (stored as vec2)
  31338. * @param uniform defines the webGL uniform location where to store the value
  31339. * @param array defines the array of int32 to store
  31340. */
  31341. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31342. /**
  31343. * Set the value of an uniform to an array of int32 (stored as vec3)
  31344. * @param uniform defines the webGL uniform location where to store the value
  31345. * @param array defines the array of int32 to store
  31346. */
  31347. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31348. /**
  31349. * Set the value of an uniform to an array of int32 (stored as vec4)
  31350. * @param uniform defines the webGL uniform location where to store the value
  31351. * @param array defines the array of int32 to store
  31352. */
  31353. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31354. /**
  31355. * Set the value of an uniform to an array of number
  31356. * @param uniform defines the webGL uniform location where to store the value
  31357. * @param array defines the array of number to store
  31358. */
  31359. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31360. /**
  31361. * Set the value of an uniform to an array of number (stored as vec2)
  31362. * @param uniform defines the webGL uniform location where to store the value
  31363. * @param array defines the array of number to store
  31364. */
  31365. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31366. /**
  31367. * Set the value of an uniform to an array of number (stored as vec3)
  31368. * @param uniform defines the webGL uniform location where to store the value
  31369. * @param array defines the array of number to store
  31370. */
  31371. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31372. /**
  31373. * Set the value of an uniform to an array of number (stored as vec4)
  31374. * @param uniform defines the webGL uniform location where to store the value
  31375. * @param array defines the array of number to store
  31376. */
  31377. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31378. /**
  31379. * Set the value of an uniform to an array of float32 (stored as matrices)
  31380. * @param uniform defines the webGL uniform location where to store the value
  31381. * @param matrices defines the array of float32 to store
  31382. */
  31383. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31384. /**
  31385. * Set the value of an uniform to a matrix (3x3)
  31386. * @param uniform defines the webGL uniform location where to store the value
  31387. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31388. */
  31389. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31390. /**
  31391. * Set the value of an uniform to a matrix (2x2)
  31392. * @param uniform defines the webGL uniform location where to store the value
  31393. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31394. */
  31395. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31396. /**
  31397. * Set the value of an uniform to a number (float)
  31398. * @param uniform defines the webGL uniform location where to store the value
  31399. * @param value defines the float number to store
  31400. */
  31401. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31402. /**
  31403. * Set the value of an uniform to a vec2
  31404. * @param uniform defines the webGL uniform location where to store the value
  31405. * @param x defines the 1st component of the value
  31406. * @param y defines the 2nd component of the value
  31407. */
  31408. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31409. /**
  31410. * Set the value of an uniform to a vec3
  31411. * @param uniform defines the webGL uniform location where to store the value
  31412. * @param x defines the 1st component of the value
  31413. * @param y defines the 2nd component of the value
  31414. * @param z defines the 3rd component of the value
  31415. */
  31416. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31417. /**
  31418. * Set the value of an uniform to a vec4
  31419. * @param uniform defines the webGL uniform location where to store the value
  31420. * @param x defines the 1st component of the value
  31421. * @param y defines the 2nd component of the value
  31422. * @param z defines the 3rd component of the value
  31423. * @param w defines the 4th component of the value
  31424. */
  31425. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31426. /**
  31427. * Apply all cached states (depth, culling, stencil and alpha)
  31428. */
  31429. applyStates(): void;
  31430. /**
  31431. * Enable or disable color writing
  31432. * @param enable defines the state to set
  31433. */
  31434. setColorWrite(enable: boolean): void;
  31435. /**
  31436. * Gets a boolean indicating if color writing is enabled
  31437. * @returns the current color writing state
  31438. */
  31439. getColorWrite(): boolean;
  31440. /**
  31441. * Gets the depth culling state manager
  31442. */
  31443. get depthCullingState(): DepthCullingState;
  31444. /**
  31445. * Gets the alpha state manager
  31446. */
  31447. get alphaState(): AlphaState;
  31448. /**
  31449. * Gets the stencil state manager
  31450. */
  31451. get stencilState(): StencilState;
  31452. /**
  31453. * Clears the list of texture accessible through engine.
  31454. * This can help preventing texture load conflict due to name collision.
  31455. */
  31456. clearInternalTexturesCache(): void;
  31457. /**
  31458. * Force the entire cache to be cleared
  31459. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31460. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31461. */
  31462. wipeCaches(bruteForce?: boolean): void;
  31463. /** @hidden */
  31464. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31465. min: number;
  31466. mag: number;
  31467. };
  31468. /** @hidden */
  31469. _createTexture(): WebGLTexture;
  31470. /**
  31471. * Usually called from Texture.ts.
  31472. * Passed information to create a WebGLTexture
  31473. * @param urlArg defines a value which contains one of the following:
  31474. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31475. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31476. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31478. * @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)
  31479. * @param scene needed for loading to the correct scene
  31480. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31481. * @param onLoad optional callback to be called upon successful completion
  31482. * @param onError optional callback to be called upon failure
  31483. * @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
  31484. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31485. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31486. * @param forcedExtension defines the extension to use to pick the right loader
  31487. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31488. * @param mimeType defines an optional mime type
  31489. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31490. */
  31491. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31492. /**
  31493. * @hidden
  31494. */
  31495. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31496. /**
  31497. * Creates a raw texture
  31498. * @param data defines the data to store in the texture
  31499. * @param width defines the width of the texture
  31500. * @param height defines the height of the texture
  31501. * @param format defines the format of the data
  31502. * @param generateMipMaps defines if the engine should generate the mip levels
  31503. * @param invertY defines if data must be stored with Y axis inverted
  31504. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31505. * @param compression defines the compression used (null by default)
  31506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31507. * @returns the raw texture inside an InternalTexture
  31508. */
  31509. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31510. /**
  31511. * Creates a new raw cube texture
  31512. * @param data defines the array of data to use to create each face
  31513. * @param size defines the size of the textures
  31514. * @param format defines the format of the data
  31515. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31516. * @param generateMipMaps defines if the engine should generate the mip levels
  31517. * @param invertY defines if data must be stored with Y axis inverted
  31518. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31519. * @param compression defines the compression used (null by default)
  31520. * @returns the cube texture as an InternalTexture
  31521. */
  31522. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31523. /**
  31524. * Creates a new raw 3D texture
  31525. * @param data defines the data used to create the texture
  31526. * @param width defines the width of the texture
  31527. * @param height defines the height of the texture
  31528. * @param depth defines the depth of the texture
  31529. * @param format defines the format of the texture
  31530. * @param generateMipMaps defines if the engine must generate mip levels
  31531. * @param invertY defines if data must be stored with Y axis inverted
  31532. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31533. * @param compression defines the compressed used (can be null)
  31534. * @param textureType defines the compressed used (can be null)
  31535. * @returns a new raw 3D texture (stored in an InternalTexture)
  31536. */
  31537. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31538. /**
  31539. * Creates a new raw 2D array texture
  31540. * @param data defines the data used to create the texture
  31541. * @param width defines the width of the texture
  31542. * @param height defines the height of the texture
  31543. * @param depth defines the number of layers of the texture
  31544. * @param format defines the format of the texture
  31545. * @param generateMipMaps defines if the engine must generate mip levels
  31546. * @param invertY defines if data must be stored with Y axis inverted
  31547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31548. * @param compression defines the compressed used (can be null)
  31549. * @param textureType defines the compressed used (can be null)
  31550. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31551. */
  31552. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31553. private _unpackFlipYCached;
  31554. /**
  31555. * In case you are sharing the context with other applications, it might
  31556. * be interested to not cache the unpack flip y state to ensure a consistent
  31557. * value would be set.
  31558. */
  31559. enableUnpackFlipYCached: boolean;
  31560. /** @hidden */
  31561. _unpackFlipY(value: boolean): void;
  31562. /** @hidden */
  31563. _getUnpackAlignement(): number;
  31564. private _getTextureTarget;
  31565. /**
  31566. * Update the sampling mode of a given texture
  31567. * @param samplingMode defines the required sampling mode
  31568. * @param texture defines the texture to update
  31569. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31570. */
  31571. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31572. /**
  31573. * Update the sampling mode of a given texture
  31574. * @param texture defines the texture to update
  31575. * @param wrapU defines the texture wrap mode of the u coordinates
  31576. * @param wrapV defines the texture wrap mode of the v coordinates
  31577. * @param wrapR defines the texture wrap mode of the r coordinates
  31578. */
  31579. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31580. /** @hidden */
  31581. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31582. width: number;
  31583. height: number;
  31584. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31585. /** @hidden */
  31586. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31587. /** @hidden */
  31588. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31589. /** @hidden */
  31590. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31591. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31592. private _prepareWebGLTexture;
  31593. /** @hidden */
  31594. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31595. private _getDepthStencilBuffer;
  31596. /** @hidden */
  31597. _releaseFramebufferObjects(texture: InternalTexture): void;
  31598. /** @hidden */
  31599. _releaseTexture(texture: InternalTexture): void;
  31600. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31601. protected _setProgram(program: WebGLProgram): void;
  31602. protected _boundUniforms: {
  31603. [key: number]: WebGLUniformLocation;
  31604. };
  31605. /**
  31606. * Binds an effect to the webGL context
  31607. * @param effect defines the effect to bind
  31608. */
  31609. bindSamplers(effect: Effect): void;
  31610. private _activateCurrentTexture;
  31611. /** @hidden */
  31612. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31613. /** @hidden */
  31614. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31615. /**
  31616. * Unbind all textures from the webGL context
  31617. */
  31618. unbindAllTextures(): void;
  31619. /**
  31620. * Sets a texture to the according uniform.
  31621. * @param channel The texture channel
  31622. * @param uniform The uniform to set
  31623. * @param texture The texture to apply
  31624. */
  31625. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31626. private _bindSamplerUniformToChannel;
  31627. private _getTextureWrapMode;
  31628. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31629. /**
  31630. * Sets an array of texture to the webGL context
  31631. * @param channel defines the channel where the texture array must be set
  31632. * @param uniform defines the associated uniform location
  31633. * @param textures defines the array of textures to bind
  31634. */
  31635. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31636. /** @hidden */
  31637. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31638. private _setTextureParameterFloat;
  31639. private _setTextureParameterInteger;
  31640. /**
  31641. * Unbind all vertex attributes from the webGL context
  31642. */
  31643. unbindAllAttributes(): void;
  31644. /**
  31645. * 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
  31646. */
  31647. releaseEffects(): void;
  31648. /**
  31649. * Dispose and release all associated resources
  31650. */
  31651. dispose(): void;
  31652. /**
  31653. * Attach a new callback raised when context lost event is fired
  31654. * @param callback defines the callback to call
  31655. */
  31656. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31657. /**
  31658. * Attach a new callback raised when context restored event is fired
  31659. * @param callback defines the callback to call
  31660. */
  31661. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31662. /**
  31663. * Get the current error code of the webGL context
  31664. * @returns the error code
  31665. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31666. */
  31667. getError(): number;
  31668. private _canRenderToFloatFramebuffer;
  31669. private _canRenderToHalfFloatFramebuffer;
  31670. private _canRenderToFramebuffer;
  31671. /** @hidden */
  31672. _getWebGLTextureType(type: number): number;
  31673. /** @hidden */
  31674. _getInternalFormat(format: number): number;
  31675. /** @hidden */
  31676. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31677. /** @hidden */
  31678. _getRGBAMultiSampleBufferFormat(type: number): number;
  31679. /** @hidden */
  31680. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31681. /**
  31682. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31683. * @param x defines the x coordinate of the rectangle where pixels must be read
  31684. * @param y defines the y coordinate of the rectangle where pixels must be read
  31685. * @param width defines the width of the rectangle where pixels must be read
  31686. * @param height defines the height of the rectangle where pixels must be read
  31687. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31688. * @returns a Uint8Array containing RGBA colors
  31689. */
  31690. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31691. private static _isSupported;
  31692. /**
  31693. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31694. * @returns true if the engine can be created
  31695. * @ignorenaming
  31696. */
  31697. static isSupported(): boolean;
  31698. /**
  31699. * Find the next highest power of two.
  31700. * @param x Number to start search from.
  31701. * @return Next highest power of two.
  31702. */
  31703. static CeilingPOT(x: number): number;
  31704. /**
  31705. * Find the next lowest power of two.
  31706. * @param x Number to start search from.
  31707. * @return Next lowest power of two.
  31708. */
  31709. static FloorPOT(x: number): number;
  31710. /**
  31711. * Find the nearest power of two.
  31712. * @param x Number to start search from.
  31713. * @return Next nearest power of two.
  31714. */
  31715. static NearestPOT(x: number): number;
  31716. /**
  31717. * Get the closest exponent of two
  31718. * @param value defines the value to approximate
  31719. * @param max defines the maximum value to return
  31720. * @param mode defines how to define the closest value
  31721. * @returns closest exponent of two of the given value
  31722. */
  31723. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31724. /**
  31725. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31726. * @param func - the function to be called
  31727. * @param requester - the object that will request the next frame. Falls back to window.
  31728. * @returns frame number
  31729. */
  31730. static QueueNewFrame(func: () => void, requester?: any): number;
  31731. /**
  31732. * Gets host document
  31733. * @returns the host document object
  31734. */
  31735. getHostDocument(): Nullable<Document>;
  31736. }
  31737. }
  31738. declare module BABYLON {
  31739. /**
  31740. * Class representing spherical harmonics coefficients to the 3rd degree
  31741. */
  31742. export class SphericalHarmonics {
  31743. /**
  31744. * Defines whether or not the harmonics have been prescaled for rendering.
  31745. */
  31746. preScaled: boolean;
  31747. /**
  31748. * The l0,0 coefficients of the spherical harmonics
  31749. */
  31750. l00: Vector3;
  31751. /**
  31752. * The l1,-1 coefficients of the spherical harmonics
  31753. */
  31754. l1_1: Vector3;
  31755. /**
  31756. * The l1,0 coefficients of the spherical harmonics
  31757. */
  31758. l10: Vector3;
  31759. /**
  31760. * The l1,1 coefficients of the spherical harmonics
  31761. */
  31762. l11: Vector3;
  31763. /**
  31764. * The l2,-2 coefficients of the spherical harmonics
  31765. */
  31766. l2_2: Vector3;
  31767. /**
  31768. * The l2,-1 coefficients of the spherical harmonics
  31769. */
  31770. l2_1: Vector3;
  31771. /**
  31772. * The l2,0 coefficients of the spherical harmonics
  31773. */
  31774. l20: Vector3;
  31775. /**
  31776. * The l2,1 coefficients of the spherical harmonics
  31777. */
  31778. l21: Vector3;
  31779. /**
  31780. * The l2,2 coefficients of the spherical harmonics
  31781. */
  31782. l22: Vector3;
  31783. /**
  31784. * Adds a light to the spherical harmonics
  31785. * @param direction the direction of the light
  31786. * @param color the color of the light
  31787. * @param deltaSolidAngle the delta solid angle of the light
  31788. */
  31789. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31790. /**
  31791. * Scales the spherical harmonics by the given amount
  31792. * @param scale the amount to scale
  31793. */
  31794. scaleInPlace(scale: number): void;
  31795. /**
  31796. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31797. *
  31798. * ```
  31799. * E_lm = A_l * L_lm
  31800. * ```
  31801. *
  31802. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31803. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31804. * the scaling factors are given in equation 9.
  31805. */
  31806. convertIncidentRadianceToIrradiance(): void;
  31807. /**
  31808. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31809. *
  31810. * ```
  31811. * L = (1/pi) * E * rho
  31812. * ```
  31813. *
  31814. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31815. */
  31816. convertIrradianceToLambertianRadiance(): void;
  31817. /**
  31818. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31819. * required operations at run time.
  31820. *
  31821. * This is simply done by scaling back the SH with Ylm constants parameter.
  31822. * The trigonometric part being applied by the shader at run time.
  31823. */
  31824. preScaleForRendering(): void;
  31825. /**
  31826. * Constructs a spherical harmonics from an array.
  31827. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31828. * @returns the spherical harmonics
  31829. */
  31830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31831. /**
  31832. * Gets the spherical harmonics from polynomial
  31833. * @param polynomial the spherical polynomial
  31834. * @returns the spherical harmonics
  31835. */
  31836. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31837. }
  31838. /**
  31839. * Class representing spherical polynomial coefficients to the 3rd degree
  31840. */
  31841. export class SphericalPolynomial {
  31842. private _harmonics;
  31843. /**
  31844. * The spherical harmonics used to create the polynomials.
  31845. */
  31846. get preScaledHarmonics(): SphericalHarmonics;
  31847. /**
  31848. * The x coefficients of the spherical polynomial
  31849. */
  31850. x: Vector3;
  31851. /**
  31852. * The y coefficients of the spherical polynomial
  31853. */
  31854. y: Vector3;
  31855. /**
  31856. * The z coefficients of the spherical polynomial
  31857. */
  31858. z: Vector3;
  31859. /**
  31860. * The xx coefficients of the spherical polynomial
  31861. */
  31862. xx: Vector3;
  31863. /**
  31864. * The yy coefficients of the spherical polynomial
  31865. */
  31866. yy: Vector3;
  31867. /**
  31868. * The zz coefficients of the spherical polynomial
  31869. */
  31870. zz: Vector3;
  31871. /**
  31872. * The xy coefficients of the spherical polynomial
  31873. */
  31874. xy: Vector3;
  31875. /**
  31876. * The yz coefficients of the spherical polynomial
  31877. */
  31878. yz: Vector3;
  31879. /**
  31880. * The zx coefficients of the spherical polynomial
  31881. */
  31882. zx: Vector3;
  31883. /**
  31884. * Adds an ambient color to the spherical polynomial
  31885. * @param color the color to add
  31886. */
  31887. addAmbient(color: Color3): void;
  31888. /**
  31889. * Scales the spherical polynomial by the given amount
  31890. * @param scale the amount to scale
  31891. */
  31892. scaleInPlace(scale: number): void;
  31893. /**
  31894. * Gets the spherical polynomial from harmonics
  31895. * @param harmonics the spherical harmonics
  31896. * @returns the spherical polynomial
  31897. */
  31898. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31899. /**
  31900. * Constructs a spherical polynomial from an array.
  31901. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31902. * @returns the spherical polynomial
  31903. */
  31904. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31905. }
  31906. }
  31907. declare module BABYLON {
  31908. /**
  31909. * Defines the source of the internal texture
  31910. */
  31911. export enum InternalTextureSource {
  31912. /**
  31913. * The source of the texture data is unknown
  31914. */
  31915. Unknown = 0,
  31916. /**
  31917. * Texture data comes from an URL
  31918. */
  31919. Url = 1,
  31920. /**
  31921. * Texture data is only used for temporary storage
  31922. */
  31923. Temp = 2,
  31924. /**
  31925. * Texture data comes from raw data (ArrayBuffer)
  31926. */
  31927. Raw = 3,
  31928. /**
  31929. * Texture content is dynamic (video or dynamic texture)
  31930. */
  31931. Dynamic = 4,
  31932. /**
  31933. * Texture content is generated by rendering to it
  31934. */
  31935. RenderTarget = 5,
  31936. /**
  31937. * Texture content is part of a multi render target process
  31938. */
  31939. MultiRenderTarget = 6,
  31940. /**
  31941. * Texture data comes from a cube data file
  31942. */
  31943. Cube = 7,
  31944. /**
  31945. * Texture data comes from a raw cube data
  31946. */
  31947. CubeRaw = 8,
  31948. /**
  31949. * Texture data come from a prefiltered cube data file
  31950. */
  31951. CubePrefiltered = 9,
  31952. /**
  31953. * Texture content is raw 3D data
  31954. */
  31955. Raw3D = 10,
  31956. /**
  31957. * Texture content is raw 2D array data
  31958. */
  31959. Raw2DArray = 11,
  31960. /**
  31961. * Texture content is a depth texture
  31962. */
  31963. Depth = 12,
  31964. /**
  31965. * Texture data comes from a raw cube data encoded with RGBD
  31966. */
  31967. CubeRawRGBD = 13
  31968. }
  31969. /**
  31970. * Class used to store data associated with WebGL texture data for the engine
  31971. * This class should not be used directly
  31972. */
  31973. export class InternalTexture {
  31974. /** @hidden */
  31975. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31976. /**
  31977. * Defines if the texture is ready
  31978. */
  31979. isReady: boolean;
  31980. /**
  31981. * Defines if the texture is a cube texture
  31982. */
  31983. isCube: boolean;
  31984. /**
  31985. * Defines if the texture contains 3D data
  31986. */
  31987. is3D: boolean;
  31988. /**
  31989. * Defines if the texture contains 2D array data
  31990. */
  31991. is2DArray: boolean;
  31992. /**
  31993. * Defines if the texture contains multiview data
  31994. */
  31995. isMultiview: boolean;
  31996. /**
  31997. * Gets the URL used to load this texture
  31998. */
  31999. url: string;
  32000. /**
  32001. * Gets the sampling mode of the texture
  32002. */
  32003. samplingMode: number;
  32004. /**
  32005. * Gets a boolean indicating if the texture needs mipmaps generation
  32006. */
  32007. generateMipMaps: boolean;
  32008. /**
  32009. * Gets the number of samples used by the texture (WebGL2+ only)
  32010. */
  32011. samples: number;
  32012. /**
  32013. * Gets the type of the texture (int, float...)
  32014. */
  32015. type: number;
  32016. /**
  32017. * Gets the format of the texture (RGB, RGBA...)
  32018. */
  32019. format: number;
  32020. /**
  32021. * Observable called when the texture is loaded
  32022. */
  32023. onLoadedObservable: Observable<InternalTexture>;
  32024. /**
  32025. * Gets the width of the texture
  32026. */
  32027. width: number;
  32028. /**
  32029. * Gets the height of the texture
  32030. */
  32031. height: number;
  32032. /**
  32033. * Gets the depth of the texture
  32034. */
  32035. depth: number;
  32036. /**
  32037. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32038. */
  32039. baseWidth: number;
  32040. /**
  32041. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32042. */
  32043. baseHeight: number;
  32044. /**
  32045. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32046. */
  32047. baseDepth: number;
  32048. /**
  32049. * Gets a boolean indicating if the texture is inverted on Y axis
  32050. */
  32051. invertY: boolean;
  32052. /** @hidden */
  32053. _invertVScale: boolean;
  32054. /** @hidden */
  32055. _associatedChannel: number;
  32056. /** @hidden */
  32057. _source: InternalTextureSource;
  32058. /** @hidden */
  32059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32060. /** @hidden */
  32061. _bufferView: Nullable<ArrayBufferView>;
  32062. /** @hidden */
  32063. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32064. /** @hidden */
  32065. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32066. /** @hidden */
  32067. _size: number;
  32068. /** @hidden */
  32069. _extension: string;
  32070. /** @hidden */
  32071. _files: Nullable<string[]>;
  32072. /** @hidden */
  32073. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32074. /** @hidden */
  32075. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32076. /** @hidden */
  32077. _framebuffer: Nullable<WebGLFramebuffer>;
  32078. /** @hidden */
  32079. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32080. /** @hidden */
  32081. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32082. /** @hidden */
  32083. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32084. /** @hidden */
  32085. _attachments: Nullable<number[]>;
  32086. /** @hidden */
  32087. _cachedCoordinatesMode: Nullable<number>;
  32088. /** @hidden */
  32089. _cachedWrapU: Nullable<number>;
  32090. /** @hidden */
  32091. _cachedWrapV: Nullable<number>;
  32092. /** @hidden */
  32093. _cachedWrapR: Nullable<number>;
  32094. /** @hidden */
  32095. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32096. /** @hidden */
  32097. _isDisabled: boolean;
  32098. /** @hidden */
  32099. _compression: Nullable<string>;
  32100. /** @hidden */
  32101. _generateStencilBuffer: boolean;
  32102. /** @hidden */
  32103. _generateDepthBuffer: boolean;
  32104. /** @hidden */
  32105. _comparisonFunction: number;
  32106. /** @hidden */
  32107. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32108. /** @hidden */
  32109. _lodGenerationScale: number;
  32110. /** @hidden */
  32111. _lodGenerationOffset: number;
  32112. /** @hidden */
  32113. _colorTextureArray: Nullable<WebGLTexture>;
  32114. /** @hidden */
  32115. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32116. /** @hidden */
  32117. _lodTextureHigh: Nullable<BaseTexture>;
  32118. /** @hidden */
  32119. _lodTextureMid: Nullable<BaseTexture>;
  32120. /** @hidden */
  32121. _lodTextureLow: Nullable<BaseTexture>;
  32122. /** @hidden */
  32123. _isRGBD: boolean;
  32124. /** @hidden */
  32125. _linearSpecularLOD: boolean;
  32126. /** @hidden */
  32127. _irradianceTexture: Nullable<BaseTexture>;
  32128. /** @hidden */
  32129. _webGLTexture: Nullable<WebGLTexture>;
  32130. /** @hidden */
  32131. _references: number;
  32132. private _engine;
  32133. /**
  32134. * Gets the Engine the texture belongs to.
  32135. * @returns The babylon engine
  32136. */
  32137. getEngine(): ThinEngine;
  32138. /**
  32139. * Gets the data source type of the texture
  32140. */
  32141. get source(): InternalTextureSource;
  32142. /**
  32143. * Creates a new InternalTexture
  32144. * @param engine defines the engine to use
  32145. * @param source defines the type of data that will be used
  32146. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32147. */
  32148. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32149. /**
  32150. * Increments the number of references (ie. the number of Texture that point to it)
  32151. */
  32152. incrementReferences(): void;
  32153. /**
  32154. * Change the size of the texture (not the size of the content)
  32155. * @param width defines the new width
  32156. * @param height defines the new height
  32157. * @param depth defines the new depth (1 by default)
  32158. */
  32159. updateSize(width: int, height: int, depth?: int): void;
  32160. /** @hidden */
  32161. _rebuild(): void;
  32162. /** @hidden */
  32163. _swapAndDie(target: InternalTexture): void;
  32164. /**
  32165. * Dispose the current allocated resources
  32166. */
  32167. dispose(): void;
  32168. }
  32169. }
  32170. declare module BABYLON {
  32171. /**
  32172. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32174. */
  32175. export class Analyser {
  32176. /**
  32177. * Gets or sets the smoothing
  32178. * @ignorenaming
  32179. */
  32180. SMOOTHING: number;
  32181. /**
  32182. * Gets or sets the FFT table size
  32183. * @ignorenaming
  32184. */
  32185. FFT_SIZE: number;
  32186. /**
  32187. * Gets or sets the bar graph amplitude
  32188. * @ignorenaming
  32189. */
  32190. BARGRAPHAMPLITUDE: number;
  32191. /**
  32192. * Gets or sets the position of the debug canvas
  32193. * @ignorenaming
  32194. */
  32195. DEBUGCANVASPOS: {
  32196. x: number;
  32197. y: number;
  32198. };
  32199. /**
  32200. * Gets or sets the debug canvas size
  32201. * @ignorenaming
  32202. */
  32203. DEBUGCANVASSIZE: {
  32204. width: number;
  32205. height: number;
  32206. };
  32207. private _byteFreqs;
  32208. private _byteTime;
  32209. private _floatFreqs;
  32210. private _webAudioAnalyser;
  32211. private _debugCanvas;
  32212. private _debugCanvasContext;
  32213. private _scene;
  32214. private _registerFunc;
  32215. private _audioEngine;
  32216. /**
  32217. * Creates a new analyser
  32218. * @param scene defines hosting scene
  32219. */
  32220. constructor(scene: Scene);
  32221. /**
  32222. * Get the number of data values you will have to play with for the visualization
  32223. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32224. * @returns a number
  32225. */
  32226. getFrequencyBinCount(): number;
  32227. /**
  32228. * Gets the current frequency data as a byte array
  32229. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32230. * @returns a Uint8Array
  32231. */
  32232. getByteFrequencyData(): Uint8Array;
  32233. /**
  32234. * Gets the current waveform as a byte array
  32235. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32236. * @returns a Uint8Array
  32237. */
  32238. getByteTimeDomainData(): Uint8Array;
  32239. /**
  32240. * Gets the current frequency data as a float array
  32241. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32242. * @returns a Float32Array
  32243. */
  32244. getFloatFrequencyData(): Float32Array;
  32245. /**
  32246. * Renders the debug canvas
  32247. */
  32248. drawDebugCanvas(): void;
  32249. /**
  32250. * Stops rendering the debug canvas and removes it
  32251. */
  32252. stopDebugCanvas(): void;
  32253. /**
  32254. * Connects two audio nodes
  32255. * @param inputAudioNode defines first node to connect
  32256. * @param outputAudioNode defines second node to connect
  32257. */
  32258. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32259. /**
  32260. * Releases all associated resources
  32261. */
  32262. dispose(): void;
  32263. }
  32264. }
  32265. declare module BABYLON {
  32266. /**
  32267. * This represents an audio engine and it is responsible
  32268. * to play, synchronize and analyse sounds throughout the application.
  32269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32270. */
  32271. export interface IAudioEngine extends IDisposable {
  32272. /**
  32273. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32274. */
  32275. readonly canUseWebAudio: boolean;
  32276. /**
  32277. * Gets the current AudioContext if available.
  32278. */
  32279. readonly audioContext: Nullable<AudioContext>;
  32280. /**
  32281. * The master gain node defines the global audio volume of your audio engine.
  32282. */
  32283. readonly masterGain: GainNode;
  32284. /**
  32285. * Gets whether or not mp3 are supported by your browser.
  32286. */
  32287. readonly isMP3supported: boolean;
  32288. /**
  32289. * Gets whether or not ogg are supported by your browser.
  32290. */
  32291. readonly isOGGsupported: boolean;
  32292. /**
  32293. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32294. * @ignoreNaming
  32295. */
  32296. WarnedWebAudioUnsupported: boolean;
  32297. /**
  32298. * Defines if the audio engine relies on a custom unlocked button.
  32299. * In this case, the embedded button will not be displayed.
  32300. */
  32301. useCustomUnlockedButton: boolean;
  32302. /**
  32303. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32304. */
  32305. readonly unlocked: boolean;
  32306. /**
  32307. * Event raised when audio has been unlocked on the browser.
  32308. */
  32309. onAudioUnlockedObservable: Observable<AudioEngine>;
  32310. /**
  32311. * Event raised when audio has been locked on the browser.
  32312. */
  32313. onAudioLockedObservable: Observable<AudioEngine>;
  32314. /**
  32315. * Flags the audio engine in Locked state.
  32316. * This happens due to new browser policies preventing audio to autoplay.
  32317. */
  32318. lock(): void;
  32319. /**
  32320. * Unlocks the audio engine once a user action has been done on the dom.
  32321. * This is helpful to resume play once browser policies have been satisfied.
  32322. */
  32323. unlock(): void;
  32324. }
  32325. /**
  32326. * This represents the default audio engine used in babylon.
  32327. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32329. */
  32330. export class AudioEngine implements IAudioEngine {
  32331. private _audioContext;
  32332. private _audioContextInitialized;
  32333. private _muteButton;
  32334. private _hostElement;
  32335. /**
  32336. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32337. */
  32338. canUseWebAudio: boolean;
  32339. /**
  32340. * The master gain node defines the global audio volume of your audio engine.
  32341. */
  32342. masterGain: GainNode;
  32343. /**
  32344. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32345. * @ignoreNaming
  32346. */
  32347. WarnedWebAudioUnsupported: boolean;
  32348. /**
  32349. * Gets whether or not mp3 are supported by your browser.
  32350. */
  32351. isMP3supported: boolean;
  32352. /**
  32353. * Gets whether or not ogg are supported by your browser.
  32354. */
  32355. isOGGsupported: boolean;
  32356. /**
  32357. * Gets whether audio has been unlocked on the device.
  32358. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32359. * a user interaction has happened.
  32360. */
  32361. unlocked: boolean;
  32362. /**
  32363. * Defines if the audio engine relies on a custom unlocked button.
  32364. * In this case, the embedded button will not be displayed.
  32365. */
  32366. useCustomUnlockedButton: boolean;
  32367. /**
  32368. * Event raised when audio has been unlocked on the browser.
  32369. */
  32370. onAudioUnlockedObservable: Observable<AudioEngine>;
  32371. /**
  32372. * Event raised when audio has been locked on the browser.
  32373. */
  32374. onAudioLockedObservable: Observable<AudioEngine>;
  32375. /**
  32376. * Gets the current AudioContext if available.
  32377. */
  32378. get audioContext(): Nullable<AudioContext>;
  32379. private _connectedAnalyser;
  32380. /**
  32381. * Instantiates a new audio engine.
  32382. *
  32383. * There should be only one per page as some browsers restrict the number
  32384. * of audio contexts you can create.
  32385. * @param hostElement defines the host element where to display the mute icon if necessary
  32386. */
  32387. constructor(hostElement?: Nullable<HTMLElement>);
  32388. /**
  32389. * Flags the audio engine in Locked state.
  32390. * This happens due to new browser policies preventing audio to autoplay.
  32391. */
  32392. lock(): void;
  32393. /**
  32394. * Unlocks the audio engine once a user action has been done on the dom.
  32395. * This is helpful to resume play once browser policies have been satisfied.
  32396. */
  32397. unlock(): void;
  32398. private _resumeAudioContext;
  32399. private _initializeAudioContext;
  32400. private _tryToRun;
  32401. private _triggerRunningState;
  32402. private _triggerSuspendedState;
  32403. private _displayMuteButton;
  32404. private _moveButtonToTopLeft;
  32405. private _onResize;
  32406. private _hideMuteButton;
  32407. /**
  32408. * Destroy and release the resources associated with the audio ccontext.
  32409. */
  32410. dispose(): void;
  32411. /**
  32412. * Gets the global volume sets on the master gain.
  32413. * @returns the global volume if set or -1 otherwise
  32414. */
  32415. getGlobalVolume(): number;
  32416. /**
  32417. * Sets the global volume of your experience (sets on the master gain).
  32418. * @param newVolume Defines the new global volume of the application
  32419. */
  32420. setGlobalVolume(newVolume: number): void;
  32421. /**
  32422. * Connect the audio engine to an audio analyser allowing some amazing
  32423. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32425. * @param analyser The analyser to connect to the engine
  32426. */
  32427. connectToAnalyser(analyser: Analyser): void;
  32428. }
  32429. }
  32430. declare module BABYLON {
  32431. /**
  32432. * Interface used to present a loading screen while loading a scene
  32433. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32434. */
  32435. export interface ILoadingScreen {
  32436. /**
  32437. * Function called to display the loading screen
  32438. */
  32439. displayLoadingUI: () => void;
  32440. /**
  32441. * Function called to hide the loading screen
  32442. */
  32443. hideLoadingUI: () => void;
  32444. /**
  32445. * Gets or sets the color to use for the background
  32446. */
  32447. loadingUIBackgroundColor: string;
  32448. /**
  32449. * Gets or sets the text to display while loading
  32450. */
  32451. loadingUIText: string;
  32452. }
  32453. /**
  32454. * Class used for the default loading screen
  32455. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32456. */
  32457. export class DefaultLoadingScreen implements ILoadingScreen {
  32458. private _renderingCanvas;
  32459. private _loadingText;
  32460. private _loadingDivBackgroundColor;
  32461. private _loadingDiv;
  32462. private _loadingTextDiv;
  32463. /** Gets or sets the logo url to use for the default loading screen */
  32464. static DefaultLogoUrl: string;
  32465. /** Gets or sets the spinner url to use for the default loading screen */
  32466. static DefaultSpinnerUrl: string;
  32467. /**
  32468. * Creates a new default loading screen
  32469. * @param _renderingCanvas defines the canvas used to render the scene
  32470. * @param _loadingText defines the default text to display
  32471. * @param _loadingDivBackgroundColor defines the default background color
  32472. */
  32473. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32474. /**
  32475. * Function called to display the loading screen
  32476. */
  32477. displayLoadingUI(): void;
  32478. /**
  32479. * Function called to hide the loading screen
  32480. */
  32481. hideLoadingUI(): void;
  32482. /**
  32483. * Gets or sets the text to display while loading
  32484. */
  32485. set loadingUIText(text: string);
  32486. get loadingUIText(): string;
  32487. /**
  32488. * Gets or sets the color to use for the background
  32489. */
  32490. get loadingUIBackgroundColor(): string;
  32491. set loadingUIBackgroundColor(color: string);
  32492. private _resizeLoadingUI;
  32493. }
  32494. }
  32495. declare module BABYLON {
  32496. /**
  32497. * Interface for any object that can request an animation frame
  32498. */
  32499. export interface ICustomAnimationFrameRequester {
  32500. /**
  32501. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32502. */
  32503. renderFunction?: Function;
  32504. /**
  32505. * Called to request the next frame to render to
  32506. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32507. */
  32508. requestAnimationFrame: Function;
  32509. /**
  32510. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32511. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32512. */
  32513. requestID?: number;
  32514. }
  32515. }
  32516. declare module BABYLON {
  32517. /**
  32518. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32519. */
  32520. export class PerformanceMonitor {
  32521. private _enabled;
  32522. private _rollingFrameTime;
  32523. private _lastFrameTimeMs;
  32524. /**
  32525. * constructor
  32526. * @param frameSampleSize The number of samples required to saturate the sliding window
  32527. */
  32528. constructor(frameSampleSize?: number);
  32529. /**
  32530. * Samples current frame
  32531. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32532. */
  32533. sampleFrame(timeMs?: number): void;
  32534. /**
  32535. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32536. */
  32537. get averageFrameTime(): number;
  32538. /**
  32539. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32540. */
  32541. get averageFrameTimeVariance(): number;
  32542. /**
  32543. * Returns the frame time of the most recent frame
  32544. */
  32545. get instantaneousFrameTime(): number;
  32546. /**
  32547. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32548. */
  32549. get averageFPS(): number;
  32550. /**
  32551. * Returns the average framerate in frames per second using the most recent frame time
  32552. */
  32553. get instantaneousFPS(): number;
  32554. /**
  32555. * Returns true if enough samples have been taken to completely fill the sliding window
  32556. */
  32557. get isSaturated(): boolean;
  32558. /**
  32559. * Enables contributions to the sliding window sample set
  32560. */
  32561. enable(): void;
  32562. /**
  32563. * Disables contributions to the sliding window sample set
  32564. * Samples will not be interpolated over the disabled period
  32565. */
  32566. disable(): void;
  32567. /**
  32568. * Returns true if sampling is enabled
  32569. */
  32570. get isEnabled(): boolean;
  32571. /**
  32572. * Resets performance monitor
  32573. */
  32574. reset(): void;
  32575. }
  32576. /**
  32577. * RollingAverage
  32578. *
  32579. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32580. */
  32581. export class RollingAverage {
  32582. /**
  32583. * Current average
  32584. */
  32585. average: number;
  32586. /**
  32587. * Current variance
  32588. */
  32589. variance: number;
  32590. protected _samples: Array<number>;
  32591. protected _sampleCount: number;
  32592. protected _pos: number;
  32593. protected _m2: number;
  32594. /**
  32595. * constructor
  32596. * @param length The number of samples required to saturate the sliding window
  32597. */
  32598. constructor(length: number);
  32599. /**
  32600. * Adds a sample to the sample set
  32601. * @param v The sample value
  32602. */
  32603. add(v: number): void;
  32604. /**
  32605. * Returns previously added values or null if outside of history or outside the sliding window domain
  32606. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32607. * @return Value previously recorded with add() or null if outside of range
  32608. */
  32609. history(i: number): number;
  32610. /**
  32611. * Returns true if enough samples have been taken to completely fill the sliding window
  32612. * @return true if sample-set saturated
  32613. */
  32614. isSaturated(): boolean;
  32615. /**
  32616. * Resets the rolling average (equivalent to 0 samples taken so far)
  32617. */
  32618. reset(): void;
  32619. /**
  32620. * Wraps a value around the sample range boundaries
  32621. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32622. * @return Wrapped position in sample range
  32623. */
  32624. protected _wrapPosition(i: number): number;
  32625. }
  32626. }
  32627. declare module BABYLON {
  32628. /**
  32629. * This class is used to track a performance counter which is number based.
  32630. * The user has access to many properties which give statistics of different nature.
  32631. *
  32632. * The implementer can track two kinds of Performance Counter: time and count.
  32633. * 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.
  32634. * 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.
  32635. */
  32636. export class PerfCounter {
  32637. /**
  32638. * Gets or sets a global boolean to turn on and off all the counters
  32639. */
  32640. static Enabled: boolean;
  32641. /**
  32642. * Returns the smallest value ever
  32643. */
  32644. get min(): number;
  32645. /**
  32646. * Returns the biggest value ever
  32647. */
  32648. get max(): number;
  32649. /**
  32650. * Returns the average value since the performance counter is running
  32651. */
  32652. get average(): number;
  32653. /**
  32654. * Returns the average value of the last second the counter was monitored
  32655. */
  32656. get lastSecAverage(): number;
  32657. /**
  32658. * Returns the current value
  32659. */
  32660. get current(): number;
  32661. /**
  32662. * Gets the accumulated total
  32663. */
  32664. get total(): number;
  32665. /**
  32666. * Gets the total value count
  32667. */
  32668. get count(): number;
  32669. /**
  32670. * Creates a new counter
  32671. */
  32672. constructor();
  32673. /**
  32674. * Call this method to start monitoring a new frame.
  32675. * 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.
  32676. */
  32677. fetchNewFrame(): void;
  32678. /**
  32679. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32680. * @param newCount the count value to add to the monitored count
  32681. * @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.
  32682. */
  32683. addCount(newCount: number, fetchResult: boolean): void;
  32684. /**
  32685. * Start monitoring this performance counter
  32686. */
  32687. beginMonitoring(): void;
  32688. /**
  32689. * Compute the time lapsed since the previous beginMonitoring() call.
  32690. * @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
  32691. */
  32692. endMonitoring(newFrame?: boolean): void;
  32693. private _fetchResult;
  32694. private _startMonitoringTime;
  32695. private _min;
  32696. private _max;
  32697. private _average;
  32698. private _current;
  32699. private _totalValueCount;
  32700. private _totalAccumulated;
  32701. private _lastSecAverage;
  32702. private _lastSecAccumulated;
  32703. private _lastSecTime;
  32704. private _lastSecValueCount;
  32705. }
  32706. }
  32707. declare module BABYLON {
  32708. interface ThinEngine {
  32709. /**
  32710. * Sets alpha constants used by some alpha blending modes
  32711. * @param r defines the red component
  32712. * @param g defines the green component
  32713. * @param b defines the blue component
  32714. * @param a defines the alpha component
  32715. */
  32716. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32717. /**
  32718. * Sets the current alpha mode
  32719. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32720. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32721. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32722. */
  32723. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32724. /**
  32725. * Gets the current alpha mode
  32726. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32727. * @returns the current alpha mode
  32728. */
  32729. getAlphaMode(): number;
  32730. /**
  32731. * Sets the current alpha equation
  32732. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32733. */
  32734. setAlphaEquation(equation: number): void;
  32735. /**
  32736. * Gets the current alpha equation.
  32737. * @returns the current alpha equation
  32738. */
  32739. getAlphaEquation(): number;
  32740. }
  32741. }
  32742. declare module BABYLON {
  32743. /**
  32744. * Defines the interface used by display changed events
  32745. */
  32746. export interface IDisplayChangedEventArgs {
  32747. /** Gets the vrDisplay object (if any) */
  32748. vrDisplay: Nullable<any>;
  32749. /** Gets a boolean indicating if webVR is supported */
  32750. vrSupported: boolean;
  32751. }
  32752. /**
  32753. * Defines the interface used by objects containing a viewport (like a camera)
  32754. */
  32755. interface IViewportOwnerLike {
  32756. /**
  32757. * Gets or sets the viewport
  32758. */
  32759. viewport: IViewportLike;
  32760. }
  32761. /**
  32762. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32763. */
  32764. export class Engine extends ThinEngine {
  32765. /** Defines that alpha blending is disabled */
  32766. static readonly ALPHA_DISABLE: number;
  32767. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32768. static readonly ALPHA_ADD: number;
  32769. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32770. static readonly ALPHA_COMBINE: number;
  32771. /** Defines that alpha blending to DEST - SRC * DEST */
  32772. static readonly ALPHA_SUBTRACT: number;
  32773. /** Defines that alpha blending to SRC * DEST */
  32774. static readonly ALPHA_MULTIPLY: number;
  32775. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32776. static readonly ALPHA_MAXIMIZED: number;
  32777. /** Defines that alpha blending to SRC + DEST */
  32778. static readonly ALPHA_ONEONE: number;
  32779. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32780. static readonly ALPHA_PREMULTIPLIED: number;
  32781. /**
  32782. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32783. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32784. */
  32785. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32786. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32787. static readonly ALPHA_INTERPOLATE: number;
  32788. /**
  32789. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32790. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32791. */
  32792. static readonly ALPHA_SCREENMODE: number;
  32793. /** Defines that the ressource is not delayed*/
  32794. static readonly DELAYLOADSTATE_NONE: number;
  32795. /** Defines that the ressource was successfully delay loaded */
  32796. static readonly DELAYLOADSTATE_LOADED: number;
  32797. /** Defines that the ressource is currently delay loading */
  32798. static readonly DELAYLOADSTATE_LOADING: number;
  32799. /** Defines that the ressource is delayed and has not started loading */
  32800. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32802. static readonly NEVER: number;
  32803. /** 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 */
  32804. static readonly ALWAYS: number;
  32805. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32806. static readonly LESS: number;
  32807. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32808. static readonly EQUAL: number;
  32809. /** 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 */
  32810. static readonly LEQUAL: number;
  32811. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32812. static readonly GREATER: number;
  32813. /** 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 */
  32814. static readonly GEQUAL: number;
  32815. /** 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 */
  32816. static readonly NOTEQUAL: number;
  32817. /** Passed to stencilOperation to specify that stencil value must be kept */
  32818. static readonly KEEP: number;
  32819. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32820. static readonly REPLACE: number;
  32821. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32822. static readonly INCR: number;
  32823. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32824. static readonly DECR: number;
  32825. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32826. static readonly INVERT: number;
  32827. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32828. static readonly INCR_WRAP: number;
  32829. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32830. static readonly DECR_WRAP: number;
  32831. /** Texture is not repeating outside of 0..1 UVs */
  32832. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32833. /** Texture is repeating outside of 0..1 UVs */
  32834. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32835. /** Texture is repeating and mirrored */
  32836. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32837. /** ALPHA */
  32838. static readonly TEXTUREFORMAT_ALPHA: number;
  32839. /** LUMINANCE */
  32840. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32841. /** LUMINANCE_ALPHA */
  32842. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32843. /** RGB */
  32844. static readonly TEXTUREFORMAT_RGB: number;
  32845. /** RGBA */
  32846. static readonly TEXTUREFORMAT_RGBA: number;
  32847. /** RED */
  32848. static readonly TEXTUREFORMAT_RED: number;
  32849. /** RED (2nd reference) */
  32850. static readonly TEXTUREFORMAT_R: number;
  32851. /** RG */
  32852. static readonly TEXTUREFORMAT_RG: number;
  32853. /** RED_INTEGER */
  32854. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32855. /** RED_INTEGER (2nd reference) */
  32856. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32857. /** RG_INTEGER */
  32858. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32859. /** RGB_INTEGER */
  32860. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32861. /** RGBA_INTEGER */
  32862. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32863. /** UNSIGNED_BYTE */
  32864. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32865. /** UNSIGNED_BYTE (2nd reference) */
  32866. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32867. /** FLOAT */
  32868. static readonly TEXTURETYPE_FLOAT: number;
  32869. /** HALF_FLOAT */
  32870. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32871. /** BYTE */
  32872. static readonly TEXTURETYPE_BYTE: number;
  32873. /** SHORT */
  32874. static readonly TEXTURETYPE_SHORT: number;
  32875. /** UNSIGNED_SHORT */
  32876. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32877. /** INT */
  32878. static readonly TEXTURETYPE_INT: number;
  32879. /** UNSIGNED_INT */
  32880. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32881. /** UNSIGNED_SHORT_4_4_4_4 */
  32882. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32883. /** UNSIGNED_SHORT_5_5_5_1 */
  32884. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32885. /** UNSIGNED_SHORT_5_6_5 */
  32886. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32887. /** UNSIGNED_INT_2_10_10_10_REV */
  32888. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32889. /** UNSIGNED_INT_24_8 */
  32890. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32891. /** UNSIGNED_INT_10F_11F_11F_REV */
  32892. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32893. /** UNSIGNED_INT_5_9_9_9_REV */
  32894. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32895. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32896. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32897. /** nearest is mag = nearest and min = nearest and mip = linear */
  32898. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32900. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32901. /** Trilinear is mag = linear and min = linear and mip = linear */
  32902. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32903. /** nearest is mag = nearest and min = nearest and mip = linear */
  32904. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32905. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32906. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32907. /** Trilinear is mag = linear and min = linear and mip = linear */
  32908. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32909. /** mag = nearest and min = nearest and mip = nearest */
  32910. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32911. /** mag = nearest and min = linear and mip = nearest */
  32912. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32913. /** mag = nearest and min = linear and mip = linear */
  32914. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32915. /** mag = nearest and min = linear and mip = none */
  32916. static readonly TEXTURE_NEAREST_LINEAR: number;
  32917. /** mag = nearest and min = nearest and mip = none */
  32918. static readonly TEXTURE_NEAREST_NEAREST: number;
  32919. /** mag = linear and min = nearest and mip = nearest */
  32920. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32921. /** mag = linear and min = nearest and mip = linear */
  32922. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32923. /** mag = linear and min = linear and mip = none */
  32924. static readonly TEXTURE_LINEAR_LINEAR: number;
  32925. /** mag = linear and min = nearest and mip = none */
  32926. static readonly TEXTURE_LINEAR_NEAREST: number;
  32927. /** Explicit coordinates mode */
  32928. static readonly TEXTURE_EXPLICIT_MODE: number;
  32929. /** Spherical coordinates mode */
  32930. static readonly TEXTURE_SPHERICAL_MODE: number;
  32931. /** Planar coordinates mode */
  32932. static readonly TEXTURE_PLANAR_MODE: number;
  32933. /** Cubic coordinates mode */
  32934. static readonly TEXTURE_CUBIC_MODE: number;
  32935. /** Projection coordinates mode */
  32936. static readonly TEXTURE_PROJECTION_MODE: number;
  32937. /** Skybox coordinates mode */
  32938. static readonly TEXTURE_SKYBOX_MODE: number;
  32939. /** Inverse Cubic coordinates mode */
  32940. static readonly TEXTURE_INVCUBIC_MODE: number;
  32941. /** Equirectangular coordinates mode */
  32942. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32943. /** Equirectangular Fixed coordinates mode */
  32944. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32945. /** Equirectangular Fixed Mirrored coordinates mode */
  32946. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32947. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32948. static readonly SCALEMODE_FLOOR: number;
  32949. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32950. static readonly SCALEMODE_NEAREST: number;
  32951. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32952. static readonly SCALEMODE_CEILING: number;
  32953. /**
  32954. * Returns the current npm package of the sdk
  32955. */
  32956. static get NpmPackage(): string;
  32957. /**
  32958. * Returns the current version of the framework
  32959. */
  32960. static get Version(): string;
  32961. /** Gets the list of created engines */
  32962. static get Instances(): Engine[];
  32963. /**
  32964. * Gets the latest created engine
  32965. */
  32966. static get LastCreatedEngine(): Nullable<Engine>;
  32967. /**
  32968. * Gets the latest created scene
  32969. */
  32970. static get LastCreatedScene(): Nullable<Scene>;
  32971. /**
  32972. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32973. * @param flag defines which part of the materials must be marked as dirty
  32974. * @param predicate defines a predicate used to filter which materials should be affected
  32975. */
  32976. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32977. /**
  32978. * Method called to create the default loading screen.
  32979. * This can be overriden in your own app.
  32980. * @param canvas The rendering canvas element
  32981. * @returns The loading screen
  32982. */
  32983. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32984. /**
  32985. * Method called to create the default rescale post process on each engine.
  32986. */
  32987. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32988. /**
  32989. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32990. **/
  32991. enableOfflineSupport: boolean;
  32992. /**
  32993. * 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)
  32994. **/
  32995. disableManifestCheck: boolean;
  32996. /**
  32997. * Gets the list of created scenes
  32998. */
  32999. scenes: Scene[];
  33000. /**
  33001. * Event raised when a new scene is created
  33002. */
  33003. onNewSceneAddedObservable: Observable<Scene>;
  33004. /**
  33005. * Gets the list of created postprocesses
  33006. */
  33007. postProcesses: PostProcess[];
  33008. /**
  33009. * Gets a boolean indicating if the pointer is currently locked
  33010. */
  33011. isPointerLock: boolean;
  33012. /**
  33013. * Observable event triggered each time the rendering canvas is resized
  33014. */
  33015. onResizeObservable: Observable<Engine>;
  33016. /**
  33017. * Observable event triggered each time the canvas loses focus
  33018. */
  33019. onCanvasBlurObservable: Observable<Engine>;
  33020. /**
  33021. * Observable event triggered each time the canvas gains focus
  33022. */
  33023. onCanvasFocusObservable: Observable<Engine>;
  33024. /**
  33025. * Observable event triggered each time the canvas receives pointerout event
  33026. */
  33027. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33028. /**
  33029. * Observable raised when the engine begins a new frame
  33030. */
  33031. onBeginFrameObservable: Observable<Engine>;
  33032. /**
  33033. * If set, will be used to request the next animation frame for the render loop
  33034. */
  33035. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33036. /**
  33037. * Observable raised when the engine ends the current frame
  33038. */
  33039. onEndFrameObservable: Observable<Engine>;
  33040. /**
  33041. * Observable raised when the engine is about to compile a shader
  33042. */
  33043. onBeforeShaderCompilationObservable: Observable<Engine>;
  33044. /**
  33045. * Observable raised when the engine has jsut compiled a shader
  33046. */
  33047. onAfterShaderCompilationObservable: Observable<Engine>;
  33048. /**
  33049. * Gets the audio engine
  33050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33051. * @ignorenaming
  33052. */
  33053. static audioEngine: IAudioEngine;
  33054. /**
  33055. * Default AudioEngine factory responsible of creating the Audio Engine.
  33056. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33057. */
  33058. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33059. /**
  33060. * Default offline support factory responsible of creating a tool used to store data locally.
  33061. * By default, this will create a Database object if the workload has been embedded.
  33062. */
  33063. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33064. private _loadingScreen;
  33065. private _pointerLockRequested;
  33066. private _dummyFramebuffer;
  33067. private _rescalePostProcess;
  33068. private _deterministicLockstep;
  33069. private _lockstepMaxSteps;
  33070. private _timeStep;
  33071. protected get _supportsHardwareTextureRescaling(): boolean;
  33072. private _fps;
  33073. private _deltaTime;
  33074. /** @hidden */
  33075. _drawCalls: PerfCounter;
  33076. /**
  33077. * Turn this value on if you want to pause FPS computation when in background
  33078. */
  33079. disablePerformanceMonitorInBackground: boolean;
  33080. private _performanceMonitor;
  33081. /**
  33082. * Gets the performance monitor attached to this engine
  33083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33084. */
  33085. get performanceMonitor(): PerformanceMonitor;
  33086. private _onFocus;
  33087. private _onBlur;
  33088. private _onCanvasPointerOut;
  33089. private _onCanvasBlur;
  33090. private _onCanvasFocus;
  33091. private _onFullscreenChange;
  33092. private _onPointerLockChange;
  33093. /**
  33094. * Gets the HTML element used to attach event listeners
  33095. * @returns a HTML element
  33096. */
  33097. getInputElement(): Nullable<HTMLElement>;
  33098. /**
  33099. * Creates a new engine
  33100. * @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
  33101. * @param antialias defines enable antialiasing (default: false)
  33102. * @param options defines further options to be sent to the getContext() function
  33103. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33104. */
  33105. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33106. /**
  33107. * Gets current aspect ratio
  33108. * @param viewportOwner defines the camera to use to get the aspect ratio
  33109. * @param useScreen defines if screen size must be used (or the current render target if any)
  33110. * @returns a number defining the aspect ratio
  33111. */
  33112. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33113. /**
  33114. * Gets current screen aspect ratio
  33115. * @returns a number defining the aspect ratio
  33116. */
  33117. getScreenAspectRatio(): number;
  33118. /**
  33119. * Gets the client rect of the HTML canvas attached with the current webGL context
  33120. * @returns a client rectanglee
  33121. */
  33122. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33123. /**
  33124. * Gets the client rect of the HTML element used for events
  33125. * @returns a client rectanglee
  33126. */
  33127. getInputElementClientRect(): Nullable<ClientRect>;
  33128. /**
  33129. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33131. * @returns true if engine is in deterministic lock step mode
  33132. */
  33133. isDeterministicLockStep(): boolean;
  33134. /**
  33135. * Gets the max steps when engine is running in deterministic lock step
  33136. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33137. * @returns the max steps
  33138. */
  33139. getLockstepMaxSteps(): number;
  33140. /**
  33141. * Returns the time in ms between steps when using deterministic lock step.
  33142. * @returns time step in (ms)
  33143. */
  33144. getTimeStep(): number;
  33145. /**
  33146. * Force the mipmap generation for the given render target texture
  33147. * @param texture defines the render target texture to use
  33148. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33149. */
  33150. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33151. /** States */
  33152. /**
  33153. * Set various states to the webGL context
  33154. * @param culling defines backface culling state
  33155. * @param zOffset defines the value to apply to zOffset (0 by default)
  33156. * @param force defines if states must be applied even if cache is up to date
  33157. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33158. */
  33159. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33160. /**
  33161. * Set the z offset to apply to current rendering
  33162. * @param value defines the offset to apply
  33163. */
  33164. setZOffset(value: number): void;
  33165. /**
  33166. * Gets the current value of the zOffset
  33167. * @returns the current zOffset state
  33168. */
  33169. getZOffset(): number;
  33170. /**
  33171. * Enable or disable depth buffering
  33172. * @param enable defines the state to set
  33173. */
  33174. setDepthBuffer(enable: boolean): void;
  33175. /**
  33176. * Gets a boolean indicating if depth writing is enabled
  33177. * @returns the current depth writing state
  33178. */
  33179. getDepthWrite(): boolean;
  33180. /**
  33181. * Enable or disable depth writing
  33182. * @param enable defines the state to set
  33183. */
  33184. setDepthWrite(enable: boolean): void;
  33185. /**
  33186. * Gets a boolean indicating if stencil buffer is enabled
  33187. * @returns the current stencil buffer state
  33188. */
  33189. getStencilBuffer(): boolean;
  33190. /**
  33191. * Enable or disable the stencil buffer
  33192. * @param enable defines if the stencil buffer must be enabled or disabled
  33193. */
  33194. setStencilBuffer(enable: boolean): void;
  33195. /**
  33196. * Gets the current stencil mask
  33197. * @returns a number defining the new stencil mask to use
  33198. */
  33199. getStencilMask(): number;
  33200. /**
  33201. * Sets the current stencil mask
  33202. * @param mask defines the new stencil mask to use
  33203. */
  33204. setStencilMask(mask: number): void;
  33205. /**
  33206. * Gets the current stencil function
  33207. * @returns a number defining the stencil function to use
  33208. */
  33209. getStencilFunction(): number;
  33210. /**
  33211. * Gets the current stencil reference value
  33212. * @returns a number defining the stencil reference value to use
  33213. */
  33214. getStencilFunctionReference(): number;
  33215. /**
  33216. * Gets the current stencil mask
  33217. * @returns a number defining the stencil mask to use
  33218. */
  33219. getStencilFunctionMask(): number;
  33220. /**
  33221. * Sets the current stencil function
  33222. * @param stencilFunc defines the new stencil function to use
  33223. */
  33224. setStencilFunction(stencilFunc: number): void;
  33225. /**
  33226. * Sets the current stencil reference
  33227. * @param reference defines the new stencil reference to use
  33228. */
  33229. setStencilFunctionReference(reference: number): void;
  33230. /**
  33231. * Sets the current stencil mask
  33232. * @param mask defines the new stencil mask to use
  33233. */
  33234. setStencilFunctionMask(mask: number): void;
  33235. /**
  33236. * Gets the current stencil operation when stencil fails
  33237. * @returns a number defining stencil operation to use when stencil fails
  33238. */
  33239. getStencilOperationFail(): number;
  33240. /**
  33241. * Gets the current stencil operation when depth fails
  33242. * @returns a number defining stencil operation to use when depth fails
  33243. */
  33244. getStencilOperationDepthFail(): number;
  33245. /**
  33246. * Gets the current stencil operation when stencil passes
  33247. * @returns a number defining stencil operation to use when stencil passes
  33248. */
  33249. getStencilOperationPass(): number;
  33250. /**
  33251. * Sets the stencil operation to use when stencil fails
  33252. * @param operation defines the stencil operation to use when stencil fails
  33253. */
  33254. setStencilOperationFail(operation: number): void;
  33255. /**
  33256. * Sets the stencil operation to use when depth fails
  33257. * @param operation defines the stencil operation to use when depth fails
  33258. */
  33259. setStencilOperationDepthFail(operation: number): void;
  33260. /**
  33261. * Sets the stencil operation to use when stencil passes
  33262. * @param operation defines the stencil operation to use when stencil passes
  33263. */
  33264. setStencilOperationPass(operation: number): void;
  33265. /**
  33266. * Sets a boolean indicating if the dithering state is enabled or disabled
  33267. * @param value defines the dithering state
  33268. */
  33269. setDitheringState(value: boolean): void;
  33270. /**
  33271. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33272. * @param value defines the rasterizer state
  33273. */
  33274. setRasterizerState(value: boolean): void;
  33275. /**
  33276. * Gets the current depth function
  33277. * @returns a number defining the depth function
  33278. */
  33279. getDepthFunction(): Nullable<number>;
  33280. /**
  33281. * Sets the current depth function
  33282. * @param depthFunc defines the function to use
  33283. */
  33284. setDepthFunction(depthFunc: number): void;
  33285. /**
  33286. * Sets the current depth function to GREATER
  33287. */
  33288. setDepthFunctionToGreater(): void;
  33289. /**
  33290. * Sets the current depth function to GEQUAL
  33291. */
  33292. setDepthFunctionToGreaterOrEqual(): void;
  33293. /**
  33294. * Sets the current depth function to LESS
  33295. */
  33296. setDepthFunctionToLess(): void;
  33297. /**
  33298. * Sets the current depth function to LEQUAL
  33299. */
  33300. setDepthFunctionToLessOrEqual(): void;
  33301. private _cachedStencilBuffer;
  33302. private _cachedStencilFunction;
  33303. private _cachedStencilMask;
  33304. private _cachedStencilOperationPass;
  33305. private _cachedStencilOperationFail;
  33306. private _cachedStencilOperationDepthFail;
  33307. private _cachedStencilReference;
  33308. /**
  33309. * Caches the the state of the stencil buffer
  33310. */
  33311. cacheStencilState(): void;
  33312. /**
  33313. * Restores the state of the stencil buffer
  33314. */
  33315. restoreStencilState(): void;
  33316. /**
  33317. * Directly set the WebGL Viewport
  33318. * @param x defines the x coordinate of the viewport (in screen space)
  33319. * @param y defines the y coordinate of the viewport (in screen space)
  33320. * @param width defines the width of the viewport (in screen space)
  33321. * @param height defines the height of the viewport (in screen space)
  33322. * @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
  33323. */
  33324. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33325. /**
  33326. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33327. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33328. * @param y defines the y-coordinate of the corner of the clear rectangle
  33329. * @param width defines the width of the clear rectangle
  33330. * @param height defines the height of the clear rectangle
  33331. * @param clearColor defines the clear color
  33332. */
  33333. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33334. /**
  33335. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33336. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33337. * @param y defines the y-coordinate of the corner of the clear rectangle
  33338. * @param width defines the width of the clear rectangle
  33339. * @param height defines the height of the clear rectangle
  33340. */
  33341. enableScissor(x: number, y: number, width: number, height: number): void;
  33342. /**
  33343. * Disable previously set scissor test rectangle
  33344. */
  33345. disableScissor(): void;
  33346. protected _reportDrawCall(): void;
  33347. /**
  33348. * Initializes a webVR display and starts listening to display change events
  33349. * The onVRDisplayChangedObservable will be notified upon these changes
  33350. * @returns The onVRDisplayChangedObservable
  33351. */
  33352. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33353. /** @hidden */
  33354. _prepareVRComponent(): void;
  33355. /** @hidden */
  33356. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33357. /** @hidden */
  33358. _submitVRFrame(): void;
  33359. /**
  33360. * Call this function to leave webVR mode
  33361. * Will do nothing if webVR is not supported or if there is no webVR device
  33362. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33363. */
  33364. disableVR(): void;
  33365. /**
  33366. * Gets a boolean indicating that the system is in VR mode and is presenting
  33367. * @returns true if VR mode is engaged
  33368. */
  33369. isVRPresenting(): boolean;
  33370. /** @hidden */
  33371. _requestVRFrame(): void;
  33372. /** @hidden */
  33373. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33374. /**
  33375. * Gets the source code of the vertex shader associated with a specific webGL program
  33376. * @param program defines the program to use
  33377. * @returns a string containing the source code of the vertex shader associated with the program
  33378. */
  33379. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33380. /**
  33381. * Gets the source code of the fragment shader associated with a specific webGL program
  33382. * @param program defines the program to use
  33383. * @returns a string containing the source code of the fragment shader associated with the program
  33384. */
  33385. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33386. /**
  33387. * Sets a depth stencil texture from a render target to the according uniform.
  33388. * @param channel The texture channel
  33389. * @param uniform The uniform to set
  33390. * @param texture The render target texture containing the depth stencil texture to apply
  33391. */
  33392. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33393. /**
  33394. * Sets a texture to the webGL context from a postprocess
  33395. * @param channel defines the channel to use
  33396. * @param postProcess defines the source postprocess
  33397. */
  33398. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33399. /**
  33400. * Binds the output of the passed in post process to the texture channel specified
  33401. * @param channel The channel the texture should be bound to
  33402. * @param postProcess The post process which's output should be bound
  33403. */
  33404. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33405. /** @hidden */
  33406. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33407. protected _rebuildBuffers(): void;
  33408. /** @hidden */
  33409. _renderFrame(): void;
  33410. _renderLoop(): void;
  33411. /** @hidden */
  33412. _renderViews(): boolean;
  33413. /**
  33414. * Toggle full screen mode
  33415. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33416. */
  33417. switchFullscreen(requestPointerLock: boolean): void;
  33418. /**
  33419. * Enters full screen mode
  33420. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33421. */
  33422. enterFullscreen(requestPointerLock: boolean): void;
  33423. /**
  33424. * Exits full screen mode
  33425. */
  33426. exitFullscreen(): void;
  33427. /**
  33428. * Enters Pointerlock mode
  33429. */
  33430. enterPointerlock(): void;
  33431. /**
  33432. * Exits Pointerlock mode
  33433. */
  33434. exitPointerlock(): void;
  33435. /**
  33436. * Begin a new frame
  33437. */
  33438. beginFrame(): void;
  33439. /**
  33440. * Enf the current frame
  33441. */
  33442. endFrame(): void;
  33443. resize(): void;
  33444. /**
  33445. * Set the compressed texture format to use, based on the formats you have, and the formats
  33446. * supported by the hardware / browser.
  33447. *
  33448. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33449. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33450. * to API arguments needed to compressed textures. This puts the burden on the container
  33451. * generator to house the arcane code for determining these for current & future formats.
  33452. *
  33453. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33454. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33455. *
  33456. * Note: The result of this call is not taken into account when a texture is base64.
  33457. *
  33458. * @param formatsAvailable defines the list of those format families you have created
  33459. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33460. *
  33461. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33462. * @returns The extension selected.
  33463. */
  33464. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33465. /**
  33466. * Set the compressed texture extensions or file names to skip.
  33467. *
  33468. * @param skippedFiles defines the list of those texture files you want to skip
  33469. * Example: [".dds", ".env", "myfile.png"]
  33470. */
  33471. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33472. /**
  33473. * Force a specific size of the canvas
  33474. * @param width defines the new canvas' width
  33475. * @param height defines the new canvas' height
  33476. */
  33477. setSize(width: number, height: number): void;
  33478. /**
  33479. * Updates a dynamic vertex buffer.
  33480. * @param vertexBuffer the vertex buffer to update
  33481. * @param data the data used to update the vertex buffer
  33482. * @param byteOffset the byte offset of the data
  33483. * @param byteLength the byte length of the data
  33484. */
  33485. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33486. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33487. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33488. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33489. _releaseTexture(texture: InternalTexture): void;
  33490. /**
  33491. * @hidden
  33492. * Rescales a texture
  33493. * @param source input texutre
  33494. * @param destination destination texture
  33495. * @param scene scene to use to render the resize
  33496. * @param internalFormat format to use when resizing
  33497. * @param onComplete callback to be called when resize has completed
  33498. */
  33499. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33500. /**
  33501. * Gets the current framerate
  33502. * @returns a number representing the framerate
  33503. */
  33504. getFps(): number;
  33505. /**
  33506. * Gets the time spent between current and previous frame
  33507. * @returns a number representing the delta time in ms
  33508. */
  33509. getDeltaTime(): number;
  33510. private _measureFps;
  33511. /** @hidden */
  33512. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33513. /**
  33514. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33515. * @param renderTarget The render target to set the frame buffer for
  33516. */
  33517. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33518. /**
  33519. * Update a dynamic index buffer
  33520. * @param indexBuffer defines the target index buffer
  33521. * @param indices defines the data to update
  33522. * @param offset defines the offset in the target index buffer where update should start
  33523. */
  33524. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33525. /**
  33526. * Updates the sample count of a render target texture
  33527. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33528. * @param texture defines the texture to update
  33529. * @param samples defines the sample count to set
  33530. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33531. */
  33532. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33533. /**
  33534. * Updates a depth texture Comparison Mode and Function.
  33535. * If the comparison Function is equal to 0, the mode will be set to none.
  33536. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33537. * @param texture The texture to set the comparison function for
  33538. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33539. */
  33540. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33541. /**
  33542. * Creates a webGL buffer to use with instanciation
  33543. * @param capacity defines the size of the buffer
  33544. * @returns the webGL buffer
  33545. */
  33546. createInstancesBuffer(capacity: number): DataBuffer;
  33547. /**
  33548. * Delete a webGL buffer used with instanciation
  33549. * @param buffer defines the webGL buffer to delete
  33550. */
  33551. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33552. /** @hidden */
  33553. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33554. dispose(): void;
  33555. private _disableTouchAction;
  33556. /**
  33557. * Display the loading screen
  33558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33559. */
  33560. displayLoadingUI(): void;
  33561. /**
  33562. * Hide the loading screen
  33563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33564. */
  33565. hideLoadingUI(): void;
  33566. /**
  33567. * Gets the current loading screen object
  33568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33569. */
  33570. get loadingScreen(): ILoadingScreen;
  33571. /**
  33572. * Sets the current loading screen object
  33573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33574. */
  33575. set loadingScreen(loadingScreen: ILoadingScreen);
  33576. /**
  33577. * Sets the current loading screen text
  33578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33579. */
  33580. set loadingUIText(text: string);
  33581. /**
  33582. * Sets the current loading screen background color
  33583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33584. */
  33585. set loadingUIBackgroundColor(color: string);
  33586. /** Pointerlock and fullscreen */
  33587. /**
  33588. * Ask the browser to promote the current element to pointerlock mode
  33589. * @param element defines the DOM element to promote
  33590. */
  33591. static _RequestPointerlock(element: HTMLElement): void;
  33592. /**
  33593. * Asks the browser to exit pointerlock mode
  33594. */
  33595. static _ExitPointerlock(): void;
  33596. /**
  33597. * Ask the browser to promote the current element to fullscreen rendering mode
  33598. * @param element defines the DOM element to promote
  33599. */
  33600. static _RequestFullscreen(element: HTMLElement): void;
  33601. /**
  33602. * Asks the browser to exit fullscreen mode
  33603. */
  33604. static _ExitFullscreen(): void;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33610. * during the life time of the application.
  33611. */
  33612. export class EngineStore {
  33613. /** Gets the list of created engines */
  33614. static Instances: Engine[];
  33615. /** @hidden */
  33616. static _LastCreatedScene: Nullable<Scene>;
  33617. /**
  33618. * Gets the latest created engine
  33619. */
  33620. static get LastCreatedEngine(): Nullable<Engine>;
  33621. /**
  33622. * Gets the latest created scene
  33623. */
  33624. static get LastCreatedScene(): Nullable<Scene>;
  33625. /**
  33626. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33627. * @ignorenaming
  33628. */
  33629. static UseFallbackTexture: boolean;
  33630. /**
  33631. * Texture content used if a texture cannot loaded
  33632. * @ignorenaming
  33633. */
  33634. static FallbackTexture: string;
  33635. }
  33636. }
  33637. declare module BABYLON {
  33638. /**
  33639. * Helper class that provides a small promise polyfill
  33640. */
  33641. export class PromisePolyfill {
  33642. /**
  33643. * Static function used to check if the polyfill is required
  33644. * If this is the case then the function will inject the polyfill to window.Promise
  33645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33646. */
  33647. static Apply(force?: boolean): void;
  33648. }
  33649. }
  33650. declare module BABYLON {
  33651. /**
  33652. * Interface for screenshot methods with describe argument called `size` as object with options
  33653. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33654. */
  33655. export interface IScreenshotSize {
  33656. /**
  33657. * number in pixels for canvas height
  33658. */
  33659. height?: number;
  33660. /**
  33661. * multiplier allowing render at a higher or lower resolution
  33662. * If value is defined then height and width will be ignored and taken from camera
  33663. */
  33664. precision?: number;
  33665. /**
  33666. * number in pixels for canvas width
  33667. */
  33668. width?: number;
  33669. }
  33670. }
  33671. declare module BABYLON {
  33672. interface IColor4Like {
  33673. r: float;
  33674. g: float;
  33675. b: float;
  33676. a: float;
  33677. }
  33678. /**
  33679. * Class containing a set of static utilities functions
  33680. */
  33681. export class Tools {
  33682. /**
  33683. * Gets or sets the base URL to use to load assets
  33684. */
  33685. static get BaseUrl(): string;
  33686. static set BaseUrl(value: string);
  33687. /**
  33688. * Enable/Disable Custom HTTP Request Headers globally.
  33689. * default = false
  33690. * @see CustomRequestHeaders
  33691. */
  33692. static UseCustomRequestHeaders: boolean;
  33693. /**
  33694. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33695. * i.e. when loading files, where the server/service expects an Authorization header
  33696. */
  33697. static CustomRequestHeaders: {
  33698. [key: string]: string;
  33699. };
  33700. /**
  33701. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33702. */
  33703. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33704. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33705. /**
  33706. * Default behaviour for cors in the application.
  33707. * It can be a string if the expected behavior is identical in the entire app.
  33708. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33709. */
  33710. static CorsBehavior: string | ((url: string | string[]) => string);
  33711. /**
  33712. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33713. * @ignorenaming
  33714. */
  33715. static get UseFallbackTexture(): boolean;
  33716. static set UseFallbackTexture(value: boolean);
  33717. /**
  33718. * Use this object to register external classes like custom textures or material
  33719. * to allow the laoders to instantiate them
  33720. */
  33721. static get RegisteredExternalClasses(): {
  33722. [key: string]: Object;
  33723. };
  33724. static set RegisteredExternalClasses(classes: {
  33725. [key: string]: Object;
  33726. });
  33727. /**
  33728. * Texture content used if a texture cannot loaded
  33729. * @ignorenaming
  33730. */
  33731. static get fallbackTexture(): string;
  33732. static set fallbackTexture(value: string);
  33733. /**
  33734. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33735. * @param u defines the coordinate on X axis
  33736. * @param v defines the coordinate on Y axis
  33737. * @param width defines the width of the source data
  33738. * @param height defines the height of the source data
  33739. * @param pixels defines the source byte array
  33740. * @param color defines the output color
  33741. */
  33742. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33743. /**
  33744. * Interpolates between a and b via alpha
  33745. * @param a The lower value (returned when alpha = 0)
  33746. * @param b The upper value (returned when alpha = 1)
  33747. * @param alpha The interpolation-factor
  33748. * @return The mixed value
  33749. */
  33750. static Mix(a: number, b: number, alpha: number): number;
  33751. /**
  33752. * Tries to instantiate a new object from a given class name
  33753. * @param className defines the class name to instantiate
  33754. * @returns the new object or null if the system was not able to do the instantiation
  33755. */
  33756. static Instantiate(className: string): any;
  33757. /**
  33758. * Provides a slice function that will work even on IE
  33759. * @param data defines the array to slice
  33760. * @param start defines the start of the data (optional)
  33761. * @param end defines the end of the data (optional)
  33762. * @returns the new sliced array
  33763. */
  33764. static Slice<T>(data: T, start?: number, end?: number): T;
  33765. /**
  33766. * Polyfill for setImmediate
  33767. * @param action defines the action to execute after the current execution block
  33768. */
  33769. static SetImmediate(action: () => void): void;
  33770. /**
  33771. * Function indicating if a number is an exponent of 2
  33772. * @param value defines the value to test
  33773. * @returns true if the value is an exponent of 2
  33774. */
  33775. static IsExponentOfTwo(value: number): boolean;
  33776. private static _tmpFloatArray;
  33777. /**
  33778. * Returns the nearest 32-bit single precision float representation of a Number
  33779. * @param value A Number. If the parameter is of a different type, it will get converted
  33780. * to a number or to NaN if it cannot be converted
  33781. * @returns number
  33782. */
  33783. static FloatRound(value: number): number;
  33784. /**
  33785. * Extracts the filename from a path
  33786. * @param path defines the path to use
  33787. * @returns the filename
  33788. */
  33789. static GetFilename(path: string): string;
  33790. /**
  33791. * Extracts the "folder" part of a path (everything before the filename).
  33792. * @param uri The URI to extract the info from
  33793. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33794. * @returns The "folder" part of the path
  33795. */
  33796. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33797. /**
  33798. * Extracts text content from a DOM element hierarchy
  33799. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33800. */
  33801. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33802. /**
  33803. * Convert an angle in radians to degrees
  33804. * @param angle defines the angle to convert
  33805. * @returns the angle in degrees
  33806. */
  33807. static ToDegrees(angle: number): number;
  33808. /**
  33809. * Convert an angle in degrees to radians
  33810. * @param angle defines the angle to convert
  33811. * @returns the angle in radians
  33812. */
  33813. static ToRadians(angle: number): number;
  33814. /**
  33815. * Returns an array if obj is not an array
  33816. * @param obj defines the object to evaluate as an array
  33817. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33818. * @returns either obj directly if obj is an array or a new array containing obj
  33819. */
  33820. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33821. /**
  33822. * Gets the pointer prefix to use
  33823. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33824. */
  33825. static GetPointerPrefix(): string;
  33826. /**
  33827. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33828. * @param url define the url we are trying
  33829. * @param element define the dom element where to configure the cors policy
  33830. */
  33831. static SetCorsBehavior(url: string | string[], element: {
  33832. crossOrigin: string | null;
  33833. }): void;
  33834. /**
  33835. * Removes unwanted characters from an url
  33836. * @param url defines the url to clean
  33837. * @returns the cleaned url
  33838. */
  33839. static CleanUrl(url: string): string;
  33840. /**
  33841. * Gets or sets a function used to pre-process url before using them to load assets
  33842. */
  33843. static get PreprocessUrl(): (url: string) => string;
  33844. static set PreprocessUrl(processor: (url: string) => string);
  33845. /**
  33846. * Loads an image as an HTMLImageElement.
  33847. * @param input url string, ArrayBuffer, or Blob to load
  33848. * @param onLoad callback called when the image successfully loads
  33849. * @param onError callback called when the image fails to load
  33850. * @param offlineProvider offline provider for caching
  33851. * @param mimeType optional mime type
  33852. * @returns the HTMLImageElement of the loaded image
  33853. */
  33854. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33855. /**
  33856. * Loads a file from a url
  33857. * @param url url string, ArrayBuffer, or Blob to load
  33858. * @param onSuccess callback called when the file successfully loads
  33859. * @param onProgress callback called while file is loading (if the server supports this mode)
  33860. * @param offlineProvider defines the offline provider for caching
  33861. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33862. * @param onError callback called when the file fails to load
  33863. * @returns a file request object
  33864. */
  33865. 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;
  33866. /**
  33867. * Loads a file from a url
  33868. * @param url the file url to load
  33869. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33870. */
  33871. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33872. /**
  33873. * Load a script (identified by an url). When the url returns, the
  33874. * content of this file is added into a new script element, attached to the DOM (body element)
  33875. * @param scriptUrl defines the url of the script to laod
  33876. * @param onSuccess defines the callback called when the script is loaded
  33877. * @param onError defines the callback to call if an error occurs
  33878. * @param scriptId defines the id of the script element
  33879. */
  33880. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33881. /**
  33882. * Load an asynchronous script (identified by an url). When the url returns, the
  33883. * content of this file is added into a new script element, attached to the DOM (body element)
  33884. * @param scriptUrl defines the url of the script to laod
  33885. * @param scriptId defines the id of the script element
  33886. * @returns a promise request object
  33887. */
  33888. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  33889. /**
  33890. * Loads a file from a blob
  33891. * @param fileToLoad defines the blob to use
  33892. * @param callback defines the callback to call when data is loaded
  33893. * @param progressCallback defines the callback to call during loading process
  33894. * @returns a file request object
  33895. */
  33896. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33897. /**
  33898. * Reads a file from a File object
  33899. * @param file defines the file to load
  33900. * @param onSuccess defines the callback to call when data is loaded
  33901. * @param onProgress defines the callback to call during loading process
  33902. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33903. * @param onError defines the callback to call when an error occurs
  33904. * @returns a file request object
  33905. */
  33906. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33907. /**
  33908. * Creates a data url from a given string content
  33909. * @param content defines the content to convert
  33910. * @returns the new data url link
  33911. */
  33912. static FileAsURL(content: string): string;
  33913. /**
  33914. * Format the given number to a specific decimal format
  33915. * @param value defines the number to format
  33916. * @param decimals defines the number of decimals to use
  33917. * @returns the formatted string
  33918. */
  33919. static Format(value: number, decimals?: number): string;
  33920. /**
  33921. * Tries to copy an object by duplicating every property
  33922. * @param source defines the source object
  33923. * @param destination defines the target object
  33924. * @param doNotCopyList defines a list of properties to avoid
  33925. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33926. */
  33927. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33928. /**
  33929. * Gets a boolean indicating if the given object has no own property
  33930. * @param obj defines the object to test
  33931. * @returns true if object has no own property
  33932. */
  33933. static IsEmpty(obj: any): boolean;
  33934. /**
  33935. * Function used to register events at window level
  33936. * @param windowElement defines the Window object to use
  33937. * @param events defines the events to register
  33938. */
  33939. static RegisterTopRootEvents(windowElement: Window, events: {
  33940. name: string;
  33941. handler: Nullable<(e: FocusEvent) => any>;
  33942. }[]): void;
  33943. /**
  33944. * Function used to unregister events from window level
  33945. * @param windowElement defines the Window object to use
  33946. * @param events defines the events to unregister
  33947. */
  33948. static UnregisterTopRootEvents(windowElement: Window, events: {
  33949. name: string;
  33950. handler: Nullable<(e: FocusEvent) => any>;
  33951. }[]): void;
  33952. /**
  33953. * @ignore
  33954. */
  33955. static _ScreenshotCanvas: HTMLCanvasElement;
  33956. /**
  33957. * Dumps the current bound framebuffer
  33958. * @param width defines the rendering width
  33959. * @param height defines the rendering height
  33960. * @param engine defines the hosting engine
  33961. * @param successCallback defines the callback triggered once the data are available
  33962. * @param mimeType defines the mime type of the result
  33963. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33964. */
  33965. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33966. /**
  33967. * Converts the canvas data to blob.
  33968. * This acts as a polyfill for browsers not supporting the to blob function.
  33969. * @param canvas Defines the canvas to extract the data from
  33970. * @param successCallback Defines the callback triggered once the data are available
  33971. * @param mimeType Defines the mime type of the result
  33972. */
  33973. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33974. /**
  33975. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33976. * @param successCallback defines the callback triggered once the data are available
  33977. * @param mimeType defines the mime type of the result
  33978. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33979. */
  33980. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33981. /**
  33982. * Downloads a blob in the browser
  33983. * @param blob defines the blob to download
  33984. * @param fileName defines the name of the downloaded file
  33985. */
  33986. static Download(blob: Blob, fileName: string): void;
  33987. /**
  33988. * Captures a screenshot of the current rendering
  33989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33990. * @param engine defines the rendering engine
  33991. * @param camera defines the source camera
  33992. * @param size This parameter can be set to a single number or to an object with the
  33993. * following (optional) properties: precision, width, height. If a single number is passed,
  33994. * it will be used for both width and height. If an object is passed, the screenshot size
  33995. * will be derived from the parameters. The precision property is a multiplier allowing
  33996. * rendering at a higher or lower resolution
  33997. * @param successCallback defines the callback receives a single parameter which contains the
  33998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33999. * src parameter of an <img> to display it
  34000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34001. * Check your browser for supported MIME types
  34002. */
  34003. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34004. /**
  34005. * Captures a screenshot of the current rendering
  34006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34007. * @param engine defines the rendering engine
  34008. * @param camera defines the source camera
  34009. * @param size This parameter can be set to a single number or to an object with the
  34010. * following (optional) properties: precision, width, height. If a single number is passed,
  34011. * it will be used for both width and height. If an object is passed, the screenshot size
  34012. * will be derived from the parameters. The precision property is a multiplier allowing
  34013. * rendering at a higher or lower resolution
  34014. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34015. * Check your browser for supported MIME types
  34016. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34017. * to the src parameter of an <img> to display it
  34018. */
  34019. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34020. /**
  34021. * Generates an image screenshot from the specified camera.
  34022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34023. * @param engine The engine to use for rendering
  34024. * @param camera The camera to use for rendering
  34025. * @param size This parameter can be set to a single number or to an object with the
  34026. * following (optional) properties: precision, width, height. If a single number is passed,
  34027. * it will be used for both width and height. If an object is passed, the screenshot size
  34028. * will be derived from the parameters. The precision property is a multiplier allowing
  34029. * rendering at a higher or lower resolution
  34030. * @param successCallback The callback receives a single parameter which contains the
  34031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34032. * src parameter of an <img> to display it
  34033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34034. * Check your browser for supported MIME types
  34035. * @param samples Texture samples (default: 1)
  34036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34037. * @param fileName A name for for the downloaded file.
  34038. */
  34039. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34040. /**
  34041. * Generates an image screenshot from the specified camera.
  34042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34043. * @param engine The engine to use for rendering
  34044. * @param camera The camera to use for rendering
  34045. * @param size This parameter can be set to a single number or to an object with the
  34046. * following (optional) properties: precision, width, height. If a single number is passed,
  34047. * it will be used for both width and height. If an object is passed, the screenshot size
  34048. * will be derived from the parameters. The precision property is a multiplier allowing
  34049. * rendering at a higher or lower resolution
  34050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34051. * Check your browser for supported MIME types
  34052. * @param samples Texture samples (default: 1)
  34053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34054. * @param fileName A name for for the downloaded file.
  34055. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34056. * to the src parameter of an <img> to display it
  34057. */
  34058. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34059. /**
  34060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34061. * Be aware Math.random() could cause collisions, but:
  34062. * "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"
  34063. * @returns a pseudo random id
  34064. */
  34065. static RandomId(): string;
  34066. /**
  34067. * Test if the given uri is a base64 string
  34068. * @param uri The uri to test
  34069. * @return True if the uri is a base64 string or false otherwise
  34070. */
  34071. static IsBase64(uri: string): boolean;
  34072. /**
  34073. * Decode the given base64 uri.
  34074. * @param uri The uri to decode
  34075. * @return The decoded base64 data.
  34076. */
  34077. static DecodeBase64(uri: string): ArrayBuffer;
  34078. /**
  34079. * Gets the absolute url.
  34080. * @param url the input url
  34081. * @return the absolute url
  34082. */
  34083. static GetAbsoluteUrl(url: string): string;
  34084. /**
  34085. * No log
  34086. */
  34087. static readonly NoneLogLevel: number;
  34088. /**
  34089. * Only message logs
  34090. */
  34091. static readonly MessageLogLevel: number;
  34092. /**
  34093. * Only warning logs
  34094. */
  34095. static readonly WarningLogLevel: number;
  34096. /**
  34097. * Only error logs
  34098. */
  34099. static readonly ErrorLogLevel: number;
  34100. /**
  34101. * All logs
  34102. */
  34103. static readonly AllLogLevel: number;
  34104. /**
  34105. * Gets a value indicating the number of loading errors
  34106. * @ignorenaming
  34107. */
  34108. static get errorsCount(): number;
  34109. /**
  34110. * Callback called when a new log is added
  34111. */
  34112. static OnNewCacheEntry: (entry: string) => void;
  34113. /**
  34114. * Log a message to the console
  34115. * @param message defines the message to log
  34116. */
  34117. static Log(message: string): void;
  34118. /**
  34119. * Write a warning message to the console
  34120. * @param message defines the message to log
  34121. */
  34122. static Warn(message: string): void;
  34123. /**
  34124. * Write an error message to the console
  34125. * @param message defines the message to log
  34126. */
  34127. static Error(message: string): void;
  34128. /**
  34129. * Gets current log cache (list of logs)
  34130. */
  34131. static get LogCache(): string;
  34132. /**
  34133. * Clears the log cache
  34134. */
  34135. static ClearLogCache(): void;
  34136. /**
  34137. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34138. */
  34139. static set LogLevels(level: number);
  34140. /**
  34141. * Checks if the window object exists
  34142. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34143. */
  34144. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34145. /**
  34146. * No performance log
  34147. */
  34148. static readonly PerformanceNoneLogLevel: number;
  34149. /**
  34150. * Use user marks to log performance
  34151. */
  34152. static readonly PerformanceUserMarkLogLevel: number;
  34153. /**
  34154. * Log performance to the console
  34155. */
  34156. static readonly PerformanceConsoleLogLevel: number;
  34157. private static _performance;
  34158. /**
  34159. * Sets the current performance log level
  34160. */
  34161. static set PerformanceLogLevel(level: number);
  34162. private static _StartPerformanceCounterDisabled;
  34163. private static _EndPerformanceCounterDisabled;
  34164. private static _StartUserMark;
  34165. private static _EndUserMark;
  34166. private static _StartPerformanceConsole;
  34167. private static _EndPerformanceConsole;
  34168. /**
  34169. * Starts a performance counter
  34170. */
  34171. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34172. /**
  34173. * Ends a specific performance coutner
  34174. */
  34175. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34176. /**
  34177. * Gets either window.performance.now() if supported or Date.now() else
  34178. */
  34179. static get Now(): number;
  34180. /**
  34181. * This method will return the name of the class used to create the instance of the given object.
  34182. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34183. * @param object the object to get the class name from
  34184. * @param isType defines if the object is actually a type
  34185. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34186. */
  34187. static GetClassName(object: any, isType?: boolean): string;
  34188. /**
  34189. * Gets the first element of an array satisfying a given predicate
  34190. * @param array defines the array to browse
  34191. * @param predicate defines the predicate to use
  34192. * @returns null if not found or the element
  34193. */
  34194. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34195. /**
  34196. * This method will return the name of the full name of the class, including its owning module (if any).
  34197. * 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).
  34198. * @param object the object to get the class name from
  34199. * @param isType defines if the object is actually a type
  34200. * @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.
  34201. * @ignorenaming
  34202. */
  34203. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34204. /**
  34205. * Returns a promise that resolves after the given amount of time.
  34206. * @param delay Number of milliseconds to delay
  34207. * @returns Promise that resolves after the given amount of time
  34208. */
  34209. static DelayAsync(delay: number): Promise<void>;
  34210. }
  34211. /**
  34212. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34213. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34214. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34215. * @param name The name of the class, case should be preserved
  34216. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34217. */
  34218. export function className(name: string, module?: string): (target: Object) => void;
  34219. /**
  34220. * An implementation of a loop for asynchronous functions.
  34221. */
  34222. export class AsyncLoop {
  34223. /**
  34224. * Defines the number of iterations for the loop
  34225. */
  34226. iterations: number;
  34227. /**
  34228. * Defines the current index of the loop.
  34229. */
  34230. index: number;
  34231. private _done;
  34232. private _fn;
  34233. private _successCallback;
  34234. /**
  34235. * Constructor.
  34236. * @param iterations the number of iterations.
  34237. * @param func the function to run each iteration
  34238. * @param successCallback the callback that will be called upon succesful execution
  34239. * @param offset starting offset.
  34240. */
  34241. constructor(
  34242. /**
  34243. * Defines the number of iterations for the loop
  34244. */
  34245. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34246. /**
  34247. * Execute the next iteration. Must be called after the last iteration was finished.
  34248. */
  34249. executeNext(): void;
  34250. /**
  34251. * Break the loop and run the success callback.
  34252. */
  34253. breakLoop(): void;
  34254. /**
  34255. * Create and run an async loop.
  34256. * @param iterations the number of iterations.
  34257. * @param fn the function to run each iteration
  34258. * @param successCallback the callback that will be called upon succesful execution
  34259. * @param offset starting offset.
  34260. * @returns the created async loop object
  34261. */
  34262. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34263. /**
  34264. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34265. * @param iterations total number of iterations
  34266. * @param syncedIterations number of synchronous iterations in each async iteration.
  34267. * @param fn the function to call each iteration.
  34268. * @param callback a success call back that will be called when iterating stops.
  34269. * @param breakFunction a break condition (optional)
  34270. * @param timeout timeout settings for the setTimeout function. default - 0.
  34271. * @returns the created async loop object
  34272. */
  34273. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34279. * The underlying implementation relies on an associative array to ensure the best performances.
  34280. * The value can be anything including 'null' but except 'undefined'
  34281. */
  34282. export class StringDictionary<T> {
  34283. /**
  34284. * This will clear this dictionary and copy the content from the 'source' one.
  34285. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34286. * @param source the dictionary to take the content from and copy to this dictionary
  34287. */
  34288. copyFrom(source: StringDictionary<T>): void;
  34289. /**
  34290. * Get a value based from its key
  34291. * @param key the given key to get the matching value from
  34292. * @return the value if found, otherwise undefined is returned
  34293. */
  34294. get(key: string): T | undefined;
  34295. /**
  34296. * Get a value from its key or add it if it doesn't exist.
  34297. * This method will ensure you that a given key/data will be present in the dictionary.
  34298. * @param key the given key to get the matching value from
  34299. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34300. * The factory will only be invoked if there's no data for the given key.
  34301. * @return the value corresponding to the key.
  34302. */
  34303. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34304. /**
  34305. * Get a value from its key if present in the dictionary otherwise add it
  34306. * @param key the key to get the value from
  34307. * @param val if there's no such key/value pair in the dictionary add it with this value
  34308. * @return the value corresponding to the key
  34309. */
  34310. getOrAdd(key: string, val: T): T;
  34311. /**
  34312. * Check if there's a given key in the dictionary
  34313. * @param key the key to check for
  34314. * @return true if the key is present, false otherwise
  34315. */
  34316. contains(key: string): boolean;
  34317. /**
  34318. * Add a new key and its corresponding value
  34319. * @param key the key to add
  34320. * @param value the value corresponding to the key
  34321. * @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
  34322. */
  34323. add(key: string, value: T): boolean;
  34324. /**
  34325. * Update a specific value associated to a key
  34326. * @param key defines the key to use
  34327. * @param value defines the value to store
  34328. * @returns true if the value was updated (or false if the key was not found)
  34329. */
  34330. set(key: string, value: T): boolean;
  34331. /**
  34332. * Get the element of the given key and remove it from the dictionary
  34333. * @param key defines the key to search
  34334. * @returns the value associated with the key or null if not found
  34335. */
  34336. getAndRemove(key: string): Nullable<T>;
  34337. /**
  34338. * Remove a key/value from the dictionary.
  34339. * @param key the key to remove
  34340. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34341. */
  34342. remove(key: string): boolean;
  34343. /**
  34344. * Clear the whole content of the dictionary
  34345. */
  34346. clear(): void;
  34347. /**
  34348. * Gets the current count
  34349. */
  34350. get count(): number;
  34351. /**
  34352. * Execute a callback on each key/val of the dictionary.
  34353. * Note that you can remove any element in this dictionary in the callback implementation
  34354. * @param callback the callback to execute on a given key/value pair
  34355. */
  34356. forEach(callback: (key: string, val: T) => void): void;
  34357. /**
  34358. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34359. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34360. * Note that you can remove any element in this dictionary in the callback implementation
  34361. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34362. * @returns the first item
  34363. */
  34364. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34365. private _count;
  34366. private _data;
  34367. }
  34368. }
  34369. declare module BABYLON {
  34370. /** @hidden */
  34371. export interface ICollisionCoordinator {
  34372. createCollider(): Collider;
  34373. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34374. init(scene: Scene): void;
  34375. }
  34376. /** @hidden */
  34377. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34378. private _scene;
  34379. private _scaledPosition;
  34380. private _scaledVelocity;
  34381. private _finalPosition;
  34382. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34383. createCollider(): Collider;
  34384. init(scene: Scene): void;
  34385. private _collideWithWorld;
  34386. }
  34387. }
  34388. declare module BABYLON {
  34389. /**
  34390. * Class used to manage all inputs for the scene.
  34391. */
  34392. export class InputManager {
  34393. /** The distance in pixel that you have to move to prevent some events */
  34394. static DragMovementThreshold: number;
  34395. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34396. static LongPressDelay: number;
  34397. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34398. static DoubleClickDelay: number;
  34399. /** If you need to check double click without raising a single click at first click, enable this flag */
  34400. static ExclusiveDoubleClickMode: boolean;
  34401. private _wheelEventName;
  34402. private _onPointerMove;
  34403. private _onPointerDown;
  34404. private _onPointerUp;
  34405. private _initClickEvent;
  34406. private _initActionManager;
  34407. private _delayedSimpleClick;
  34408. private _delayedSimpleClickTimeout;
  34409. private _previousDelayedSimpleClickTimeout;
  34410. private _meshPickProceed;
  34411. private _previousButtonPressed;
  34412. private _currentPickResult;
  34413. private _previousPickResult;
  34414. private _totalPointersPressed;
  34415. private _doubleClickOccured;
  34416. private _pointerOverMesh;
  34417. private _pickedDownMesh;
  34418. private _pickedUpMesh;
  34419. private _pointerX;
  34420. private _pointerY;
  34421. private _unTranslatedPointerX;
  34422. private _unTranslatedPointerY;
  34423. private _startingPointerPosition;
  34424. private _previousStartingPointerPosition;
  34425. private _startingPointerTime;
  34426. private _previousStartingPointerTime;
  34427. private _pointerCaptures;
  34428. private _onKeyDown;
  34429. private _onKeyUp;
  34430. private _onCanvasFocusObserver;
  34431. private _onCanvasBlurObserver;
  34432. private _scene;
  34433. /**
  34434. * Creates a new InputManager
  34435. * @param scene defines the hosting scene
  34436. */
  34437. constructor(scene: Scene);
  34438. /**
  34439. * Gets the mesh that is currently under the pointer
  34440. */
  34441. get meshUnderPointer(): Nullable<AbstractMesh>;
  34442. /**
  34443. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34444. */
  34445. get unTranslatedPointer(): Vector2;
  34446. /**
  34447. * Gets or sets the current on-screen X position of the pointer
  34448. */
  34449. get pointerX(): number;
  34450. set pointerX(value: number);
  34451. /**
  34452. * Gets or sets the current on-screen Y position of the pointer
  34453. */
  34454. get pointerY(): number;
  34455. set pointerY(value: number);
  34456. private _updatePointerPosition;
  34457. private _processPointerMove;
  34458. private _setRayOnPointerInfo;
  34459. private _checkPrePointerObservable;
  34460. /**
  34461. * Use this method to simulate a pointer move on a mesh
  34462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34465. */
  34466. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34467. /**
  34468. * Use this method to simulate a pointer down on a mesh
  34469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34472. */
  34473. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34474. private _processPointerDown;
  34475. /** @hidden */
  34476. _isPointerSwiping(): boolean;
  34477. /**
  34478. * Use this method to simulate a pointer up on a mesh
  34479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34482. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34483. */
  34484. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34485. private _processPointerUp;
  34486. /**
  34487. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34488. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34489. * @returns true if the pointer was captured
  34490. */
  34491. isPointerCaptured(pointerId?: number): boolean;
  34492. /**
  34493. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34494. * @param attachUp defines if you want to attach events to pointerup
  34495. * @param attachDown defines if you want to attach events to pointerdown
  34496. * @param attachMove defines if you want to attach events to pointermove
  34497. */
  34498. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34499. /**
  34500. * Detaches all event handlers
  34501. */
  34502. detachControl(): void;
  34503. /**
  34504. * Force the value of meshUnderPointer
  34505. * @param mesh defines the mesh to use
  34506. */
  34507. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34508. /**
  34509. * Gets the mesh under the pointer
  34510. * @returns a Mesh or null if no mesh is under the pointer
  34511. */
  34512. getPointerOverMesh(): Nullable<AbstractMesh>;
  34513. }
  34514. }
  34515. declare module BABYLON {
  34516. /**
  34517. * Helper class used to generate session unique ID
  34518. */
  34519. export class UniqueIdGenerator {
  34520. private static _UniqueIdCounter;
  34521. /**
  34522. * Gets an unique (relatively to the current scene) Id
  34523. */
  34524. static get UniqueId(): number;
  34525. }
  34526. }
  34527. declare module BABYLON {
  34528. /**
  34529. * This class defines the direct association between an animation and a target
  34530. */
  34531. export class TargetedAnimation {
  34532. /**
  34533. * Animation to perform
  34534. */
  34535. animation: Animation;
  34536. /**
  34537. * Target to animate
  34538. */
  34539. target: any;
  34540. /**
  34541. * Serialize the object
  34542. * @returns the JSON object representing the current entity
  34543. */
  34544. serialize(): any;
  34545. }
  34546. /**
  34547. * Use this class to create coordinated animations on multiple targets
  34548. */
  34549. export class AnimationGroup implements IDisposable {
  34550. /** The name of the animation group */
  34551. name: string;
  34552. private _scene;
  34553. private _targetedAnimations;
  34554. private _animatables;
  34555. private _from;
  34556. private _to;
  34557. private _isStarted;
  34558. private _isPaused;
  34559. private _speedRatio;
  34560. private _loopAnimation;
  34561. /**
  34562. * Gets or sets the unique id of the node
  34563. */
  34564. uniqueId: number;
  34565. /**
  34566. * This observable will notify when one animation have ended
  34567. */
  34568. onAnimationEndObservable: Observable<TargetedAnimation>;
  34569. /**
  34570. * Observer raised when one animation loops
  34571. */
  34572. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34573. /**
  34574. * Observer raised when all animations have looped
  34575. */
  34576. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34577. /**
  34578. * This observable will notify when all animations have ended.
  34579. */
  34580. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34581. /**
  34582. * This observable will notify when all animations have paused.
  34583. */
  34584. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34585. /**
  34586. * This observable will notify when all animations are playing.
  34587. */
  34588. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34589. /**
  34590. * Gets the first frame
  34591. */
  34592. get from(): number;
  34593. /**
  34594. * Gets the last frame
  34595. */
  34596. get to(): number;
  34597. /**
  34598. * Define if the animations are started
  34599. */
  34600. get isStarted(): boolean;
  34601. /**
  34602. * Gets a value indicating that the current group is playing
  34603. */
  34604. get isPlaying(): boolean;
  34605. /**
  34606. * Gets or sets the speed ratio to use for all animations
  34607. */
  34608. get speedRatio(): number;
  34609. /**
  34610. * Gets or sets the speed ratio to use for all animations
  34611. */
  34612. set speedRatio(value: number);
  34613. /**
  34614. * Gets or sets if all animations should loop or not
  34615. */
  34616. get loopAnimation(): boolean;
  34617. set loopAnimation(value: boolean);
  34618. /**
  34619. * Gets the targeted animations for this animation group
  34620. */
  34621. get targetedAnimations(): Array<TargetedAnimation>;
  34622. /**
  34623. * returning the list of animatables controlled by this animation group.
  34624. */
  34625. get animatables(): Array<Animatable>;
  34626. /**
  34627. * Instantiates a new Animation Group.
  34628. * This helps managing several animations at once.
  34629. * @see http://doc.babylonjs.com/how_to/group
  34630. * @param name Defines the name of the group
  34631. * @param scene Defines the scene the group belongs to
  34632. */
  34633. constructor(
  34634. /** The name of the animation group */
  34635. name: string, scene?: Nullable<Scene>);
  34636. /**
  34637. * Add an animation (with its target) in the group
  34638. * @param animation defines the animation we want to add
  34639. * @param target defines the target of the animation
  34640. * @returns the TargetedAnimation object
  34641. */
  34642. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34643. /**
  34644. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34645. * It can add constant keys at begin or end
  34646. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34647. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34648. * @returns the animation group
  34649. */
  34650. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34651. private _animationLoopCount;
  34652. private _animationLoopFlags;
  34653. private _processLoop;
  34654. /**
  34655. * Start all animations on given targets
  34656. * @param loop defines if animations must loop
  34657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34658. * @param from defines the from key (optional)
  34659. * @param to defines the to key (optional)
  34660. * @returns the current animation group
  34661. */
  34662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34663. /**
  34664. * Pause all animations
  34665. * @returns the animation group
  34666. */
  34667. pause(): AnimationGroup;
  34668. /**
  34669. * Play all animations to initial state
  34670. * This function will start() the animations if they were not started or will restart() them if they were paused
  34671. * @param loop defines if animations must loop
  34672. * @returns the animation group
  34673. */
  34674. play(loop?: boolean): AnimationGroup;
  34675. /**
  34676. * Reset all animations to initial state
  34677. * @returns the animation group
  34678. */
  34679. reset(): AnimationGroup;
  34680. /**
  34681. * Restart animations from key 0
  34682. * @returns the animation group
  34683. */
  34684. restart(): AnimationGroup;
  34685. /**
  34686. * Stop all animations
  34687. * @returns the animation group
  34688. */
  34689. stop(): AnimationGroup;
  34690. /**
  34691. * Set animation weight for all animatables
  34692. * @param weight defines the weight to use
  34693. * @return the animationGroup
  34694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34695. */
  34696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34697. /**
  34698. * Synchronize and normalize all animatables with a source animatable
  34699. * @param root defines the root animatable to synchronize with
  34700. * @return the animationGroup
  34701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34702. */
  34703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34704. /**
  34705. * Goes to a specific frame in this animation group
  34706. * @param frame the frame number to go to
  34707. * @return the animationGroup
  34708. */
  34709. goToFrame(frame: number): AnimationGroup;
  34710. /**
  34711. * Dispose all associated resources
  34712. */
  34713. dispose(): void;
  34714. private _checkAnimationGroupEnded;
  34715. /**
  34716. * Clone the current animation group and returns a copy
  34717. * @param newName defines the name of the new group
  34718. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34719. * @returns the new aniamtion group
  34720. */
  34721. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34722. /**
  34723. * Serializes the animationGroup to an object
  34724. * @returns Serialized object
  34725. */
  34726. serialize(): any;
  34727. /**
  34728. * Returns a new AnimationGroup object parsed from the source provided.
  34729. * @param parsedAnimationGroup defines the source
  34730. * @param scene defines the scene that will receive the animationGroup
  34731. * @returns a new AnimationGroup
  34732. */
  34733. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34734. /**
  34735. * Returns the string "AnimationGroup"
  34736. * @returns "AnimationGroup"
  34737. */
  34738. getClassName(): string;
  34739. /**
  34740. * Creates a detailled string about the object
  34741. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34742. * @returns a string representing the object
  34743. */
  34744. toString(fullDetails?: boolean): string;
  34745. }
  34746. }
  34747. declare module BABYLON {
  34748. /**
  34749. * Define an interface for all classes that will hold resources
  34750. */
  34751. export interface IDisposable {
  34752. /**
  34753. * Releases all held resources
  34754. */
  34755. dispose(): void;
  34756. }
  34757. /** Interface defining initialization parameters for Scene class */
  34758. export interface SceneOptions {
  34759. /**
  34760. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34761. * It will improve performance when the number of geometries becomes important.
  34762. */
  34763. useGeometryUniqueIdsMap?: boolean;
  34764. /**
  34765. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34766. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34767. */
  34768. useMaterialMeshMap?: boolean;
  34769. /**
  34770. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34771. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34772. */
  34773. useClonedMeshhMap?: boolean;
  34774. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34775. virtual?: boolean;
  34776. }
  34777. /**
  34778. * Represents a scene to be rendered by the engine.
  34779. * @see http://doc.babylonjs.com/features/scene
  34780. */
  34781. export class Scene extends AbstractScene implements IAnimatable {
  34782. /** The fog is deactivated */
  34783. static readonly FOGMODE_NONE: number;
  34784. /** The fog density is following an exponential function */
  34785. static readonly FOGMODE_EXP: number;
  34786. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34787. static readonly FOGMODE_EXP2: number;
  34788. /** The fog density is following a linear function. */
  34789. static readonly FOGMODE_LINEAR: number;
  34790. /**
  34791. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34793. */
  34794. static MinDeltaTime: number;
  34795. /**
  34796. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34797. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34798. */
  34799. static MaxDeltaTime: number;
  34800. /**
  34801. * Factory used to create the default material.
  34802. * @param name The name of the material to create
  34803. * @param scene The scene to create the material for
  34804. * @returns The default material
  34805. */
  34806. static DefaultMaterialFactory(scene: Scene): Material;
  34807. /**
  34808. * Factory used to create the a collision coordinator.
  34809. * @returns The collision coordinator
  34810. */
  34811. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34812. /** @hidden */
  34813. _inputManager: InputManager;
  34814. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34815. cameraToUseForPointers: Nullable<Camera>;
  34816. /** @hidden */
  34817. readonly _isScene: boolean;
  34818. /**
  34819. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34820. */
  34821. autoClear: boolean;
  34822. /**
  34823. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34824. */
  34825. autoClearDepthAndStencil: boolean;
  34826. /**
  34827. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34828. */
  34829. clearColor: Color4;
  34830. /**
  34831. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34832. */
  34833. ambientColor: Color3;
  34834. /**
  34835. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34836. * It should only be one of the following (if not the default embedded one):
  34837. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34838. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34839. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34840. * The material properties need to be setup according to the type of texture in use.
  34841. */
  34842. environmentBRDFTexture: BaseTexture;
  34843. /** @hidden */
  34844. protected _environmentTexture: Nullable<BaseTexture>;
  34845. /**
  34846. * Texture used in all pbr material as the reflection texture.
  34847. * As in the majority of the scene they are the same (exception for multi room and so on),
  34848. * this is easier to reference from here than from all the materials.
  34849. */
  34850. get environmentTexture(): Nullable<BaseTexture>;
  34851. /**
  34852. * Texture used in all pbr material as the reflection texture.
  34853. * As in the majority of the scene they are the same (exception for multi room and so on),
  34854. * this is easier to set here than in all the materials.
  34855. */
  34856. set environmentTexture(value: Nullable<BaseTexture>);
  34857. /** @hidden */
  34858. protected _environmentIntensity: number;
  34859. /**
  34860. * Intensity of the environment in all pbr material.
  34861. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34862. * As in the majority of the scene they are the same (exception for multi room and so on),
  34863. * this is easier to reference from here than from all the materials.
  34864. */
  34865. get environmentIntensity(): number;
  34866. /**
  34867. * Intensity of the environment in all pbr material.
  34868. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34869. * As in the majority of the scene they are the same (exception for multi room and so on),
  34870. * this is easier to set here than in all the materials.
  34871. */
  34872. set environmentIntensity(value: number);
  34873. /** @hidden */
  34874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34875. /**
  34876. * Default image processing configuration used either in the rendering
  34877. * Forward main pass or through the imageProcessingPostProcess if present.
  34878. * As in the majority of the scene they are the same (exception for multi camera),
  34879. * this is easier to reference from here than from all the materials and post process.
  34880. *
  34881. * No setter as we it is a shared configuration, you can set the values instead.
  34882. */
  34883. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34884. private _forceWireframe;
  34885. /**
  34886. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34887. */
  34888. set forceWireframe(value: boolean);
  34889. get forceWireframe(): boolean;
  34890. private _skipFrustumClipping;
  34891. /**
  34892. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  34893. */
  34894. set skipFrustumClipping(value: boolean);
  34895. get skipFrustumClipping(): boolean;
  34896. private _forcePointsCloud;
  34897. /**
  34898. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34899. */
  34900. set forcePointsCloud(value: boolean);
  34901. get forcePointsCloud(): boolean;
  34902. /**
  34903. * Gets or sets the active clipplane 1
  34904. */
  34905. clipPlane: Nullable<Plane>;
  34906. /**
  34907. * Gets or sets the active clipplane 2
  34908. */
  34909. clipPlane2: Nullable<Plane>;
  34910. /**
  34911. * Gets or sets the active clipplane 3
  34912. */
  34913. clipPlane3: Nullable<Plane>;
  34914. /**
  34915. * Gets or sets the active clipplane 4
  34916. */
  34917. clipPlane4: Nullable<Plane>;
  34918. /**
  34919. * Gets or sets the active clipplane 5
  34920. */
  34921. clipPlane5: Nullable<Plane>;
  34922. /**
  34923. * Gets or sets the active clipplane 6
  34924. */
  34925. clipPlane6: Nullable<Plane>;
  34926. /**
  34927. * Gets or sets a boolean indicating if animations are enabled
  34928. */
  34929. animationsEnabled: boolean;
  34930. private _animationPropertiesOverride;
  34931. /**
  34932. * Gets or sets the animation properties override
  34933. */
  34934. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34935. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34936. /**
  34937. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34938. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34939. */
  34940. useConstantAnimationDeltaTime: boolean;
  34941. /**
  34942. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34943. * Please note that it requires to run a ray cast through the scene on every frame
  34944. */
  34945. constantlyUpdateMeshUnderPointer: boolean;
  34946. /**
  34947. * Defines the HTML cursor to use when hovering over interactive elements
  34948. */
  34949. hoverCursor: string;
  34950. /**
  34951. * Defines the HTML default cursor to use (empty by default)
  34952. */
  34953. defaultCursor: string;
  34954. /**
  34955. * Defines wether cursors are handled by the scene.
  34956. */
  34957. doNotHandleCursors: boolean;
  34958. /**
  34959. * This is used to call preventDefault() on pointer down
  34960. * in order to block unwanted artifacts like system double clicks
  34961. */
  34962. preventDefaultOnPointerDown: boolean;
  34963. /**
  34964. * This is used to call preventDefault() on pointer up
  34965. * in order to block unwanted artifacts like system double clicks
  34966. */
  34967. preventDefaultOnPointerUp: boolean;
  34968. /**
  34969. * Gets or sets user defined metadata
  34970. */
  34971. metadata: any;
  34972. /**
  34973. * For internal use only. Please do not use.
  34974. */
  34975. reservedDataStore: any;
  34976. /**
  34977. * Gets the name of the plugin used to load this scene (null by default)
  34978. */
  34979. loadingPluginName: string;
  34980. /**
  34981. * Use this array to add regular expressions used to disable offline support for specific urls
  34982. */
  34983. disableOfflineSupportExceptionRules: RegExp[];
  34984. /**
  34985. * An event triggered when the scene is disposed.
  34986. */
  34987. onDisposeObservable: Observable<Scene>;
  34988. private _onDisposeObserver;
  34989. /** Sets a function to be executed when this scene is disposed. */
  34990. set onDispose(callback: () => void);
  34991. /**
  34992. * An event triggered before rendering the scene (right after animations and physics)
  34993. */
  34994. onBeforeRenderObservable: Observable<Scene>;
  34995. private _onBeforeRenderObserver;
  34996. /** Sets a function to be executed before rendering this scene */
  34997. set beforeRender(callback: Nullable<() => void>);
  34998. /**
  34999. * An event triggered after rendering the scene
  35000. */
  35001. onAfterRenderObservable: Observable<Scene>;
  35002. /**
  35003. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35004. */
  35005. onAfterRenderCameraObservable: Observable<Camera>;
  35006. private _onAfterRenderObserver;
  35007. /** Sets a function to be executed after rendering this scene */
  35008. set afterRender(callback: Nullable<() => void>);
  35009. /**
  35010. * An event triggered before animating the scene
  35011. */
  35012. onBeforeAnimationsObservable: Observable<Scene>;
  35013. /**
  35014. * An event triggered after animations processing
  35015. */
  35016. onAfterAnimationsObservable: Observable<Scene>;
  35017. /**
  35018. * An event triggered before draw calls are ready to be sent
  35019. */
  35020. onBeforeDrawPhaseObservable: Observable<Scene>;
  35021. /**
  35022. * An event triggered after draw calls have been sent
  35023. */
  35024. onAfterDrawPhaseObservable: Observable<Scene>;
  35025. /**
  35026. * An event triggered when the scene is ready
  35027. */
  35028. onReadyObservable: Observable<Scene>;
  35029. /**
  35030. * An event triggered before rendering a camera
  35031. */
  35032. onBeforeCameraRenderObservable: Observable<Camera>;
  35033. private _onBeforeCameraRenderObserver;
  35034. /** Sets a function to be executed before rendering a camera*/
  35035. set beforeCameraRender(callback: () => void);
  35036. /**
  35037. * An event triggered after rendering a camera
  35038. */
  35039. onAfterCameraRenderObservable: Observable<Camera>;
  35040. private _onAfterCameraRenderObserver;
  35041. /** Sets a function to be executed after rendering a camera*/
  35042. set afterCameraRender(callback: () => void);
  35043. /**
  35044. * An event triggered when active meshes evaluation is about to start
  35045. */
  35046. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35047. /**
  35048. * An event triggered when active meshes evaluation is done
  35049. */
  35050. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35051. /**
  35052. * An event triggered when particles rendering is about to start
  35053. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35054. */
  35055. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35056. /**
  35057. * An event triggered when particles rendering is done
  35058. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35059. */
  35060. onAfterParticlesRenderingObservable: Observable<Scene>;
  35061. /**
  35062. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35063. */
  35064. onDataLoadedObservable: Observable<Scene>;
  35065. /**
  35066. * An event triggered when a camera is created
  35067. */
  35068. onNewCameraAddedObservable: Observable<Camera>;
  35069. /**
  35070. * An event triggered when a camera is removed
  35071. */
  35072. onCameraRemovedObservable: Observable<Camera>;
  35073. /**
  35074. * An event triggered when a light is created
  35075. */
  35076. onNewLightAddedObservable: Observable<Light>;
  35077. /**
  35078. * An event triggered when a light is removed
  35079. */
  35080. onLightRemovedObservable: Observable<Light>;
  35081. /**
  35082. * An event triggered when a geometry is created
  35083. */
  35084. onNewGeometryAddedObservable: Observable<Geometry>;
  35085. /**
  35086. * An event triggered when a geometry is removed
  35087. */
  35088. onGeometryRemovedObservable: Observable<Geometry>;
  35089. /**
  35090. * An event triggered when a transform node is created
  35091. */
  35092. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35093. /**
  35094. * An event triggered when a transform node is removed
  35095. */
  35096. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35097. /**
  35098. * An event triggered when a mesh is created
  35099. */
  35100. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35101. /**
  35102. * An event triggered when a mesh is removed
  35103. */
  35104. onMeshRemovedObservable: Observable<AbstractMesh>;
  35105. /**
  35106. * An event triggered when a skeleton is created
  35107. */
  35108. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35109. /**
  35110. * An event triggered when a skeleton is removed
  35111. */
  35112. onSkeletonRemovedObservable: Observable<Skeleton>;
  35113. /**
  35114. * An event triggered when a material is created
  35115. */
  35116. onNewMaterialAddedObservable: Observable<Material>;
  35117. /**
  35118. * An event triggered when a material is removed
  35119. */
  35120. onMaterialRemovedObservable: Observable<Material>;
  35121. /**
  35122. * An event triggered when a texture is created
  35123. */
  35124. onNewTextureAddedObservable: Observable<BaseTexture>;
  35125. /**
  35126. * An event triggered when a texture is removed
  35127. */
  35128. onTextureRemovedObservable: Observable<BaseTexture>;
  35129. /**
  35130. * An event triggered when render targets are about to be rendered
  35131. * Can happen multiple times per frame.
  35132. */
  35133. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35134. /**
  35135. * An event triggered when render targets were rendered.
  35136. * Can happen multiple times per frame.
  35137. */
  35138. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35139. /**
  35140. * An event triggered before calculating deterministic simulation step
  35141. */
  35142. onBeforeStepObservable: Observable<Scene>;
  35143. /**
  35144. * An event triggered after calculating deterministic simulation step
  35145. */
  35146. onAfterStepObservable: Observable<Scene>;
  35147. /**
  35148. * An event triggered when the activeCamera property is updated
  35149. */
  35150. onActiveCameraChanged: Observable<Scene>;
  35151. /**
  35152. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35153. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35154. * 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)
  35155. */
  35156. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35157. /**
  35158. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35159. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35160. * 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)
  35161. */
  35162. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35163. /**
  35164. * This Observable will when a mesh has been imported into the scene.
  35165. */
  35166. onMeshImportedObservable: Observable<AbstractMesh>;
  35167. /**
  35168. * This Observable will when an animation file has been imported into the scene.
  35169. */
  35170. onAnimationFileImportedObservable: Observable<Scene>;
  35171. /**
  35172. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35173. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35174. */
  35175. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35176. /** @hidden */
  35177. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35178. /**
  35179. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35180. */
  35181. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35182. /**
  35183. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35184. */
  35185. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35186. /**
  35187. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35188. */
  35189. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35190. /** Callback called when a pointer move is detected */
  35191. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35192. /** Callback called when a pointer down is detected */
  35193. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35194. /** Callback called when a pointer up is detected */
  35195. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35196. /** Callback called when a pointer pick is detected */
  35197. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35198. /**
  35199. * 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).
  35200. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35201. */
  35202. onPrePointerObservable: Observable<PointerInfoPre>;
  35203. /**
  35204. * Observable event triggered each time an input event is received from the rendering canvas
  35205. */
  35206. onPointerObservable: Observable<PointerInfo>;
  35207. /**
  35208. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35209. */
  35210. get unTranslatedPointer(): Vector2;
  35211. /**
  35212. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35213. */
  35214. static get DragMovementThreshold(): number;
  35215. static set DragMovementThreshold(value: number);
  35216. /**
  35217. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35218. */
  35219. static get LongPressDelay(): number;
  35220. static set LongPressDelay(value: number);
  35221. /**
  35222. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35223. */
  35224. static get DoubleClickDelay(): number;
  35225. static set DoubleClickDelay(value: number);
  35226. /** If you need to check double click without raising a single click at first click, enable this flag */
  35227. static get ExclusiveDoubleClickMode(): boolean;
  35228. static set ExclusiveDoubleClickMode(value: boolean);
  35229. /** @hidden */
  35230. _mirroredCameraPosition: Nullable<Vector3>;
  35231. /**
  35232. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35233. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35234. */
  35235. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35236. /**
  35237. * Observable event triggered each time an keyboard event is received from the hosting window
  35238. */
  35239. onKeyboardObservable: Observable<KeyboardInfo>;
  35240. private _useRightHandedSystem;
  35241. /**
  35242. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35243. */
  35244. set useRightHandedSystem(value: boolean);
  35245. get useRightHandedSystem(): boolean;
  35246. private _timeAccumulator;
  35247. private _currentStepId;
  35248. private _currentInternalStep;
  35249. /**
  35250. * Sets the step Id used by deterministic lock step
  35251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35252. * @param newStepId defines the step Id
  35253. */
  35254. setStepId(newStepId: number): void;
  35255. /**
  35256. * Gets the step Id used by deterministic lock step
  35257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35258. * @returns the step Id
  35259. */
  35260. getStepId(): number;
  35261. /**
  35262. * Gets the internal step used by deterministic lock step
  35263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35264. * @returns the internal step
  35265. */
  35266. getInternalStep(): number;
  35267. private _fogEnabled;
  35268. /**
  35269. * Gets or sets a boolean indicating if fog is enabled on this scene
  35270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35271. * (Default is true)
  35272. */
  35273. set fogEnabled(value: boolean);
  35274. get fogEnabled(): boolean;
  35275. private _fogMode;
  35276. /**
  35277. * Gets or sets the fog mode to use
  35278. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35279. * | mode | value |
  35280. * | --- | --- |
  35281. * | FOGMODE_NONE | 0 |
  35282. * | FOGMODE_EXP | 1 |
  35283. * | FOGMODE_EXP2 | 2 |
  35284. * | FOGMODE_LINEAR | 3 |
  35285. */
  35286. set fogMode(value: number);
  35287. get fogMode(): number;
  35288. /**
  35289. * Gets or sets the fog color to use
  35290. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35291. * (Default is Color3(0.2, 0.2, 0.3))
  35292. */
  35293. fogColor: Color3;
  35294. /**
  35295. * Gets or sets the fog density to use
  35296. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35297. * (Default is 0.1)
  35298. */
  35299. fogDensity: number;
  35300. /**
  35301. * Gets or sets the fog start distance to use
  35302. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35303. * (Default is 0)
  35304. */
  35305. fogStart: number;
  35306. /**
  35307. * Gets or sets the fog end distance to use
  35308. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35309. * (Default is 1000)
  35310. */
  35311. fogEnd: number;
  35312. private _shadowsEnabled;
  35313. /**
  35314. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35315. */
  35316. set shadowsEnabled(value: boolean);
  35317. get shadowsEnabled(): boolean;
  35318. private _lightsEnabled;
  35319. /**
  35320. * Gets or sets a boolean indicating if lights are enabled on this scene
  35321. */
  35322. set lightsEnabled(value: boolean);
  35323. get lightsEnabled(): boolean;
  35324. /** All of the active cameras added to this scene. */
  35325. activeCameras: Camera[];
  35326. /** @hidden */
  35327. _activeCamera: Nullable<Camera>;
  35328. /** Gets or sets the current active camera */
  35329. get activeCamera(): Nullable<Camera>;
  35330. set activeCamera(value: Nullable<Camera>);
  35331. private _defaultMaterial;
  35332. /** The default material used on meshes when no material is affected */
  35333. get defaultMaterial(): Material;
  35334. /** The default material used on meshes when no material is affected */
  35335. set defaultMaterial(value: Material);
  35336. private _texturesEnabled;
  35337. /**
  35338. * Gets or sets a boolean indicating if textures are enabled on this scene
  35339. */
  35340. set texturesEnabled(value: boolean);
  35341. get texturesEnabled(): boolean;
  35342. /**
  35343. * Gets or sets a boolean indicating if particles are enabled on this scene
  35344. */
  35345. particlesEnabled: boolean;
  35346. /**
  35347. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35348. */
  35349. spritesEnabled: boolean;
  35350. private _skeletonsEnabled;
  35351. /**
  35352. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35353. */
  35354. set skeletonsEnabled(value: boolean);
  35355. get skeletonsEnabled(): boolean;
  35356. /**
  35357. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35358. */
  35359. lensFlaresEnabled: boolean;
  35360. /**
  35361. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35363. */
  35364. collisionsEnabled: boolean;
  35365. private _collisionCoordinator;
  35366. /** @hidden */
  35367. get collisionCoordinator(): ICollisionCoordinator;
  35368. /**
  35369. * Defines the gravity applied to this scene (used only for collisions)
  35370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35371. */
  35372. gravity: Vector3;
  35373. /**
  35374. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35375. */
  35376. postProcessesEnabled: boolean;
  35377. /**
  35378. * The list of postprocesses added to the scene
  35379. */
  35380. postProcesses: PostProcess[];
  35381. /**
  35382. * Gets the current postprocess manager
  35383. */
  35384. postProcessManager: PostProcessManager;
  35385. /**
  35386. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35387. */
  35388. renderTargetsEnabled: boolean;
  35389. /**
  35390. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35391. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35392. */
  35393. dumpNextRenderTargets: boolean;
  35394. /**
  35395. * The list of user defined render targets added to the scene
  35396. */
  35397. customRenderTargets: RenderTargetTexture[];
  35398. /**
  35399. * Defines if texture loading must be delayed
  35400. * If true, textures will only be loaded when they need to be rendered
  35401. */
  35402. useDelayedTextureLoading: boolean;
  35403. /**
  35404. * Gets the list of meshes imported to the scene through SceneLoader
  35405. */
  35406. importedMeshesFiles: String[];
  35407. /**
  35408. * Gets or sets a boolean indicating if probes are enabled on this scene
  35409. */
  35410. probesEnabled: boolean;
  35411. /**
  35412. * Gets or sets the current offline provider to use to store scene data
  35413. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35414. */
  35415. offlineProvider: IOfflineProvider;
  35416. /**
  35417. * Gets or sets the action manager associated with the scene
  35418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35419. */
  35420. actionManager: AbstractActionManager;
  35421. private _meshesForIntersections;
  35422. /**
  35423. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35424. */
  35425. proceduralTexturesEnabled: boolean;
  35426. private _engine;
  35427. private _totalVertices;
  35428. /** @hidden */
  35429. _activeIndices: PerfCounter;
  35430. /** @hidden */
  35431. _activeParticles: PerfCounter;
  35432. /** @hidden */
  35433. _activeBones: PerfCounter;
  35434. private _animationRatio;
  35435. /** @hidden */
  35436. _animationTimeLast: number;
  35437. /** @hidden */
  35438. _animationTime: number;
  35439. /**
  35440. * Gets or sets a general scale for animation speed
  35441. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35442. */
  35443. animationTimeScale: number;
  35444. /** @hidden */
  35445. _cachedMaterial: Nullable<Material>;
  35446. /** @hidden */
  35447. _cachedEffect: Nullable<Effect>;
  35448. /** @hidden */
  35449. _cachedVisibility: Nullable<number>;
  35450. private _renderId;
  35451. private _frameId;
  35452. private _executeWhenReadyTimeoutId;
  35453. private _intermediateRendering;
  35454. private _viewUpdateFlag;
  35455. private _projectionUpdateFlag;
  35456. /** @hidden */
  35457. _toBeDisposed: Nullable<IDisposable>[];
  35458. private _activeRequests;
  35459. /** @hidden */
  35460. _pendingData: any[];
  35461. private _isDisposed;
  35462. /**
  35463. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35464. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35465. */
  35466. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35467. private _activeMeshes;
  35468. private _processedMaterials;
  35469. private _renderTargets;
  35470. /** @hidden */
  35471. _activeParticleSystems: SmartArray<IParticleSystem>;
  35472. private _activeSkeletons;
  35473. private _softwareSkinnedMeshes;
  35474. private _renderingManager;
  35475. /** @hidden */
  35476. _activeAnimatables: Animatable[];
  35477. private _transformMatrix;
  35478. private _sceneUbo;
  35479. /** @hidden */
  35480. _viewMatrix: Matrix;
  35481. private _projectionMatrix;
  35482. /** @hidden */
  35483. _forcedViewPosition: Nullable<Vector3>;
  35484. /** @hidden */
  35485. _frustumPlanes: Plane[];
  35486. /**
  35487. * Gets the list of frustum planes (built from the active camera)
  35488. */
  35489. get frustumPlanes(): Plane[];
  35490. /**
  35491. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35492. * This is useful if there are more lights that the maximum simulteanous authorized
  35493. */
  35494. requireLightSorting: boolean;
  35495. /** @hidden */
  35496. readonly useMaterialMeshMap: boolean;
  35497. /** @hidden */
  35498. readonly useClonedMeshhMap: boolean;
  35499. private _externalData;
  35500. private _uid;
  35501. /**
  35502. * @hidden
  35503. * Backing store of defined scene components.
  35504. */
  35505. _components: ISceneComponent[];
  35506. /**
  35507. * @hidden
  35508. * Backing store of defined scene components.
  35509. */
  35510. _serializableComponents: ISceneSerializableComponent[];
  35511. /**
  35512. * List of components to register on the next registration step.
  35513. */
  35514. private _transientComponents;
  35515. /**
  35516. * Registers the transient components if needed.
  35517. */
  35518. private _registerTransientComponents;
  35519. /**
  35520. * @hidden
  35521. * Add a component to the scene.
  35522. * Note that the ccomponent could be registered on th next frame if this is called after
  35523. * the register component stage.
  35524. * @param component Defines the component to add to the scene
  35525. */
  35526. _addComponent(component: ISceneComponent): void;
  35527. /**
  35528. * @hidden
  35529. * Gets a component from the scene.
  35530. * @param name defines the name of the component to retrieve
  35531. * @returns the component or null if not present
  35532. */
  35533. _getComponent(name: string): Nullable<ISceneComponent>;
  35534. /**
  35535. * @hidden
  35536. * Defines the actions happening before camera updates.
  35537. */
  35538. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35539. /**
  35540. * @hidden
  35541. * Defines the actions happening before clear the canvas.
  35542. */
  35543. _beforeClearStage: Stage<SimpleStageAction>;
  35544. /**
  35545. * @hidden
  35546. * Defines the actions when collecting render targets for the frame.
  35547. */
  35548. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35549. /**
  35550. * @hidden
  35551. * Defines the actions happening for one camera in the frame.
  35552. */
  35553. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35554. /**
  35555. * @hidden
  35556. * Defines the actions happening during the per mesh ready checks.
  35557. */
  35558. _isReadyForMeshStage: Stage<MeshStageAction>;
  35559. /**
  35560. * @hidden
  35561. * Defines the actions happening before evaluate active mesh checks.
  35562. */
  35563. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35564. /**
  35565. * @hidden
  35566. * Defines the actions happening during the evaluate sub mesh checks.
  35567. */
  35568. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35569. /**
  35570. * @hidden
  35571. * Defines the actions happening during the active mesh stage.
  35572. */
  35573. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35574. /**
  35575. * @hidden
  35576. * Defines the actions happening during the per camera render target step.
  35577. */
  35578. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35579. /**
  35580. * @hidden
  35581. * Defines the actions happening just before the active camera is drawing.
  35582. */
  35583. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35584. /**
  35585. * @hidden
  35586. * Defines the actions happening just before a render target is drawing.
  35587. */
  35588. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35589. /**
  35590. * @hidden
  35591. * Defines the actions happening just before a rendering group is drawing.
  35592. */
  35593. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35594. /**
  35595. * @hidden
  35596. * Defines the actions happening just before a mesh is drawing.
  35597. */
  35598. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35599. /**
  35600. * @hidden
  35601. * Defines the actions happening just after a mesh has been drawn.
  35602. */
  35603. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35604. /**
  35605. * @hidden
  35606. * Defines the actions happening just after a rendering group has been drawn.
  35607. */
  35608. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35609. /**
  35610. * @hidden
  35611. * Defines the actions happening just after the active camera has been drawn.
  35612. */
  35613. _afterCameraDrawStage: Stage<CameraStageAction>;
  35614. /**
  35615. * @hidden
  35616. * Defines the actions happening just after a render target has been drawn.
  35617. */
  35618. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35619. /**
  35620. * @hidden
  35621. * Defines the actions happening just after rendering all cameras and computing intersections.
  35622. */
  35623. _afterRenderStage: Stage<SimpleStageAction>;
  35624. /**
  35625. * @hidden
  35626. * Defines the actions happening when a pointer move event happens.
  35627. */
  35628. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35629. /**
  35630. * @hidden
  35631. * Defines the actions happening when a pointer down event happens.
  35632. */
  35633. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35634. /**
  35635. * @hidden
  35636. * Defines the actions happening when a pointer up event happens.
  35637. */
  35638. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35639. /**
  35640. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35641. */
  35642. private geometriesByUniqueId;
  35643. /**
  35644. * Creates a new Scene
  35645. * @param engine defines the engine to use to render this scene
  35646. * @param options defines the scene options
  35647. */
  35648. constructor(engine: Engine, options?: SceneOptions);
  35649. /**
  35650. * Gets a string idenfifying the name of the class
  35651. * @returns "Scene" string
  35652. */
  35653. getClassName(): string;
  35654. private _defaultMeshCandidates;
  35655. /**
  35656. * @hidden
  35657. */
  35658. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35659. private _defaultSubMeshCandidates;
  35660. /**
  35661. * @hidden
  35662. */
  35663. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35664. /**
  35665. * Sets the default candidate providers for the scene.
  35666. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35667. * and getCollidingSubMeshCandidates to their default function
  35668. */
  35669. setDefaultCandidateProviders(): void;
  35670. /**
  35671. * Gets the mesh that is currently under the pointer
  35672. */
  35673. get meshUnderPointer(): Nullable<AbstractMesh>;
  35674. /**
  35675. * Gets or sets the current on-screen X position of the pointer
  35676. */
  35677. get pointerX(): number;
  35678. set pointerX(value: number);
  35679. /**
  35680. * Gets or sets the current on-screen Y position of the pointer
  35681. */
  35682. get pointerY(): number;
  35683. set pointerY(value: number);
  35684. /**
  35685. * Gets the cached material (ie. the latest rendered one)
  35686. * @returns the cached material
  35687. */
  35688. getCachedMaterial(): Nullable<Material>;
  35689. /**
  35690. * Gets the cached effect (ie. the latest rendered one)
  35691. * @returns the cached effect
  35692. */
  35693. getCachedEffect(): Nullable<Effect>;
  35694. /**
  35695. * Gets the cached visibility state (ie. the latest rendered one)
  35696. * @returns the cached visibility state
  35697. */
  35698. getCachedVisibility(): Nullable<number>;
  35699. /**
  35700. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35701. * @param material defines the current material
  35702. * @param effect defines the current effect
  35703. * @param visibility defines the current visibility state
  35704. * @returns true if one parameter is not cached
  35705. */
  35706. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35707. /**
  35708. * Gets the engine associated with the scene
  35709. * @returns an Engine
  35710. */
  35711. getEngine(): Engine;
  35712. /**
  35713. * Gets the total number of vertices rendered per frame
  35714. * @returns the total number of vertices rendered per frame
  35715. */
  35716. getTotalVertices(): number;
  35717. /**
  35718. * Gets the performance counter for total vertices
  35719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35720. */
  35721. get totalVerticesPerfCounter(): PerfCounter;
  35722. /**
  35723. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35724. * @returns the total number of active indices rendered per frame
  35725. */
  35726. getActiveIndices(): number;
  35727. /**
  35728. * Gets the performance counter for active indices
  35729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35730. */
  35731. get totalActiveIndicesPerfCounter(): PerfCounter;
  35732. /**
  35733. * Gets the total number of active particles rendered per frame
  35734. * @returns the total number of active particles rendered per frame
  35735. */
  35736. getActiveParticles(): number;
  35737. /**
  35738. * Gets the performance counter for active particles
  35739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35740. */
  35741. get activeParticlesPerfCounter(): PerfCounter;
  35742. /**
  35743. * Gets the total number of active bones rendered per frame
  35744. * @returns the total number of active bones rendered per frame
  35745. */
  35746. getActiveBones(): number;
  35747. /**
  35748. * Gets the performance counter for active bones
  35749. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35750. */
  35751. get activeBonesPerfCounter(): PerfCounter;
  35752. /**
  35753. * Gets the array of active meshes
  35754. * @returns an array of AbstractMesh
  35755. */
  35756. getActiveMeshes(): SmartArray<AbstractMesh>;
  35757. /**
  35758. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35759. * @returns a number
  35760. */
  35761. getAnimationRatio(): number;
  35762. /**
  35763. * Gets an unique Id for the current render phase
  35764. * @returns a number
  35765. */
  35766. getRenderId(): number;
  35767. /**
  35768. * Gets an unique Id for the current frame
  35769. * @returns a number
  35770. */
  35771. getFrameId(): number;
  35772. /** Call this function if you want to manually increment the render Id*/
  35773. incrementRenderId(): void;
  35774. private _createUbo;
  35775. /**
  35776. * Use this method to simulate a pointer move on a mesh
  35777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35780. * @returns the current scene
  35781. */
  35782. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35783. /**
  35784. * Use this method to simulate a pointer down on a mesh
  35785. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35786. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35787. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35788. * @returns the current scene
  35789. */
  35790. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35791. /**
  35792. * Use this method to simulate a pointer up on a mesh
  35793. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35794. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35795. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35796. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35797. * @returns the current scene
  35798. */
  35799. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35800. /**
  35801. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35802. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35803. * @returns true if the pointer was captured
  35804. */
  35805. isPointerCaptured(pointerId?: number): boolean;
  35806. /**
  35807. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35808. * @param attachUp defines if you want to attach events to pointerup
  35809. * @param attachDown defines if you want to attach events to pointerdown
  35810. * @param attachMove defines if you want to attach events to pointermove
  35811. */
  35812. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35813. /** Detaches all event handlers*/
  35814. detachControl(): void;
  35815. /**
  35816. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35817. * Delay loaded resources are not taking in account
  35818. * @return true if all required resources are ready
  35819. */
  35820. isReady(): boolean;
  35821. /** Resets all cached information relative to material (including effect and visibility) */
  35822. resetCachedMaterial(): void;
  35823. /**
  35824. * Registers a function to be called before every frame render
  35825. * @param func defines the function to register
  35826. */
  35827. registerBeforeRender(func: () => void): void;
  35828. /**
  35829. * Unregisters a function called before every frame render
  35830. * @param func defines the function to unregister
  35831. */
  35832. unregisterBeforeRender(func: () => void): void;
  35833. /**
  35834. * Registers a function to be called after every frame render
  35835. * @param func defines the function to register
  35836. */
  35837. registerAfterRender(func: () => void): void;
  35838. /**
  35839. * Unregisters a function called after every frame render
  35840. * @param func defines the function to unregister
  35841. */
  35842. unregisterAfterRender(func: () => void): void;
  35843. private _executeOnceBeforeRender;
  35844. /**
  35845. * The provided function will run before render once and will be disposed afterwards.
  35846. * A timeout delay can be provided so that the function will be executed in N ms.
  35847. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35848. * @param func The function to be executed.
  35849. * @param timeout optional delay in ms
  35850. */
  35851. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35852. /** @hidden */
  35853. _addPendingData(data: any): void;
  35854. /** @hidden */
  35855. _removePendingData(data: any): void;
  35856. /**
  35857. * Returns the number of items waiting to be loaded
  35858. * @returns the number of items waiting to be loaded
  35859. */
  35860. getWaitingItemsCount(): number;
  35861. /**
  35862. * Returns a boolean indicating if the scene is still loading data
  35863. */
  35864. get isLoading(): boolean;
  35865. /**
  35866. * Registers a function to be executed when the scene is ready
  35867. * @param {Function} func - the function to be executed
  35868. */
  35869. executeWhenReady(func: () => void): void;
  35870. /**
  35871. * Returns a promise that resolves when the scene is ready
  35872. * @returns A promise that resolves when the scene is ready
  35873. */
  35874. whenReadyAsync(): Promise<void>;
  35875. /** @hidden */
  35876. _checkIsReady(): void;
  35877. /**
  35878. * Gets all animatable attached to the scene
  35879. */
  35880. get animatables(): Animatable[];
  35881. /**
  35882. * Resets the last animation time frame.
  35883. * Useful to override when animations start running when loading a scene for the first time.
  35884. */
  35885. resetLastAnimationTimeFrame(): void;
  35886. /**
  35887. * Gets the current view matrix
  35888. * @returns a Matrix
  35889. */
  35890. getViewMatrix(): Matrix;
  35891. /**
  35892. * Gets the current projection matrix
  35893. * @returns a Matrix
  35894. */
  35895. getProjectionMatrix(): Matrix;
  35896. /**
  35897. * Gets the current transform matrix
  35898. * @returns a Matrix made of View * Projection
  35899. */
  35900. getTransformMatrix(): Matrix;
  35901. /**
  35902. * Sets the current transform matrix
  35903. * @param viewL defines the View matrix to use
  35904. * @param projectionL defines the Projection matrix to use
  35905. * @param viewR defines the right View matrix to use (if provided)
  35906. * @param projectionR defines the right Projection matrix to use (if provided)
  35907. */
  35908. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35909. /**
  35910. * Gets the uniform buffer used to store scene data
  35911. * @returns a UniformBuffer
  35912. */
  35913. getSceneUniformBuffer(): UniformBuffer;
  35914. /**
  35915. * Gets an unique (relatively to the current scene) Id
  35916. * @returns an unique number for the scene
  35917. */
  35918. getUniqueId(): number;
  35919. /**
  35920. * Add a mesh to the list of scene's meshes
  35921. * @param newMesh defines the mesh to add
  35922. * @param recursive if all child meshes should also be added to the scene
  35923. */
  35924. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35925. /**
  35926. * Remove a mesh for the list of scene's meshes
  35927. * @param toRemove defines the mesh to remove
  35928. * @param recursive if all child meshes should also be removed from the scene
  35929. * @returns the index where the mesh was in the mesh list
  35930. */
  35931. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35932. /**
  35933. * Add a transform node to the list of scene's transform nodes
  35934. * @param newTransformNode defines the transform node to add
  35935. */
  35936. addTransformNode(newTransformNode: TransformNode): void;
  35937. /**
  35938. * Remove a transform node for the list of scene's transform nodes
  35939. * @param toRemove defines the transform node to remove
  35940. * @returns the index where the transform node was in the transform node list
  35941. */
  35942. removeTransformNode(toRemove: TransformNode): number;
  35943. /**
  35944. * Remove a skeleton for the list of scene's skeletons
  35945. * @param toRemove defines the skeleton to remove
  35946. * @returns the index where the skeleton was in the skeleton list
  35947. */
  35948. removeSkeleton(toRemove: Skeleton): number;
  35949. /**
  35950. * Remove a morph target for the list of scene's morph targets
  35951. * @param toRemove defines the morph target to remove
  35952. * @returns the index where the morph target was in the morph target list
  35953. */
  35954. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35955. /**
  35956. * Remove a light for the list of scene's lights
  35957. * @param toRemove defines the light to remove
  35958. * @returns the index where the light was in the light list
  35959. */
  35960. removeLight(toRemove: Light): number;
  35961. /**
  35962. * Remove a camera for the list of scene's cameras
  35963. * @param toRemove defines the camera to remove
  35964. * @returns the index where the camera was in the camera list
  35965. */
  35966. removeCamera(toRemove: Camera): number;
  35967. /**
  35968. * Remove a particle system for the list of scene's particle systems
  35969. * @param toRemove defines the particle system to remove
  35970. * @returns the index where the particle system was in the particle system list
  35971. */
  35972. removeParticleSystem(toRemove: IParticleSystem): number;
  35973. /**
  35974. * Remove a animation for the list of scene's animations
  35975. * @param toRemove defines the animation to remove
  35976. * @returns the index where the animation was in the animation list
  35977. */
  35978. removeAnimation(toRemove: Animation): number;
  35979. /**
  35980. * Will stop the animation of the given target
  35981. * @param target - the target
  35982. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35983. * @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)
  35984. */
  35985. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35986. /**
  35987. * Removes the given animation group from this scene.
  35988. * @param toRemove The animation group to remove
  35989. * @returns The index of the removed animation group
  35990. */
  35991. removeAnimationGroup(toRemove: AnimationGroup): number;
  35992. /**
  35993. * Removes the given multi-material from this scene.
  35994. * @param toRemove The multi-material to remove
  35995. * @returns The index of the removed multi-material
  35996. */
  35997. removeMultiMaterial(toRemove: MultiMaterial): number;
  35998. /**
  35999. * Removes the given material from this scene.
  36000. * @param toRemove The material to remove
  36001. * @returns The index of the removed material
  36002. */
  36003. removeMaterial(toRemove: Material): number;
  36004. /**
  36005. * Removes the given action manager from this scene.
  36006. * @param toRemove The action manager to remove
  36007. * @returns The index of the removed action manager
  36008. */
  36009. removeActionManager(toRemove: AbstractActionManager): number;
  36010. /**
  36011. * Removes the given texture from this scene.
  36012. * @param toRemove The texture to remove
  36013. * @returns The index of the removed texture
  36014. */
  36015. removeTexture(toRemove: BaseTexture): number;
  36016. /**
  36017. * Adds the given light to this scene
  36018. * @param newLight The light to add
  36019. */
  36020. addLight(newLight: Light): void;
  36021. /**
  36022. * Sorts the list list based on light priorities
  36023. */
  36024. sortLightsByPriority(): void;
  36025. /**
  36026. * Adds the given camera to this scene
  36027. * @param newCamera The camera to add
  36028. */
  36029. addCamera(newCamera: Camera): void;
  36030. /**
  36031. * Adds the given skeleton to this scene
  36032. * @param newSkeleton The skeleton to add
  36033. */
  36034. addSkeleton(newSkeleton: Skeleton): void;
  36035. /**
  36036. * Adds the given particle system to this scene
  36037. * @param newParticleSystem The particle system to add
  36038. */
  36039. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36040. /**
  36041. * Adds the given animation to this scene
  36042. * @param newAnimation The animation to add
  36043. */
  36044. addAnimation(newAnimation: Animation): void;
  36045. /**
  36046. * Adds the given animation group to this scene.
  36047. * @param newAnimationGroup The animation group to add
  36048. */
  36049. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36050. /**
  36051. * Adds the given multi-material to this scene
  36052. * @param newMultiMaterial The multi-material to add
  36053. */
  36054. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36055. /**
  36056. * Adds the given material to this scene
  36057. * @param newMaterial The material to add
  36058. */
  36059. addMaterial(newMaterial: Material): void;
  36060. /**
  36061. * Adds the given morph target to this scene
  36062. * @param newMorphTargetManager The morph target to add
  36063. */
  36064. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36065. /**
  36066. * Adds the given geometry to this scene
  36067. * @param newGeometry The geometry to add
  36068. */
  36069. addGeometry(newGeometry: Geometry): void;
  36070. /**
  36071. * Adds the given action manager to this scene
  36072. * @param newActionManager The action manager to add
  36073. */
  36074. addActionManager(newActionManager: AbstractActionManager): void;
  36075. /**
  36076. * Adds the given texture to this scene.
  36077. * @param newTexture The texture to add
  36078. */
  36079. addTexture(newTexture: BaseTexture): void;
  36080. /**
  36081. * Switch active camera
  36082. * @param newCamera defines the new active camera
  36083. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36084. */
  36085. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36086. /**
  36087. * sets the active camera of the scene using its ID
  36088. * @param id defines the camera's ID
  36089. * @return the new active camera or null if none found.
  36090. */
  36091. setActiveCameraByID(id: string): Nullable<Camera>;
  36092. /**
  36093. * sets the active camera of the scene using its name
  36094. * @param name defines the camera's name
  36095. * @returns the new active camera or null if none found.
  36096. */
  36097. setActiveCameraByName(name: string): Nullable<Camera>;
  36098. /**
  36099. * get an animation group using its name
  36100. * @param name defines the material's name
  36101. * @return the animation group or null if none found.
  36102. */
  36103. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36104. /**
  36105. * Get a material using its unique id
  36106. * @param uniqueId defines the material's unique id
  36107. * @return the material or null if none found.
  36108. */
  36109. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36110. /**
  36111. * get a material using its id
  36112. * @param id defines the material's ID
  36113. * @return the material or null if none found.
  36114. */
  36115. getMaterialByID(id: string): Nullable<Material>;
  36116. /**
  36117. * Gets a the last added material using a given id
  36118. * @param id defines the material's ID
  36119. * @return the last material with the given id or null if none found.
  36120. */
  36121. getLastMaterialByID(id: string): Nullable<Material>;
  36122. /**
  36123. * Gets a material using its name
  36124. * @param name defines the material's name
  36125. * @return the material or null if none found.
  36126. */
  36127. getMaterialByName(name: string): Nullable<Material>;
  36128. /**
  36129. * Get a texture using its unique id
  36130. * @param uniqueId defines the texture's unique id
  36131. * @return the texture or null if none found.
  36132. */
  36133. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36134. /**
  36135. * Gets a camera using its id
  36136. * @param id defines the id to look for
  36137. * @returns the camera or null if not found
  36138. */
  36139. getCameraByID(id: string): Nullable<Camera>;
  36140. /**
  36141. * Gets a camera using its unique id
  36142. * @param uniqueId defines the unique id to look for
  36143. * @returns the camera or null if not found
  36144. */
  36145. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36146. /**
  36147. * Gets a camera using its name
  36148. * @param name defines the camera's name
  36149. * @return the camera or null if none found.
  36150. */
  36151. getCameraByName(name: string): Nullable<Camera>;
  36152. /**
  36153. * Gets a bone using its id
  36154. * @param id defines the bone's id
  36155. * @return the bone or null if not found
  36156. */
  36157. getBoneByID(id: string): Nullable<Bone>;
  36158. /**
  36159. * Gets a bone using its id
  36160. * @param name defines the bone's name
  36161. * @return the bone or null if not found
  36162. */
  36163. getBoneByName(name: string): Nullable<Bone>;
  36164. /**
  36165. * Gets a light node using its name
  36166. * @param name defines the the light's name
  36167. * @return the light or null if none found.
  36168. */
  36169. getLightByName(name: string): Nullable<Light>;
  36170. /**
  36171. * Gets a light node using its id
  36172. * @param id defines the light's id
  36173. * @return the light or null if none found.
  36174. */
  36175. getLightByID(id: string): Nullable<Light>;
  36176. /**
  36177. * Gets a light node using its scene-generated unique ID
  36178. * @param uniqueId defines the light's unique id
  36179. * @return the light or null if none found.
  36180. */
  36181. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36182. /**
  36183. * Gets a particle system by id
  36184. * @param id defines the particle system id
  36185. * @return the corresponding system or null if none found
  36186. */
  36187. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36188. /**
  36189. * Gets a geometry using its ID
  36190. * @param id defines the geometry's id
  36191. * @return the geometry or null if none found.
  36192. */
  36193. getGeometryByID(id: string): Nullable<Geometry>;
  36194. private _getGeometryByUniqueID;
  36195. /**
  36196. * Add a new geometry to this scene
  36197. * @param geometry defines the geometry to be added to the scene.
  36198. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36199. * @return a boolean defining if the geometry was added or not
  36200. */
  36201. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36202. /**
  36203. * Removes an existing geometry
  36204. * @param geometry defines the geometry to be removed from the scene
  36205. * @return a boolean defining if the geometry was removed or not
  36206. */
  36207. removeGeometry(geometry: Geometry): boolean;
  36208. /**
  36209. * Gets the list of geometries attached to the scene
  36210. * @returns an array of Geometry
  36211. */
  36212. getGeometries(): Geometry[];
  36213. /**
  36214. * Gets the first added mesh found of a given ID
  36215. * @param id defines the id to search for
  36216. * @return the mesh found or null if not found at all
  36217. */
  36218. getMeshByID(id: string): Nullable<AbstractMesh>;
  36219. /**
  36220. * Gets a list of meshes using their id
  36221. * @param id defines the id to search for
  36222. * @returns a list of meshes
  36223. */
  36224. getMeshesByID(id: string): Array<AbstractMesh>;
  36225. /**
  36226. * Gets the first added transform node found of a given ID
  36227. * @param id defines the id to search for
  36228. * @return the found transform node or null if not found at all.
  36229. */
  36230. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36231. /**
  36232. * Gets a transform node with its auto-generated unique id
  36233. * @param uniqueId efines the unique id to search for
  36234. * @return the found transform node or null if not found at all.
  36235. */
  36236. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36237. /**
  36238. * Gets a list of transform nodes using their id
  36239. * @param id defines the id to search for
  36240. * @returns a list of transform nodes
  36241. */
  36242. getTransformNodesByID(id: string): Array<TransformNode>;
  36243. /**
  36244. * Gets a mesh with its auto-generated unique id
  36245. * @param uniqueId defines the unique id to search for
  36246. * @return the found mesh or null if not found at all.
  36247. */
  36248. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36249. /**
  36250. * Gets a the last added mesh using a given id
  36251. * @param id defines the id to search for
  36252. * @return the found mesh or null if not found at all.
  36253. */
  36254. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36255. /**
  36256. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36257. * @param id defines the id to search for
  36258. * @return the found node or null if not found at all
  36259. */
  36260. getLastEntryByID(id: string): Nullable<Node>;
  36261. /**
  36262. * Gets a node (Mesh, Camera, Light) using a given id
  36263. * @param id defines the id to search for
  36264. * @return the found node or null if not found at all
  36265. */
  36266. getNodeByID(id: string): Nullable<Node>;
  36267. /**
  36268. * Gets a node (Mesh, Camera, Light) using a given name
  36269. * @param name defines the name to search for
  36270. * @return the found node or null if not found at all.
  36271. */
  36272. getNodeByName(name: string): Nullable<Node>;
  36273. /**
  36274. * Gets a mesh using a given name
  36275. * @param name defines the name to search for
  36276. * @return the found mesh or null if not found at all.
  36277. */
  36278. getMeshByName(name: string): Nullable<AbstractMesh>;
  36279. /**
  36280. * Gets a transform node using a given name
  36281. * @param name defines the name to search for
  36282. * @return the found transform node or null if not found at all.
  36283. */
  36284. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36285. /**
  36286. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36287. * @param id defines the id to search for
  36288. * @return the found skeleton or null if not found at all.
  36289. */
  36290. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36291. /**
  36292. * Gets a skeleton using a given auto generated unique id
  36293. * @param uniqueId defines the unique id to search for
  36294. * @return the found skeleton or null if not found at all.
  36295. */
  36296. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36297. /**
  36298. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36299. * @param id defines the id to search for
  36300. * @return the found skeleton or null if not found at all.
  36301. */
  36302. getSkeletonById(id: string): Nullable<Skeleton>;
  36303. /**
  36304. * Gets a skeleton using a given name
  36305. * @param name defines the name to search for
  36306. * @return the found skeleton or null if not found at all.
  36307. */
  36308. getSkeletonByName(name: string): Nullable<Skeleton>;
  36309. /**
  36310. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36311. * @param id defines the id to search for
  36312. * @return the found morph target manager or null if not found at all.
  36313. */
  36314. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36315. /**
  36316. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36317. * @param id defines the id to search for
  36318. * @return the found morph target or null if not found at all.
  36319. */
  36320. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36321. /**
  36322. * Gets a boolean indicating if the given mesh is active
  36323. * @param mesh defines the mesh to look for
  36324. * @returns true if the mesh is in the active list
  36325. */
  36326. isActiveMesh(mesh: AbstractMesh): boolean;
  36327. /**
  36328. * Return a unique id as a string which can serve as an identifier for the scene
  36329. */
  36330. get uid(): string;
  36331. /**
  36332. * Add an externaly attached data from its key.
  36333. * This method call will fail and return false, if such key already exists.
  36334. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36335. * @param key the unique key that identifies the data
  36336. * @param data the data object to associate to the key for this Engine instance
  36337. * @return true if no such key were already present and the data was added successfully, false otherwise
  36338. */
  36339. addExternalData<T>(key: string, data: T): boolean;
  36340. /**
  36341. * Get an externaly attached data from its key
  36342. * @param key the unique key that identifies the data
  36343. * @return the associated data, if present (can be null), or undefined if not present
  36344. */
  36345. getExternalData<T>(key: string): Nullable<T>;
  36346. /**
  36347. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36348. * @param key the unique key that identifies the data
  36349. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36350. * @return the associated data, can be null if the factory returned null.
  36351. */
  36352. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36353. /**
  36354. * Remove an externaly attached data from the Engine instance
  36355. * @param key the unique key that identifies the data
  36356. * @return true if the data was successfully removed, false if it doesn't exist
  36357. */
  36358. removeExternalData(key: string): boolean;
  36359. private _evaluateSubMesh;
  36360. /**
  36361. * Clear the processed materials smart array preventing retention point in material dispose.
  36362. */
  36363. freeProcessedMaterials(): void;
  36364. private _preventFreeActiveMeshesAndRenderingGroups;
  36365. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36366. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36367. * when disposing several meshes in a row or a hierarchy of meshes.
  36368. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36369. */
  36370. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36371. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36372. /**
  36373. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36374. */
  36375. freeActiveMeshes(): void;
  36376. /**
  36377. * Clear the info related to rendering groups preventing retention points during dispose.
  36378. */
  36379. freeRenderingGroups(): void;
  36380. /** @hidden */
  36381. _isInIntermediateRendering(): boolean;
  36382. /**
  36383. * Lambda returning the list of potentially active meshes.
  36384. */
  36385. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36386. /**
  36387. * Lambda returning the list of potentially active sub meshes.
  36388. */
  36389. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36390. /**
  36391. * Lambda returning the list of potentially intersecting sub meshes.
  36392. */
  36393. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36394. /**
  36395. * Lambda returning the list of potentially colliding sub meshes.
  36396. */
  36397. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36398. private _activeMeshesFrozen;
  36399. private _skipEvaluateActiveMeshesCompletely;
  36400. /**
  36401. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36402. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36403. * @returns the current scene
  36404. */
  36405. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36406. /**
  36407. * Use this function to restart evaluating active meshes on every frame
  36408. * @returns the current scene
  36409. */
  36410. unfreezeActiveMeshes(): Scene;
  36411. private _evaluateActiveMeshes;
  36412. private _activeMesh;
  36413. /**
  36414. * Update the transform matrix to update from the current active camera
  36415. * @param force defines a boolean used to force the update even if cache is up to date
  36416. */
  36417. updateTransformMatrix(force?: boolean): void;
  36418. private _bindFrameBuffer;
  36419. /** @hidden */
  36420. _allowPostProcessClearColor: boolean;
  36421. /** @hidden */
  36422. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36423. private _processSubCameras;
  36424. private _checkIntersections;
  36425. /** @hidden */
  36426. _advancePhysicsEngineStep(step: number): void;
  36427. /**
  36428. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36429. */
  36430. getDeterministicFrameTime: () => number;
  36431. /** @hidden */
  36432. _animate(): void;
  36433. /** Execute all animations (for a frame) */
  36434. animate(): void;
  36435. /**
  36436. * Render the scene
  36437. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36438. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36439. */
  36440. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36441. /**
  36442. * Freeze all materials
  36443. * A frozen material will not be updatable but should be faster to render
  36444. */
  36445. freezeMaterials(): void;
  36446. /**
  36447. * Unfreeze all materials
  36448. * A frozen material will not be updatable but should be faster to render
  36449. */
  36450. unfreezeMaterials(): void;
  36451. /**
  36452. * Releases all held ressources
  36453. */
  36454. dispose(): void;
  36455. /**
  36456. * Gets if the scene is already disposed
  36457. */
  36458. get isDisposed(): boolean;
  36459. /**
  36460. * Call this function to reduce memory footprint of the scene.
  36461. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36462. */
  36463. clearCachedVertexData(): void;
  36464. /**
  36465. * This function will remove the local cached buffer data from texture.
  36466. * It will save memory but will prevent the texture from being rebuilt
  36467. */
  36468. cleanCachedTextureBuffer(): void;
  36469. /**
  36470. * Get the world extend vectors with an optional filter
  36471. *
  36472. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36473. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36474. */
  36475. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36476. min: Vector3;
  36477. max: Vector3;
  36478. };
  36479. /**
  36480. * Creates a ray that can be used to pick in the scene
  36481. * @param x defines the x coordinate of the origin (on-screen)
  36482. * @param y defines the y coordinate of the origin (on-screen)
  36483. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36484. * @param camera defines the camera to use for the picking
  36485. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36486. * @returns a Ray
  36487. */
  36488. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36489. /**
  36490. * Creates a ray that can be used to pick in the scene
  36491. * @param x defines the x coordinate of the origin (on-screen)
  36492. * @param y defines the y coordinate of the origin (on-screen)
  36493. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36494. * @param result defines the ray where to store the picking ray
  36495. * @param camera defines the camera to use for the picking
  36496. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36497. * @returns the current scene
  36498. */
  36499. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36500. /**
  36501. * Creates a ray that can be used to pick in the scene
  36502. * @param x defines the x coordinate of the origin (on-screen)
  36503. * @param y defines the y coordinate of the origin (on-screen)
  36504. * @param camera defines the camera to use for the picking
  36505. * @returns a Ray
  36506. */
  36507. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36508. /**
  36509. * Creates a ray that can be used to pick in the scene
  36510. * @param x defines the x coordinate of the origin (on-screen)
  36511. * @param y defines the y coordinate of the origin (on-screen)
  36512. * @param result defines the ray where to store the picking ray
  36513. * @param camera defines the camera to use for the picking
  36514. * @returns the current scene
  36515. */
  36516. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36517. /** Launch a ray to try to pick a mesh in the scene
  36518. * @param x position on screen
  36519. * @param y position on screen
  36520. * @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
  36521. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36522. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36524. * @returns a PickingInfo
  36525. */
  36526. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36527. /** Use the given ray to pick a mesh in the scene
  36528. * @param ray The ray to use to pick meshes
  36529. * @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
  36530. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36531. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36532. * @returns a PickingInfo
  36533. */
  36534. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36535. /**
  36536. * Launch a ray to try to pick a mesh in the scene
  36537. * @param x X position on screen
  36538. * @param y Y position on screen
  36539. * @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
  36540. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36542. * @returns an array of PickingInfo
  36543. */
  36544. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36545. /**
  36546. * Launch a ray to try to pick a mesh in the scene
  36547. * @param ray Ray to use
  36548. * @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
  36549. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36550. * @returns an array of PickingInfo
  36551. */
  36552. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36553. /**
  36554. * Force the value of meshUnderPointer
  36555. * @param mesh defines the mesh to use
  36556. */
  36557. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36558. /**
  36559. * Gets the mesh under the pointer
  36560. * @returns a Mesh or null if no mesh is under the pointer
  36561. */
  36562. getPointerOverMesh(): Nullable<AbstractMesh>;
  36563. /** @hidden */
  36564. _rebuildGeometries(): void;
  36565. /** @hidden */
  36566. _rebuildTextures(): void;
  36567. private _getByTags;
  36568. /**
  36569. * Get a list of meshes by tags
  36570. * @param tagsQuery defines the tags query to use
  36571. * @param forEach defines a predicate used to filter results
  36572. * @returns an array of Mesh
  36573. */
  36574. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36575. /**
  36576. * Get a list of cameras by tags
  36577. * @param tagsQuery defines the tags query to use
  36578. * @param forEach defines a predicate used to filter results
  36579. * @returns an array of Camera
  36580. */
  36581. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36582. /**
  36583. * Get a list of lights by tags
  36584. * @param tagsQuery defines the tags query to use
  36585. * @param forEach defines a predicate used to filter results
  36586. * @returns an array of Light
  36587. */
  36588. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36589. /**
  36590. * Get a list of materials by tags
  36591. * @param tagsQuery defines the tags query to use
  36592. * @param forEach defines a predicate used to filter results
  36593. * @returns an array of Material
  36594. */
  36595. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36596. /**
  36597. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36598. * This allowed control for front to back rendering or reversly depending of the special needs.
  36599. *
  36600. * @param renderingGroupId The rendering group id corresponding to its index
  36601. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36602. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36603. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36604. */
  36605. 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;
  36606. /**
  36607. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36608. *
  36609. * @param renderingGroupId The rendering group id corresponding to its index
  36610. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36611. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36612. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36613. */
  36614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36615. /**
  36616. * Gets the current auto clear configuration for one rendering group of the rendering
  36617. * manager.
  36618. * @param index the rendering group index to get the information for
  36619. * @returns The auto clear setup for the requested rendering group
  36620. */
  36621. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36622. private _blockMaterialDirtyMechanism;
  36623. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36624. get blockMaterialDirtyMechanism(): boolean;
  36625. set blockMaterialDirtyMechanism(value: boolean);
  36626. /**
  36627. * Will flag all materials as dirty to trigger new shader compilation
  36628. * @param flag defines the flag used to specify which material part must be marked as dirty
  36629. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36630. */
  36631. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36632. /** @hidden */
  36633. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36634. /** @hidden */
  36635. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36636. /** @hidden */
  36637. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36638. /** @hidden */
  36639. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36640. /** @hidden */
  36641. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36642. /** @hidden */
  36643. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36644. }
  36645. }
  36646. declare module BABYLON {
  36647. /**
  36648. * Set of assets to keep when moving a scene into an asset container.
  36649. */
  36650. export class KeepAssets extends AbstractScene {
  36651. }
  36652. /**
  36653. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36654. */
  36655. export class InstantiatedEntries {
  36656. /**
  36657. * List of new root nodes (eg. nodes with no parent)
  36658. */
  36659. rootNodes: TransformNode[];
  36660. /**
  36661. * List of new skeletons
  36662. */
  36663. skeletons: Skeleton[];
  36664. /**
  36665. * List of new animation groups
  36666. */
  36667. animationGroups: AnimationGroup[];
  36668. }
  36669. /**
  36670. * Container with a set of assets that can be added or removed from a scene.
  36671. */
  36672. export class AssetContainer extends AbstractScene {
  36673. /**
  36674. * The scene the AssetContainer belongs to.
  36675. */
  36676. scene: Scene;
  36677. /**
  36678. * Instantiates an AssetContainer.
  36679. * @param scene The scene the AssetContainer belongs to.
  36680. */
  36681. constructor(scene: Scene);
  36682. /**
  36683. * Instantiate or clone all meshes and add the new ones to the scene.
  36684. * Skeletons and animation groups will all be cloned
  36685. * @param nameFunction defines an optional function used to get new names for clones
  36686. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36687. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36688. */
  36689. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36690. /**
  36691. * Adds all the assets from the container to the scene.
  36692. */
  36693. addAllToScene(): void;
  36694. /**
  36695. * Removes all the assets in the container from the scene
  36696. */
  36697. removeAllFromScene(): void;
  36698. /**
  36699. * Disposes all the assets in the container
  36700. */
  36701. dispose(): void;
  36702. private _moveAssets;
  36703. /**
  36704. * Removes all the assets contained in the scene and adds them to the container.
  36705. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36706. */
  36707. moveAllFromScene(keepAssets?: KeepAssets): void;
  36708. /**
  36709. * 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.
  36710. * @returns the root mesh
  36711. */
  36712. createRootMesh(): Mesh;
  36713. /**
  36714. * Merge animations from this asset container into a scene
  36715. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36716. * @param animatables set of animatables to retarget to a node from the scene
  36717. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36718. */
  36719. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36720. }
  36721. }
  36722. declare module BABYLON {
  36723. /**
  36724. * Defines how the parser contract is defined.
  36725. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36726. */
  36727. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36728. /**
  36729. * Defines how the individual parser contract is defined.
  36730. * These parser can parse an individual asset
  36731. */
  36732. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36733. /**
  36734. * Base class of the scene acting as a container for the different elements composing a scene.
  36735. * This class is dynamically extended by the different components of the scene increasing
  36736. * flexibility and reducing coupling
  36737. */
  36738. export abstract class AbstractScene {
  36739. /**
  36740. * Stores the list of available parsers in the application.
  36741. */
  36742. private static _BabylonFileParsers;
  36743. /**
  36744. * Stores the list of available individual parsers in the application.
  36745. */
  36746. private static _IndividualBabylonFileParsers;
  36747. /**
  36748. * Adds a parser in the list of available ones
  36749. * @param name Defines the name of the parser
  36750. * @param parser Defines the parser to add
  36751. */
  36752. static AddParser(name: string, parser: BabylonFileParser): void;
  36753. /**
  36754. * Gets a general parser from the list of avaialble ones
  36755. * @param name Defines the name of the parser
  36756. * @returns the requested parser or null
  36757. */
  36758. static GetParser(name: string): Nullable<BabylonFileParser>;
  36759. /**
  36760. * Adds n individual parser in the list of available ones
  36761. * @param name Defines the name of the parser
  36762. * @param parser Defines the parser to add
  36763. */
  36764. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36765. /**
  36766. * Gets an individual parser from the list of avaialble ones
  36767. * @param name Defines the name of the parser
  36768. * @returns the requested parser or null
  36769. */
  36770. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36771. /**
  36772. * Parser json data and populate both a scene and its associated container object
  36773. * @param jsonData Defines the data to parse
  36774. * @param scene Defines the scene to parse the data for
  36775. * @param container Defines the container attached to the parsing sequence
  36776. * @param rootUrl Defines the root url of the data
  36777. */
  36778. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36779. /**
  36780. * Gets the list of root nodes (ie. nodes with no parent)
  36781. */
  36782. rootNodes: Node[];
  36783. /** All of the cameras added to this scene
  36784. * @see http://doc.babylonjs.com/babylon101/cameras
  36785. */
  36786. cameras: Camera[];
  36787. /**
  36788. * All of the lights added to this scene
  36789. * @see http://doc.babylonjs.com/babylon101/lights
  36790. */
  36791. lights: Light[];
  36792. /**
  36793. * All of the (abstract) meshes added to this scene
  36794. */
  36795. meshes: AbstractMesh[];
  36796. /**
  36797. * The list of skeletons added to the scene
  36798. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36799. */
  36800. skeletons: Skeleton[];
  36801. /**
  36802. * All of the particle systems added to this scene
  36803. * @see http://doc.babylonjs.com/babylon101/particles
  36804. */
  36805. particleSystems: IParticleSystem[];
  36806. /**
  36807. * Gets a list of Animations associated with the scene
  36808. */
  36809. animations: Animation[];
  36810. /**
  36811. * All of the animation groups added to this scene
  36812. * @see http://doc.babylonjs.com/how_to/group
  36813. */
  36814. animationGroups: AnimationGroup[];
  36815. /**
  36816. * All of the multi-materials added to this scene
  36817. * @see http://doc.babylonjs.com/how_to/multi_materials
  36818. */
  36819. multiMaterials: MultiMaterial[];
  36820. /**
  36821. * All of the materials added to this scene
  36822. * In the context of a Scene, it is not supposed to be modified manually.
  36823. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36824. * Note also that the order of the Material within the array is not significant and might change.
  36825. * @see http://doc.babylonjs.com/babylon101/materials
  36826. */
  36827. materials: Material[];
  36828. /**
  36829. * The list of morph target managers added to the scene
  36830. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36831. */
  36832. morphTargetManagers: MorphTargetManager[];
  36833. /**
  36834. * The list of geometries used in the scene.
  36835. */
  36836. geometries: Geometry[];
  36837. /**
  36838. * All of the tranform nodes added to this scene
  36839. * In the context of a Scene, it is not supposed to be modified manually.
  36840. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36841. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36842. * @see http://doc.babylonjs.com/how_to/transformnode
  36843. */
  36844. transformNodes: TransformNode[];
  36845. /**
  36846. * ActionManagers available on the scene.
  36847. */
  36848. actionManagers: AbstractActionManager[];
  36849. /**
  36850. * Textures to keep.
  36851. */
  36852. textures: BaseTexture[];
  36853. /**
  36854. * Environment texture for the scene
  36855. */
  36856. environmentTexture: Nullable<BaseTexture>;
  36857. /**
  36858. * @returns all meshes, lights, cameras, transformNodes and bones
  36859. */
  36860. getNodes(): Array<Node>;
  36861. }
  36862. }
  36863. declare module BABYLON {
  36864. /**
  36865. * Interface used to define options for Sound class
  36866. */
  36867. export interface ISoundOptions {
  36868. /**
  36869. * Does the sound autoplay once loaded.
  36870. */
  36871. autoplay?: boolean;
  36872. /**
  36873. * Does the sound loop after it finishes playing once.
  36874. */
  36875. loop?: boolean;
  36876. /**
  36877. * Sound's volume
  36878. */
  36879. volume?: number;
  36880. /**
  36881. * Is it a spatial sound?
  36882. */
  36883. spatialSound?: boolean;
  36884. /**
  36885. * Maximum distance to hear that sound
  36886. */
  36887. maxDistance?: number;
  36888. /**
  36889. * Uses user defined attenuation function
  36890. */
  36891. useCustomAttenuation?: boolean;
  36892. /**
  36893. * Define the roll off factor of spatial sounds.
  36894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36895. */
  36896. rolloffFactor?: number;
  36897. /**
  36898. * Define the reference distance the sound should be heard perfectly.
  36899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36900. */
  36901. refDistance?: number;
  36902. /**
  36903. * Define the distance attenuation model the sound will follow.
  36904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36905. */
  36906. distanceModel?: string;
  36907. /**
  36908. * Defines the playback speed (1 by default)
  36909. */
  36910. playbackRate?: number;
  36911. /**
  36912. * Defines if the sound is from a streaming source
  36913. */
  36914. streaming?: boolean;
  36915. /**
  36916. * Defines an optional length (in seconds) inside the sound file
  36917. */
  36918. length?: number;
  36919. /**
  36920. * Defines an optional offset (in seconds) inside the sound file
  36921. */
  36922. offset?: number;
  36923. /**
  36924. * If true, URLs will not be required to state the audio file codec to use.
  36925. */
  36926. skipCodecCheck?: boolean;
  36927. }
  36928. /**
  36929. * Defines a sound that can be played in the application.
  36930. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36932. */
  36933. export class Sound {
  36934. /**
  36935. * The name of the sound in the scene.
  36936. */
  36937. name: string;
  36938. /**
  36939. * Does the sound autoplay once loaded.
  36940. */
  36941. autoplay: boolean;
  36942. /**
  36943. * Does the sound loop after it finishes playing once.
  36944. */
  36945. loop: boolean;
  36946. /**
  36947. * Does the sound use a custom attenuation curve to simulate the falloff
  36948. * happening when the source gets further away from the camera.
  36949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36950. */
  36951. useCustomAttenuation: boolean;
  36952. /**
  36953. * The sound track id this sound belongs to.
  36954. */
  36955. soundTrackId: number;
  36956. /**
  36957. * Is this sound currently played.
  36958. */
  36959. isPlaying: boolean;
  36960. /**
  36961. * Is this sound currently paused.
  36962. */
  36963. isPaused: boolean;
  36964. /**
  36965. * Does this sound enables spatial sound.
  36966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36967. */
  36968. spatialSound: boolean;
  36969. /**
  36970. * Define the reference distance the sound should be heard perfectly.
  36971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36972. */
  36973. refDistance: number;
  36974. /**
  36975. * Define the roll off factor of spatial sounds.
  36976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36977. */
  36978. rolloffFactor: number;
  36979. /**
  36980. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36982. */
  36983. maxDistance: number;
  36984. /**
  36985. * Define the distance attenuation model the sound will follow.
  36986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36987. */
  36988. distanceModel: string;
  36989. /**
  36990. * @hidden
  36991. * Back Compat
  36992. **/
  36993. onended: () => any;
  36994. /**
  36995. * Observable event when the current playing sound finishes.
  36996. */
  36997. onEndedObservable: Observable<Sound>;
  36998. private _panningModel;
  36999. private _playbackRate;
  37000. private _streaming;
  37001. private _startTime;
  37002. private _startOffset;
  37003. private _position;
  37004. /** @hidden */
  37005. _positionInEmitterSpace: boolean;
  37006. private _localDirection;
  37007. private _volume;
  37008. private _isReadyToPlay;
  37009. private _isDirectional;
  37010. private _readyToPlayCallback;
  37011. private _audioBuffer;
  37012. private _soundSource;
  37013. private _streamingSource;
  37014. private _soundPanner;
  37015. private _soundGain;
  37016. private _inputAudioNode;
  37017. private _outputAudioNode;
  37018. private _coneInnerAngle;
  37019. private _coneOuterAngle;
  37020. private _coneOuterGain;
  37021. private _scene;
  37022. private _connectedTransformNode;
  37023. private _customAttenuationFunction;
  37024. private _registerFunc;
  37025. private _isOutputConnected;
  37026. private _htmlAudioElement;
  37027. private _urlType;
  37028. private _length?;
  37029. private _offset?;
  37030. /** @hidden */
  37031. static _SceneComponentInitialization: (scene: Scene) => void;
  37032. /**
  37033. * Create a sound and attach it to a scene
  37034. * @param name Name of your sound
  37035. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37036. * @param scene defines the scene the sound belongs to
  37037. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37038. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37039. */
  37040. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37041. /**
  37042. * Release the sound and its associated resources
  37043. */
  37044. dispose(): void;
  37045. /**
  37046. * Gets if the sounds is ready to be played or not.
  37047. * @returns true if ready, otherwise false
  37048. */
  37049. isReady(): boolean;
  37050. private _soundLoaded;
  37051. /**
  37052. * Sets the data of the sound from an audiobuffer
  37053. * @param audioBuffer The audioBuffer containing the data
  37054. */
  37055. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37056. /**
  37057. * Updates the current sounds options such as maxdistance, loop...
  37058. * @param options A JSON object containing values named as the object properties
  37059. */
  37060. updateOptions(options: ISoundOptions): void;
  37061. private _createSpatialParameters;
  37062. private _updateSpatialParameters;
  37063. /**
  37064. * Switch the panning model to HRTF:
  37065. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37067. */
  37068. switchPanningModelToHRTF(): void;
  37069. /**
  37070. * Switch the panning model to Equal Power:
  37071. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37073. */
  37074. switchPanningModelToEqualPower(): void;
  37075. private _switchPanningModel;
  37076. /**
  37077. * Connect this sound to a sound track audio node like gain...
  37078. * @param soundTrackAudioNode the sound track audio node to connect to
  37079. */
  37080. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37081. /**
  37082. * Transform this sound into a directional source
  37083. * @param coneInnerAngle Size of the inner cone in degree
  37084. * @param coneOuterAngle Size of the outer cone in degree
  37085. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37086. */
  37087. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37088. /**
  37089. * Gets or sets the inner angle for the directional cone.
  37090. */
  37091. get directionalConeInnerAngle(): number;
  37092. /**
  37093. * Gets or sets the inner angle for the directional cone.
  37094. */
  37095. set directionalConeInnerAngle(value: number);
  37096. /**
  37097. * Gets or sets the outer angle for the directional cone.
  37098. */
  37099. get directionalConeOuterAngle(): number;
  37100. /**
  37101. * Gets or sets the outer angle for the directional cone.
  37102. */
  37103. set directionalConeOuterAngle(value: number);
  37104. /**
  37105. * Sets the position of the emitter if spatial sound is enabled
  37106. * @param newPosition Defines the new posisiton
  37107. */
  37108. setPosition(newPosition: Vector3): void;
  37109. /**
  37110. * Sets the local direction of the emitter if spatial sound is enabled
  37111. * @param newLocalDirection Defines the new local direction
  37112. */
  37113. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37114. private _updateDirection;
  37115. /** @hidden */
  37116. updateDistanceFromListener(): void;
  37117. /**
  37118. * Sets a new custom attenuation function for the sound.
  37119. * @param callback Defines the function used for the attenuation
  37120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37121. */
  37122. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37123. /**
  37124. * Play the sound
  37125. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37126. * @param offset (optional) Start the sound at a specific time in seconds
  37127. * @param length (optional) Sound duration (in seconds)
  37128. */
  37129. play(time?: number, offset?: number, length?: number): void;
  37130. private _onended;
  37131. /**
  37132. * Stop the sound
  37133. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37134. */
  37135. stop(time?: number): void;
  37136. /**
  37137. * Put the sound in pause
  37138. */
  37139. pause(): void;
  37140. /**
  37141. * Sets a dedicated volume for this sounds
  37142. * @param newVolume Define the new volume of the sound
  37143. * @param time Define time for gradual change to new volume
  37144. */
  37145. setVolume(newVolume: number, time?: number): void;
  37146. /**
  37147. * Set the sound play back rate
  37148. * @param newPlaybackRate Define the playback rate the sound should be played at
  37149. */
  37150. setPlaybackRate(newPlaybackRate: number): void;
  37151. /**
  37152. * Gets the volume of the sound.
  37153. * @returns the volume of the sound
  37154. */
  37155. getVolume(): number;
  37156. /**
  37157. * Attach the sound to a dedicated mesh
  37158. * @param transformNode The transform node to connect the sound with
  37159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37160. */
  37161. attachToMesh(transformNode: TransformNode): void;
  37162. /**
  37163. * Detach the sound from the previously attached mesh
  37164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37165. */
  37166. detachFromMesh(): void;
  37167. private _onRegisterAfterWorldMatrixUpdate;
  37168. /**
  37169. * Clone the current sound in the scene.
  37170. * @returns the new sound clone
  37171. */
  37172. clone(): Nullable<Sound>;
  37173. /**
  37174. * Gets the current underlying audio buffer containing the data
  37175. * @returns the audio buffer
  37176. */
  37177. getAudioBuffer(): Nullable<AudioBuffer>;
  37178. /**
  37179. * Serializes the Sound in a JSON representation
  37180. * @returns the JSON representation of the sound
  37181. */
  37182. serialize(): any;
  37183. /**
  37184. * Parse a JSON representation of a sound to innstantiate in a given scene
  37185. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37186. * @param scene Define the scene the new parsed sound should be created in
  37187. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37188. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37189. * @returns the newly parsed sound
  37190. */
  37191. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37192. }
  37193. }
  37194. declare module BABYLON {
  37195. /**
  37196. * This defines an action helpful to play a defined sound on a triggered action.
  37197. */
  37198. export class PlaySoundAction extends Action {
  37199. private _sound;
  37200. /**
  37201. * Instantiate the action
  37202. * @param triggerOptions defines the trigger options
  37203. * @param sound defines the sound to play
  37204. * @param condition defines the trigger related conditions
  37205. */
  37206. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37207. /** @hidden */
  37208. _prepare(): void;
  37209. /**
  37210. * Execute the action and play the sound.
  37211. */
  37212. execute(): void;
  37213. /**
  37214. * Serializes the actions and its related information.
  37215. * @param parent defines the object to serialize in
  37216. * @returns the serialized object
  37217. */
  37218. serialize(parent: any): any;
  37219. }
  37220. /**
  37221. * This defines an action helpful to stop a defined sound on a triggered action.
  37222. */
  37223. export class StopSoundAction extends Action {
  37224. private _sound;
  37225. /**
  37226. * Instantiate the action
  37227. * @param triggerOptions defines the trigger options
  37228. * @param sound defines the sound to stop
  37229. * @param condition defines the trigger related conditions
  37230. */
  37231. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37232. /** @hidden */
  37233. _prepare(): void;
  37234. /**
  37235. * Execute the action and stop the sound.
  37236. */
  37237. execute(): void;
  37238. /**
  37239. * Serializes the actions and its related information.
  37240. * @param parent defines the object to serialize in
  37241. * @returns the serialized object
  37242. */
  37243. serialize(parent: any): any;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /**
  37248. * This defines an action responsible to change the value of a property
  37249. * by interpolating between its current value and the newly set one once triggered.
  37250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37251. */
  37252. export class InterpolateValueAction extends Action {
  37253. /**
  37254. * Defines the path of the property where the value should be interpolated
  37255. */
  37256. propertyPath: string;
  37257. /**
  37258. * Defines the target value at the end of the interpolation.
  37259. */
  37260. value: any;
  37261. /**
  37262. * Defines the time it will take for the property to interpolate to the value.
  37263. */
  37264. duration: number;
  37265. /**
  37266. * Defines if the other scene animations should be stopped when the action has been triggered
  37267. */
  37268. stopOtherAnimations?: boolean;
  37269. /**
  37270. * Defines a callback raised once the interpolation animation has been done.
  37271. */
  37272. onInterpolationDone?: () => void;
  37273. /**
  37274. * Observable triggered once the interpolation animation has been done.
  37275. */
  37276. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37277. private _target;
  37278. private _effectiveTarget;
  37279. private _property;
  37280. /**
  37281. * Instantiate the action
  37282. * @param triggerOptions defines the trigger options
  37283. * @param target defines the object containing the value to interpolate
  37284. * @param propertyPath defines the path to the property in the target object
  37285. * @param value defines the target value at the end of the interpolation
  37286. * @param duration deines the time it will take for the property to interpolate to the value.
  37287. * @param condition defines the trigger related conditions
  37288. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37289. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37290. */
  37291. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37292. /** @hidden */
  37293. _prepare(): void;
  37294. /**
  37295. * Execute the action starts the value interpolation.
  37296. */
  37297. execute(): void;
  37298. /**
  37299. * Serializes the actions and its related information.
  37300. * @param parent defines the object to serialize in
  37301. * @returns the serialized object
  37302. */
  37303. serialize(parent: any): any;
  37304. }
  37305. }
  37306. declare module BABYLON {
  37307. /**
  37308. * Options allowed during the creation of a sound track.
  37309. */
  37310. export interface ISoundTrackOptions {
  37311. /**
  37312. * The volume the sound track should take during creation
  37313. */
  37314. volume?: number;
  37315. /**
  37316. * Define if the sound track is the main sound track of the scene
  37317. */
  37318. mainTrack?: boolean;
  37319. }
  37320. /**
  37321. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37322. * It will be also used in a future release to apply effects on a specific track.
  37323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37324. */
  37325. export class SoundTrack {
  37326. /**
  37327. * The unique identifier of the sound track in the scene.
  37328. */
  37329. id: number;
  37330. /**
  37331. * The list of sounds included in the sound track.
  37332. */
  37333. soundCollection: Array<Sound>;
  37334. private _outputAudioNode;
  37335. private _scene;
  37336. private _connectedAnalyser;
  37337. private _options;
  37338. private _isInitialized;
  37339. /**
  37340. * Creates a new sound track.
  37341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37342. * @param scene Define the scene the sound track belongs to
  37343. * @param options
  37344. */
  37345. constructor(scene: Scene, options?: ISoundTrackOptions);
  37346. private _initializeSoundTrackAudioGraph;
  37347. /**
  37348. * Release the sound track and its associated resources
  37349. */
  37350. dispose(): void;
  37351. /**
  37352. * Adds a sound to this sound track
  37353. * @param sound define the cound to add
  37354. * @ignoreNaming
  37355. */
  37356. AddSound(sound: Sound): void;
  37357. /**
  37358. * Removes a sound to this sound track
  37359. * @param sound define the cound to remove
  37360. * @ignoreNaming
  37361. */
  37362. RemoveSound(sound: Sound): void;
  37363. /**
  37364. * Set a global volume for the full sound track.
  37365. * @param newVolume Define the new volume of the sound track
  37366. */
  37367. setVolume(newVolume: number): void;
  37368. /**
  37369. * Switch the panning model to HRTF:
  37370. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37372. */
  37373. switchPanningModelToHRTF(): void;
  37374. /**
  37375. * Switch the panning model to Equal Power:
  37376. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37378. */
  37379. switchPanningModelToEqualPower(): void;
  37380. /**
  37381. * Connect the sound track to an audio analyser allowing some amazing
  37382. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37384. * @param analyser The analyser to connect to the engine
  37385. */
  37386. connectToAnalyser(analyser: Analyser): void;
  37387. }
  37388. }
  37389. declare module BABYLON {
  37390. interface AbstractScene {
  37391. /**
  37392. * The list of sounds used in the scene.
  37393. */
  37394. sounds: Nullable<Array<Sound>>;
  37395. }
  37396. interface Scene {
  37397. /**
  37398. * @hidden
  37399. * Backing field
  37400. */
  37401. _mainSoundTrack: SoundTrack;
  37402. /**
  37403. * The main sound track played by the scene.
  37404. * It cotains your primary collection of sounds.
  37405. */
  37406. mainSoundTrack: SoundTrack;
  37407. /**
  37408. * The list of sound tracks added to the scene
  37409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37410. */
  37411. soundTracks: Nullable<Array<SoundTrack>>;
  37412. /**
  37413. * Gets a sound using a given name
  37414. * @param name defines the name to search for
  37415. * @return the found sound or null if not found at all.
  37416. */
  37417. getSoundByName(name: string): Nullable<Sound>;
  37418. /**
  37419. * Gets or sets if audio support is enabled
  37420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37421. */
  37422. audioEnabled: boolean;
  37423. /**
  37424. * Gets or sets if audio will be output to headphones
  37425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37426. */
  37427. headphone: boolean;
  37428. /**
  37429. * Gets or sets custom audio listener position provider
  37430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37431. */
  37432. audioListenerPositionProvider: Nullable<() => Vector3>;
  37433. /**
  37434. * Gets or sets a refresh rate when using 3D audio positioning
  37435. */
  37436. audioPositioningRefreshRate: number;
  37437. }
  37438. /**
  37439. * Defines the sound scene component responsible to manage any sounds
  37440. * in a given scene.
  37441. */
  37442. export class AudioSceneComponent implements ISceneSerializableComponent {
  37443. /**
  37444. * The component name helpfull to identify the component in the list of scene components.
  37445. */
  37446. readonly name: string;
  37447. /**
  37448. * The scene the component belongs to.
  37449. */
  37450. scene: Scene;
  37451. private _audioEnabled;
  37452. /**
  37453. * Gets whether audio is enabled or not.
  37454. * Please use related enable/disable method to switch state.
  37455. */
  37456. get audioEnabled(): boolean;
  37457. private _headphone;
  37458. /**
  37459. * Gets whether audio is outputing to headphone or not.
  37460. * Please use the according Switch methods to change output.
  37461. */
  37462. get headphone(): boolean;
  37463. /**
  37464. * Gets or sets a refresh rate when using 3D audio positioning
  37465. */
  37466. audioPositioningRefreshRate: number;
  37467. private _audioListenerPositionProvider;
  37468. /**
  37469. * Gets the current audio listener position provider
  37470. */
  37471. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37472. /**
  37473. * Sets a custom listener position for all sounds in the scene
  37474. * By default, this is the position of the first active camera
  37475. */
  37476. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37477. /**
  37478. * Creates a new instance of the component for the given scene
  37479. * @param scene Defines the scene to register the component in
  37480. */
  37481. constructor(scene: Scene);
  37482. /**
  37483. * Registers the component in a given scene
  37484. */
  37485. register(): void;
  37486. /**
  37487. * Rebuilds the elements related to this component in case of
  37488. * context lost for instance.
  37489. */
  37490. rebuild(): void;
  37491. /**
  37492. * Serializes the component data to the specified json object
  37493. * @param serializationObject The object to serialize to
  37494. */
  37495. serialize(serializationObject: any): void;
  37496. /**
  37497. * Adds all the elements from the container to the scene
  37498. * @param container the container holding the elements
  37499. */
  37500. addFromContainer(container: AbstractScene): void;
  37501. /**
  37502. * Removes all the elements in the container from the scene
  37503. * @param container contains the elements to remove
  37504. * @param dispose if the removed element should be disposed (default: false)
  37505. */
  37506. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37507. /**
  37508. * Disposes the component and the associated ressources.
  37509. */
  37510. dispose(): void;
  37511. /**
  37512. * Disables audio in the associated scene.
  37513. */
  37514. disableAudio(): void;
  37515. /**
  37516. * Enables audio in the associated scene.
  37517. */
  37518. enableAudio(): void;
  37519. /**
  37520. * Switch audio to headphone output.
  37521. */
  37522. switchAudioModeForHeadphones(): void;
  37523. /**
  37524. * Switch audio to normal speakers.
  37525. */
  37526. switchAudioModeForNormalSpeakers(): void;
  37527. private _cachedCameraDirection;
  37528. private _cachedCameraPosition;
  37529. private _lastCheck;
  37530. private _afterRender;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /**
  37535. * Wraps one or more Sound objects and selects one with random weight for playback.
  37536. */
  37537. export class WeightedSound {
  37538. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37539. loop: boolean;
  37540. private _coneInnerAngle;
  37541. private _coneOuterAngle;
  37542. private _volume;
  37543. /** A Sound is currently playing. */
  37544. isPlaying: boolean;
  37545. /** A Sound is currently paused. */
  37546. isPaused: boolean;
  37547. private _sounds;
  37548. private _weights;
  37549. private _currentIndex?;
  37550. /**
  37551. * Creates a new WeightedSound from the list of sounds given.
  37552. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37553. * @param sounds Array of Sounds that will be selected from.
  37554. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37555. */
  37556. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37557. /**
  37558. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37559. */
  37560. get directionalConeInnerAngle(): number;
  37561. /**
  37562. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37563. */
  37564. set directionalConeInnerAngle(value: number);
  37565. /**
  37566. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37567. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37568. */
  37569. get directionalConeOuterAngle(): number;
  37570. /**
  37571. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37572. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37573. */
  37574. set directionalConeOuterAngle(value: number);
  37575. /**
  37576. * Playback volume.
  37577. */
  37578. get volume(): number;
  37579. /**
  37580. * Playback volume.
  37581. */
  37582. set volume(value: number);
  37583. private _onended;
  37584. /**
  37585. * Suspend playback
  37586. */
  37587. pause(): void;
  37588. /**
  37589. * Stop playback
  37590. */
  37591. stop(): void;
  37592. /**
  37593. * Start playback.
  37594. * @param startOffset Position the clip head at a specific time in seconds.
  37595. */
  37596. play(startOffset?: number): void;
  37597. }
  37598. }
  37599. declare module BABYLON {
  37600. /**
  37601. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37603. */
  37604. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37605. /**
  37606. * Gets the name of the behavior.
  37607. */
  37608. get name(): string;
  37609. /**
  37610. * The easing function used by animations
  37611. */
  37612. static EasingFunction: BackEase;
  37613. /**
  37614. * The easing mode used by animations
  37615. */
  37616. static EasingMode: number;
  37617. /**
  37618. * The duration of the animation, in milliseconds
  37619. */
  37620. transitionDuration: number;
  37621. /**
  37622. * Length of the distance animated by the transition when lower radius is reached
  37623. */
  37624. lowerRadiusTransitionRange: number;
  37625. /**
  37626. * Length of the distance animated by the transition when upper radius is reached
  37627. */
  37628. upperRadiusTransitionRange: number;
  37629. private _autoTransitionRange;
  37630. /**
  37631. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37632. */
  37633. get autoTransitionRange(): boolean;
  37634. /**
  37635. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37636. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37637. */
  37638. set autoTransitionRange(value: boolean);
  37639. private _attachedCamera;
  37640. private _onAfterCheckInputsObserver;
  37641. private _onMeshTargetChangedObserver;
  37642. /**
  37643. * Initializes the behavior.
  37644. */
  37645. init(): void;
  37646. /**
  37647. * Attaches the behavior to its arc rotate camera.
  37648. * @param camera Defines the camera to attach the behavior to
  37649. */
  37650. attach(camera: ArcRotateCamera): void;
  37651. /**
  37652. * Detaches the behavior from its current arc rotate camera.
  37653. */
  37654. detach(): void;
  37655. private _radiusIsAnimating;
  37656. private _radiusBounceTransition;
  37657. private _animatables;
  37658. private _cachedWheelPrecision;
  37659. /**
  37660. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37661. * @param radiusLimit The limit to check against.
  37662. * @return Bool to indicate if at limit.
  37663. */
  37664. private _isRadiusAtLimit;
  37665. /**
  37666. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37667. * @param radiusDelta The delta by which to animate to. Can be negative.
  37668. */
  37669. private _applyBoundRadiusAnimation;
  37670. /**
  37671. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37672. */
  37673. protected _clearAnimationLocks(): void;
  37674. /**
  37675. * Stops and removes all animations that have been applied to the camera
  37676. */
  37677. stopAllAnimations(): void;
  37678. }
  37679. }
  37680. declare module BABYLON {
  37681. /**
  37682. * 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.
  37683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37684. */
  37685. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37686. /**
  37687. * Gets the name of the behavior.
  37688. */
  37689. get name(): string;
  37690. private _mode;
  37691. private _radiusScale;
  37692. private _positionScale;
  37693. private _defaultElevation;
  37694. private _elevationReturnTime;
  37695. private _elevationReturnWaitTime;
  37696. private _zoomStopsAnimation;
  37697. private _framingTime;
  37698. /**
  37699. * The easing function used by animations
  37700. */
  37701. static EasingFunction: ExponentialEase;
  37702. /**
  37703. * The easing mode used by animations
  37704. */
  37705. static EasingMode: number;
  37706. /**
  37707. * Sets the current mode used by the behavior
  37708. */
  37709. set mode(mode: number);
  37710. /**
  37711. * Gets current mode used by the behavior.
  37712. */
  37713. get mode(): number;
  37714. /**
  37715. * Sets the scale applied to the radius (1 by default)
  37716. */
  37717. set radiusScale(radius: number);
  37718. /**
  37719. * Gets the scale applied to the radius
  37720. */
  37721. get radiusScale(): number;
  37722. /**
  37723. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37724. */
  37725. set positionScale(scale: number);
  37726. /**
  37727. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37728. */
  37729. get positionScale(): number;
  37730. /**
  37731. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37732. * behaviour is triggered, in radians.
  37733. */
  37734. set defaultElevation(elevation: number);
  37735. /**
  37736. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37737. * behaviour is triggered, in radians.
  37738. */
  37739. get defaultElevation(): number;
  37740. /**
  37741. * Sets the time (in milliseconds) taken to return to the default beta position.
  37742. * Negative value indicates camera should not return to default.
  37743. */
  37744. set elevationReturnTime(speed: number);
  37745. /**
  37746. * Gets the time (in milliseconds) taken to return to the default beta position.
  37747. * Negative value indicates camera should not return to default.
  37748. */
  37749. get elevationReturnTime(): number;
  37750. /**
  37751. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37752. */
  37753. set elevationReturnWaitTime(time: number);
  37754. /**
  37755. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37756. */
  37757. get elevationReturnWaitTime(): number;
  37758. /**
  37759. * Sets the flag that indicates if user zooming should stop animation.
  37760. */
  37761. set zoomStopsAnimation(flag: boolean);
  37762. /**
  37763. * Gets the flag that indicates if user zooming should stop animation.
  37764. */
  37765. get zoomStopsAnimation(): boolean;
  37766. /**
  37767. * Sets the transition time when framing the mesh, in milliseconds
  37768. */
  37769. set framingTime(time: number);
  37770. /**
  37771. * Gets the transition time when framing the mesh, in milliseconds
  37772. */
  37773. get framingTime(): number;
  37774. /**
  37775. * Define if the behavior should automatically change the configured
  37776. * camera limits and sensibilities.
  37777. */
  37778. autoCorrectCameraLimitsAndSensibility: boolean;
  37779. private _onPrePointerObservableObserver;
  37780. private _onAfterCheckInputsObserver;
  37781. private _onMeshTargetChangedObserver;
  37782. private _attachedCamera;
  37783. private _isPointerDown;
  37784. private _lastInteractionTime;
  37785. /**
  37786. * Initializes the behavior.
  37787. */
  37788. init(): void;
  37789. /**
  37790. * Attaches the behavior to its arc rotate camera.
  37791. * @param camera Defines the camera to attach the behavior to
  37792. */
  37793. attach(camera: ArcRotateCamera): void;
  37794. /**
  37795. * Detaches the behavior from its current arc rotate camera.
  37796. */
  37797. detach(): void;
  37798. private _animatables;
  37799. private _betaIsAnimating;
  37800. private _betaTransition;
  37801. private _radiusTransition;
  37802. private _vectorTransition;
  37803. /**
  37804. * Targets the given mesh and updates zoom level accordingly.
  37805. * @param mesh The mesh to target.
  37806. * @param radius Optional. If a cached radius position already exists, overrides default.
  37807. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37810. */
  37811. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37812. /**
  37813. * Targets the given mesh with its children and updates zoom level accordingly.
  37814. * @param mesh The mesh to target.
  37815. * @param radius Optional. If a cached radius position already exists, overrides default.
  37816. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37817. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37818. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37819. */
  37820. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37821. /**
  37822. * Targets the given meshes with their children and updates zoom level accordingly.
  37823. * @param meshes The mesh to target.
  37824. * @param radius Optional. If a cached radius position already exists, overrides default.
  37825. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37826. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37827. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37828. */
  37829. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37830. /**
  37831. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37832. * @param minimumWorld Determines the smaller position of the bounding box extend
  37833. * @param maximumWorld Determines the bigger position of the bounding box extend
  37834. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37835. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37836. */
  37837. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37838. /**
  37839. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37840. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37841. * frustum width.
  37842. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37843. * to fully enclose the mesh in the viewing frustum.
  37844. */
  37845. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37846. /**
  37847. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37848. * is automatically returned to its default position (expected to be above ground plane).
  37849. */
  37850. private _maintainCameraAboveGround;
  37851. /**
  37852. * Returns the frustum slope based on the canvas ratio and camera FOV
  37853. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37854. */
  37855. private _getFrustumSlope;
  37856. /**
  37857. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37858. */
  37859. private _clearAnimationLocks;
  37860. /**
  37861. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37862. */
  37863. private _applyUserInteraction;
  37864. /**
  37865. * Stops and removes all animations that have been applied to the camera
  37866. */
  37867. stopAllAnimations(): void;
  37868. /**
  37869. * Gets a value indicating if the user is moving the camera
  37870. */
  37871. get isUserIsMoving(): boolean;
  37872. /**
  37873. * The camera can move all the way towards the mesh.
  37874. */
  37875. static IgnoreBoundsSizeMode: number;
  37876. /**
  37877. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37878. */
  37879. static FitFrustumSidesMode: number;
  37880. }
  37881. }
  37882. declare module BABYLON {
  37883. /**
  37884. * Base class for Camera Pointer Inputs.
  37885. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37886. * for example usage.
  37887. */
  37888. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37889. /**
  37890. * Defines the camera the input is attached to.
  37891. */
  37892. abstract camera: Camera;
  37893. /**
  37894. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37895. */
  37896. protected _altKey: boolean;
  37897. protected _ctrlKey: boolean;
  37898. protected _metaKey: boolean;
  37899. protected _shiftKey: boolean;
  37900. /**
  37901. * Which mouse buttons were pressed at time of last mouse event.
  37902. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37903. */
  37904. protected _buttonsPressed: number;
  37905. /**
  37906. * Defines the buttons associated with the input to handle camera move.
  37907. */
  37908. buttons: number[];
  37909. /**
  37910. * Attach the input controls to a specific dom element to get the input from.
  37911. * @param element Defines the element the controls should be listened from
  37912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37913. */
  37914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37915. /**
  37916. * Detach the current controls from the specified dom element.
  37917. * @param element Defines the element to stop listening the inputs from
  37918. */
  37919. detachControl(element: Nullable<HTMLElement>): void;
  37920. /**
  37921. * Gets the class name of the current input.
  37922. * @returns the class name
  37923. */
  37924. getClassName(): string;
  37925. /**
  37926. * Get the friendly name associated with the input class.
  37927. * @returns the input friendly name
  37928. */
  37929. getSimpleName(): string;
  37930. /**
  37931. * Called on pointer POINTERDOUBLETAP event.
  37932. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37933. */
  37934. protected onDoubleTap(type: string): void;
  37935. /**
  37936. * Called on pointer POINTERMOVE event if only a single touch is active.
  37937. * Override this method to provide functionality.
  37938. */
  37939. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37940. /**
  37941. * Called on pointer POINTERMOVE event if multiple touches are active.
  37942. * Override this method to provide functionality.
  37943. */
  37944. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37945. /**
  37946. * Called on JS contextmenu event.
  37947. * Override this method to provide functionality.
  37948. */
  37949. protected onContextMenu(evt: PointerEvent): void;
  37950. /**
  37951. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37952. * press.
  37953. * Override this method to provide functionality.
  37954. */
  37955. protected onButtonDown(evt: PointerEvent): void;
  37956. /**
  37957. * Called each time a new POINTERUP event occurs. Ie, for each button
  37958. * release.
  37959. * Override this method to provide functionality.
  37960. */
  37961. protected onButtonUp(evt: PointerEvent): void;
  37962. /**
  37963. * Called when window becomes inactive.
  37964. * Override this method to provide functionality.
  37965. */
  37966. protected onLostFocus(): void;
  37967. private _pointerInput;
  37968. private _observer;
  37969. private _onLostFocus;
  37970. private pointA;
  37971. private pointB;
  37972. }
  37973. }
  37974. declare module BABYLON {
  37975. /**
  37976. * Manage the pointers inputs to control an arc rotate camera.
  37977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37978. */
  37979. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37980. /**
  37981. * Defines the camera the input is attached to.
  37982. */
  37983. camera: ArcRotateCamera;
  37984. /**
  37985. * Gets the class name of the current input.
  37986. * @returns the class name
  37987. */
  37988. getClassName(): string;
  37989. /**
  37990. * Defines the buttons associated with the input to handle camera move.
  37991. */
  37992. buttons: number[];
  37993. /**
  37994. * Defines the pointer angular sensibility along the X axis or how fast is
  37995. * the camera rotating.
  37996. */
  37997. angularSensibilityX: number;
  37998. /**
  37999. * Defines the pointer angular sensibility along the Y axis or how fast is
  38000. * the camera rotating.
  38001. */
  38002. angularSensibilityY: number;
  38003. /**
  38004. * Defines the pointer pinch precision or how fast is the camera zooming.
  38005. */
  38006. pinchPrecision: number;
  38007. /**
  38008. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38009. * from 0.
  38010. * It defines the percentage of current camera.radius to use as delta when
  38011. * pinch zoom is used.
  38012. */
  38013. pinchDeltaPercentage: number;
  38014. /**
  38015. * Defines the pointer panning sensibility or how fast is the camera moving.
  38016. */
  38017. panningSensibility: number;
  38018. /**
  38019. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38020. */
  38021. multiTouchPanning: boolean;
  38022. /**
  38023. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38024. * zoom (pinch) through multitouch.
  38025. */
  38026. multiTouchPanAndZoom: boolean;
  38027. /**
  38028. * Revers pinch action direction.
  38029. */
  38030. pinchInwards: boolean;
  38031. private _isPanClick;
  38032. private _twoFingerActivityCount;
  38033. private _isPinching;
  38034. /**
  38035. * Called on pointer POINTERMOVE event if only a single touch is active.
  38036. */
  38037. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38038. /**
  38039. * Called on pointer POINTERDOUBLETAP event.
  38040. */
  38041. protected onDoubleTap(type: string): void;
  38042. /**
  38043. * Called on pointer POINTERMOVE event if multiple touches are active.
  38044. */
  38045. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38046. /**
  38047. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38048. * press.
  38049. */
  38050. protected onButtonDown(evt: PointerEvent): void;
  38051. /**
  38052. * Called each time a new POINTERUP event occurs. Ie, for each button
  38053. * release.
  38054. */
  38055. protected onButtonUp(evt: PointerEvent): void;
  38056. /**
  38057. * Called when window becomes inactive.
  38058. */
  38059. protected onLostFocus(): void;
  38060. }
  38061. }
  38062. declare module BABYLON {
  38063. /**
  38064. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38066. */
  38067. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38068. /**
  38069. * Defines the camera the input is attached to.
  38070. */
  38071. camera: ArcRotateCamera;
  38072. /**
  38073. * Defines the list of key codes associated with the up action (increase alpha)
  38074. */
  38075. keysUp: number[];
  38076. /**
  38077. * Defines the list of key codes associated with the down action (decrease alpha)
  38078. */
  38079. keysDown: number[];
  38080. /**
  38081. * Defines the list of key codes associated with the left action (increase beta)
  38082. */
  38083. keysLeft: number[];
  38084. /**
  38085. * Defines the list of key codes associated with the right action (decrease beta)
  38086. */
  38087. keysRight: number[];
  38088. /**
  38089. * Defines the list of key codes associated with the reset action.
  38090. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38091. */
  38092. keysReset: number[];
  38093. /**
  38094. * Defines the panning sensibility of the inputs.
  38095. * (How fast is the camera paning)
  38096. */
  38097. panningSensibility: number;
  38098. /**
  38099. * Defines the zooming sensibility of the inputs.
  38100. * (How fast is the camera zooming)
  38101. */
  38102. zoomingSensibility: number;
  38103. /**
  38104. * Defines wether maintaining the alt key down switch the movement mode from
  38105. * orientation to zoom.
  38106. */
  38107. useAltToZoom: boolean;
  38108. /**
  38109. * Rotation speed of the camera
  38110. */
  38111. angularSpeed: number;
  38112. private _keys;
  38113. private _ctrlPressed;
  38114. private _altPressed;
  38115. private _onCanvasBlurObserver;
  38116. private _onKeyboardObserver;
  38117. private _engine;
  38118. private _scene;
  38119. /**
  38120. * Attach the input controls to a specific dom element to get the input from.
  38121. * @param element Defines the element the controls should be listened from
  38122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38123. */
  38124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38125. /**
  38126. * Detach the current controls from the specified dom element.
  38127. * @param element Defines the element to stop listening the inputs from
  38128. */
  38129. detachControl(element: Nullable<HTMLElement>): void;
  38130. /**
  38131. * Update the current camera state depending on the inputs that have been used this frame.
  38132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38133. */
  38134. checkInputs(): void;
  38135. /**
  38136. * Gets the class name of the current intput.
  38137. * @returns the class name
  38138. */
  38139. getClassName(): string;
  38140. /**
  38141. * Get the friendly name associated with the input class.
  38142. * @returns the input friendly name
  38143. */
  38144. getSimpleName(): string;
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. /**
  38149. * Manage the mouse wheel inputs to control an arc rotate camera.
  38150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38151. */
  38152. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38153. /**
  38154. * Defines the camera the input is attached to.
  38155. */
  38156. camera: ArcRotateCamera;
  38157. /**
  38158. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38159. */
  38160. wheelPrecision: number;
  38161. /**
  38162. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38163. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38164. */
  38165. wheelDeltaPercentage: number;
  38166. private _wheel;
  38167. private _observer;
  38168. private computeDeltaFromMouseWheelLegacyEvent;
  38169. /**
  38170. * Attach the input controls to a specific dom element to get the input from.
  38171. * @param element Defines the element the controls should be listened from
  38172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38173. */
  38174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38175. /**
  38176. * Detach the current controls from the specified dom element.
  38177. * @param element Defines the element to stop listening the inputs from
  38178. */
  38179. detachControl(element: Nullable<HTMLElement>): void;
  38180. /**
  38181. * Gets the class name of the current intput.
  38182. * @returns the class name
  38183. */
  38184. getClassName(): string;
  38185. /**
  38186. * Get the friendly name associated with the input class.
  38187. * @returns the input friendly name
  38188. */
  38189. getSimpleName(): string;
  38190. }
  38191. }
  38192. declare module BABYLON {
  38193. /**
  38194. * Default Inputs manager for the ArcRotateCamera.
  38195. * It groups all the default supported inputs for ease of use.
  38196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38197. */
  38198. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38199. /**
  38200. * Instantiates a new ArcRotateCameraInputsManager.
  38201. * @param camera Defines the camera the inputs belong to
  38202. */
  38203. constructor(camera: ArcRotateCamera);
  38204. /**
  38205. * Add mouse wheel input support to the input manager.
  38206. * @returns the current input manager
  38207. */
  38208. addMouseWheel(): ArcRotateCameraInputsManager;
  38209. /**
  38210. * Add pointers input support to the input manager.
  38211. * @returns the current input manager
  38212. */
  38213. addPointers(): ArcRotateCameraInputsManager;
  38214. /**
  38215. * Add keyboard input support to the input manager.
  38216. * @returns the current input manager
  38217. */
  38218. addKeyboard(): ArcRotateCameraInputsManager;
  38219. }
  38220. }
  38221. declare module BABYLON {
  38222. /**
  38223. * This represents an orbital type of camera.
  38224. *
  38225. * 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.
  38226. * 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.
  38227. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38228. */
  38229. export class ArcRotateCamera extends TargetCamera {
  38230. /**
  38231. * Defines the rotation angle of the camera along the longitudinal axis.
  38232. */
  38233. alpha: number;
  38234. /**
  38235. * Defines the rotation angle of the camera along the latitudinal axis.
  38236. */
  38237. beta: number;
  38238. /**
  38239. * Defines the radius of the camera from it s target point.
  38240. */
  38241. radius: number;
  38242. protected _target: Vector3;
  38243. protected _targetHost: Nullable<AbstractMesh>;
  38244. /**
  38245. * Defines the target point of the camera.
  38246. * The camera looks towards it form the radius distance.
  38247. */
  38248. get target(): Vector3;
  38249. set target(value: Vector3);
  38250. /**
  38251. * Define the current local position of the camera in the scene
  38252. */
  38253. get position(): Vector3;
  38254. set position(newPosition: Vector3);
  38255. protected _upVector: Vector3;
  38256. protected _upToYMatrix: Matrix;
  38257. protected _YToUpMatrix: Matrix;
  38258. /**
  38259. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38260. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38261. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38262. */
  38263. set upVector(vec: Vector3);
  38264. get upVector(): Vector3;
  38265. /**
  38266. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38267. */
  38268. setMatUp(): void;
  38269. /**
  38270. * Current inertia value on the longitudinal axis.
  38271. * The bigger this number the longer it will take for the camera to stop.
  38272. */
  38273. inertialAlphaOffset: number;
  38274. /**
  38275. * Current inertia value on the latitudinal axis.
  38276. * The bigger this number the longer it will take for the camera to stop.
  38277. */
  38278. inertialBetaOffset: number;
  38279. /**
  38280. * Current inertia value on the radius axis.
  38281. * The bigger this number the longer it will take for the camera to stop.
  38282. */
  38283. inertialRadiusOffset: number;
  38284. /**
  38285. * Minimum allowed angle on the longitudinal axis.
  38286. * This can help limiting how the Camera is able to move in the scene.
  38287. */
  38288. lowerAlphaLimit: Nullable<number>;
  38289. /**
  38290. * Maximum allowed angle on the longitudinal axis.
  38291. * This can help limiting how the Camera is able to move in the scene.
  38292. */
  38293. upperAlphaLimit: Nullable<number>;
  38294. /**
  38295. * Minimum allowed angle on the latitudinal axis.
  38296. * This can help limiting how the Camera is able to move in the scene.
  38297. */
  38298. lowerBetaLimit: number;
  38299. /**
  38300. * Maximum allowed angle on the latitudinal axis.
  38301. * This can help limiting how the Camera is able to move in the scene.
  38302. */
  38303. upperBetaLimit: number;
  38304. /**
  38305. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38306. * This can help limiting how the Camera is able to move in the scene.
  38307. */
  38308. lowerRadiusLimit: Nullable<number>;
  38309. /**
  38310. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38311. * This can help limiting how the Camera is able to move in the scene.
  38312. */
  38313. upperRadiusLimit: Nullable<number>;
  38314. /**
  38315. * Defines the current inertia value used during panning of the camera along the X axis.
  38316. */
  38317. inertialPanningX: number;
  38318. /**
  38319. * Defines the current inertia value used during panning of the camera along the Y axis.
  38320. */
  38321. inertialPanningY: number;
  38322. /**
  38323. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38324. * Basically if your fingers moves away from more than this distance you will be considered
  38325. * in pinch mode.
  38326. */
  38327. pinchToPanMaxDistance: number;
  38328. /**
  38329. * Defines the maximum distance the camera can pan.
  38330. * This could help keeping the cammera always in your scene.
  38331. */
  38332. panningDistanceLimit: Nullable<number>;
  38333. /**
  38334. * Defines the target of the camera before paning.
  38335. */
  38336. panningOriginTarget: Vector3;
  38337. /**
  38338. * Defines the value of the inertia used during panning.
  38339. * 0 would mean stop inertia and one would mean no decelleration at all.
  38340. */
  38341. panningInertia: number;
  38342. /**
  38343. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38344. */
  38345. get angularSensibilityX(): number;
  38346. set angularSensibilityX(value: number);
  38347. /**
  38348. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38349. */
  38350. get angularSensibilityY(): number;
  38351. set angularSensibilityY(value: number);
  38352. /**
  38353. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38354. */
  38355. get pinchPrecision(): number;
  38356. set pinchPrecision(value: number);
  38357. /**
  38358. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38359. * It will be used instead of pinchDeltaPrecision if different from 0.
  38360. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38361. */
  38362. get pinchDeltaPercentage(): number;
  38363. set pinchDeltaPercentage(value: number);
  38364. /**
  38365. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38366. */
  38367. get panningSensibility(): number;
  38368. set panningSensibility(value: number);
  38369. /**
  38370. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38371. */
  38372. get keysUp(): number[];
  38373. set keysUp(value: number[]);
  38374. /**
  38375. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38376. */
  38377. get keysDown(): number[];
  38378. set keysDown(value: number[]);
  38379. /**
  38380. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38381. */
  38382. get keysLeft(): number[];
  38383. set keysLeft(value: number[]);
  38384. /**
  38385. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38386. */
  38387. get keysRight(): number[];
  38388. set keysRight(value: number[]);
  38389. /**
  38390. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38391. */
  38392. get wheelPrecision(): number;
  38393. set wheelPrecision(value: number);
  38394. /**
  38395. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38396. * It will be used instead of pinchDeltaPrecision if different from 0.
  38397. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38398. */
  38399. get wheelDeltaPercentage(): number;
  38400. set wheelDeltaPercentage(value: number);
  38401. /**
  38402. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38403. */
  38404. zoomOnFactor: number;
  38405. /**
  38406. * Defines a screen offset for the camera position.
  38407. */
  38408. targetScreenOffset: Vector2;
  38409. /**
  38410. * Allows the camera to be completely reversed.
  38411. * If false the camera can not arrive upside down.
  38412. */
  38413. allowUpsideDown: boolean;
  38414. /**
  38415. * Define if double tap/click is used to restore the previously saved state of the camera.
  38416. */
  38417. useInputToRestoreState: boolean;
  38418. /** @hidden */
  38419. _viewMatrix: Matrix;
  38420. /** @hidden */
  38421. _useCtrlForPanning: boolean;
  38422. /** @hidden */
  38423. _panningMouseButton: number;
  38424. /**
  38425. * Defines the input associated to the camera.
  38426. */
  38427. inputs: ArcRotateCameraInputsManager;
  38428. /** @hidden */
  38429. _reset: () => void;
  38430. /**
  38431. * Defines the allowed panning axis.
  38432. */
  38433. panningAxis: Vector3;
  38434. protected _localDirection: Vector3;
  38435. protected _transformedDirection: Vector3;
  38436. private _bouncingBehavior;
  38437. /**
  38438. * Gets the bouncing behavior of the camera if it has been enabled.
  38439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38440. */
  38441. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38442. /**
  38443. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38444. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38445. */
  38446. get useBouncingBehavior(): boolean;
  38447. set useBouncingBehavior(value: boolean);
  38448. private _framingBehavior;
  38449. /**
  38450. * Gets the framing behavior of the camera if it has been enabled.
  38451. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38452. */
  38453. get framingBehavior(): Nullable<FramingBehavior>;
  38454. /**
  38455. * Defines if the framing behavior of the camera is enabled on the camera.
  38456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38457. */
  38458. get useFramingBehavior(): boolean;
  38459. set useFramingBehavior(value: boolean);
  38460. private _autoRotationBehavior;
  38461. /**
  38462. * Gets the auto rotation behavior of the camera if it has been enabled.
  38463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38464. */
  38465. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38466. /**
  38467. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38469. */
  38470. get useAutoRotationBehavior(): boolean;
  38471. set useAutoRotationBehavior(value: boolean);
  38472. /**
  38473. * Observable triggered when the mesh target has been changed on the camera.
  38474. */
  38475. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38476. /**
  38477. * Event raised when the camera is colliding with a mesh.
  38478. */
  38479. onCollide: (collidedMesh: AbstractMesh) => void;
  38480. /**
  38481. * Defines whether the camera should check collision with the objects oh the scene.
  38482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38483. */
  38484. checkCollisions: boolean;
  38485. /**
  38486. * Defines the collision radius of the camera.
  38487. * This simulates a sphere around the camera.
  38488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38489. */
  38490. collisionRadius: Vector3;
  38491. protected _collider: Collider;
  38492. protected _previousPosition: Vector3;
  38493. protected _collisionVelocity: Vector3;
  38494. protected _newPosition: Vector3;
  38495. protected _previousAlpha: number;
  38496. protected _previousBeta: number;
  38497. protected _previousRadius: number;
  38498. protected _collisionTriggered: boolean;
  38499. protected _targetBoundingCenter: Nullable<Vector3>;
  38500. private _computationVector;
  38501. /**
  38502. * Instantiates a new ArcRotateCamera in a given scene
  38503. * @param name Defines the name of the camera
  38504. * @param alpha Defines the camera rotation along the logitudinal axis
  38505. * @param beta Defines the camera rotation along the latitudinal axis
  38506. * @param radius Defines the camera distance from its target
  38507. * @param target Defines the camera target
  38508. * @param scene Defines the scene the camera belongs to
  38509. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38510. */
  38511. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38512. /** @hidden */
  38513. _initCache(): void;
  38514. /** @hidden */
  38515. _updateCache(ignoreParentClass?: boolean): void;
  38516. protected _getTargetPosition(): Vector3;
  38517. private _storedAlpha;
  38518. private _storedBeta;
  38519. private _storedRadius;
  38520. private _storedTarget;
  38521. private _storedTargetScreenOffset;
  38522. /**
  38523. * Stores the current state of the camera (alpha, beta, radius and target)
  38524. * @returns the camera itself
  38525. */
  38526. storeState(): Camera;
  38527. /**
  38528. * @hidden
  38529. * Restored camera state. You must call storeState() first
  38530. */
  38531. _restoreStateValues(): boolean;
  38532. /** @hidden */
  38533. _isSynchronizedViewMatrix(): boolean;
  38534. /**
  38535. * Attached controls to the current camera.
  38536. * @param element Defines the element the controls should be listened from
  38537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38538. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38539. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38540. */
  38541. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38542. /**
  38543. * Detach the current controls from the camera.
  38544. * The camera will stop reacting to inputs.
  38545. * @param element Defines the element to stop listening the inputs from
  38546. */
  38547. detachControl(element: HTMLElement): void;
  38548. /** @hidden */
  38549. _checkInputs(): void;
  38550. protected _checkLimits(): void;
  38551. /**
  38552. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38553. */
  38554. rebuildAnglesAndRadius(): void;
  38555. /**
  38556. * Use a position to define the current camera related information like alpha, beta and radius
  38557. * @param position Defines the position to set the camera at
  38558. */
  38559. setPosition(position: Vector3): void;
  38560. /**
  38561. * Defines the target the camera should look at.
  38562. * This will automatically adapt alpha beta and radius to fit within the new target.
  38563. * @param target Defines the new target as a Vector or a mesh
  38564. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38565. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38566. */
  38567. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38568. /** @hidden */
  38569. _getViewMatrix(): Matrix;
  38570. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38571. /**
  38572. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38573. * @param meshes Defines the mesh to zoom on
  38574. * @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)
  38575. */
  38576. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38577. /**
  38578. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38579. * The target will be changed but the radius
  38580. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38581. * @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)
  38582. */
  38583. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38584. min: Vector3;
  38585. max: Vector3;
  38586. distance: number;
  38587. }, doNotUpdateMaxZ?: boolean): void;
  38588. /**
  38589. * @override
  38590. * Override Camera.createRigCamera
  38591. */
  38592. createRigCamera(name: string, cameraIndex: number): Camera;
  38593. /**
  38594. * @hidden
  38595. * @override
  38596. * Override Camera._updateRigCameras
  38597. */
  38598. _updateRigCameras(): void;
  38599. /**
  38600. * Destroy the camera and release the current resources hold by it.
  38601. */
  38602. dispose(): void;
  38603. /**
  38604. * Gets the current object class name.
  38605. * @return the class name
  38606. */
  38607. getClassName(): string;
  38608. }
  38609. }
  38610. declare module BABYLON {
  38611. /**
  38612. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38613. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38614. */
  38615. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38616. /**
  38617. * Gets the name of the behavior.
  38618. */
  38619. get name(): string;
  38620. private _zoomStopsAnimation;
  38621. private _idleRotationSpeed;
  38622. private _idleRotationWaitTime;
  38623. private _idleRotationSpinupTime;
  38624. /**
  38625. * Sets the flag that indicates if user zooming should stop animation.
  38626. */
  38627. set zoomStopsAnimation(flag: boolean);
  38628. /**
  38629. * Gets the flag that indicates if user zooming should stop animation.
  38630. */
  38631. get zoomStopsAnimation(): boolean;
  38632. /**
  38633. * Sets the default speed at which the camera rotates around the model.
  38634. */
  38635. set idleRotationSpeed(speed: number);
  38636. /**
  38637. * Gets the default speed at which the camera rotates around the model.
  38638. */
  38639. get idleRotationSpeed(): number;
  38640. /**
  38641. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38642. */
  38643. set idleRotationWaitTime(time: number);
  38644. /**
  38645. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38646. */
  38647. get idleRotationWaitTime(): number;
  38648. /**
  38649. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38650. */
  38651. set idleRotationSpinupTime(time: number);
  38652. /**
  38653. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38654. */
  38655. get idleRotationSpinupTime(): number;
  38656. /**
  38657. * Gets a value indicating if the camera is currently rotating because of this behavior
  38658. */
  38659. get rotationInProgress(): boolean;
  38660. private _onPrePointerObservableObserver;
  38661. private _onAfterCheckInputsObserver;
  38662. private _attachedCamera;
  38663. private _isPointerDown;
  38664. private _lastFrameTime;
  38665. private _lastInteractionTime;
  38666. private _cameraRotationSpeed;
  38667. /**
  38668. * Initializes the behavior.
  38669. */
  38670. init(): void;
  38671. /**
  38672. * Attaches the behavior to its arc rotate camera.
  38673. * @param camera Defines the camera to attach the behavior to
  38674. */
  38675. attach(camera: ArcRotateCamera): void;
  38676. /**
  38677. * Detaches the behavior from its current arc rotate camera.
  38678. */
  38679. detach(): void;
  38680. /**
  38681. * Returns true if user is scrolling.
  38682. * @return true if user is scrolling.
  38683. */
  38684. private _userIsZooming;
  38685. private _lastFrameRadius;
  38686. private _shouldAnimationStopForInteraction;
  38687. /**
  38688. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38689. */
  38690. private _applyUserInteraction;
  38691. private _userIsMoving;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38697. */
  38698. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38699. private ui;
  38700. /**
  38701. * The name of the behavior
  38702. */
  38703. name: string;
  38704. /**
  38705. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38706. */
  38707. distanceAwayFromFace: number;
  38708. /**
  38709. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38710. */
  38711. distanceAwayFromBottomOfFace: number;
  38712. private _faceVectors;
  38713. private _target;
  38714. private _scene;
  38715. private _onRenderObserver;
  38716. private _tmpMatrix;
  38717. private _tmpVector;
  38718. /**
  38719. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38720. * @param ui The transform node that should be attched to the mesh
  38721. */
  38722. constructor(ui: TransformNode);
  38723. /**
  38724. * Initializes the behavior
  38725. */
  38726. init(): void;
  38727. private _closestFace;
  38728. private _zeroVector;
  38729. private _lookAtTmpMatrix;
  38730. private _lookAtToRef;
  38731. /**
  38732. * Attaches the AttachToBoxBehavior to the passed in mesh
  38733. * @param target The mesh that the specified node will be attached to
  38734. */
  38735. attach(target: Mesh): void;
  38736. /**
  38737. * Detaches the behavior from the mesh
  38738. */
  38739. detach(): void;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /**
  38744. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38745. */
  38746. export class FadeInOutBehavior implements Behavior<Mesh> {
  38747. /**
  38748. * Time in milliseconds to delay before fading in (Default: 0)
  38749. */
  38750. delay: number;
  38751. /**
  38752. * Time in milliseconds for the mesh to fade in (Default: 300)
  38753. */
  38754. fadeInTime: number;
  38755. private _millisecondsPerFrame;
  38756. private _hovered;
  38757. private _hoverValue;
  38758. private _ownerNode;
  38759. /**
  38760. * Instatiates the FadeInOutBehavior
  38761. */
  38762. constructor();
  38763. /**
  38764. * The name of the behavior
  38765. */
  38766. get name(): string;
  38767. /**
  38768. * Initializes the behavior
  38769. */
  38770. init(): void;
  38771. /**
  38772. * Attaches the fade behavior on the passed in mesh
  38773. * @param ownerNode The mesh that will be faded in/out once attached
  38774. */
  38775. attach(ownerNode: Mesh): void;
  38776. /**
  38777. * Detaches the behavior from the mesh
  38778. */
  38779. detach(): void;
  38780. /**
  38781. * Triggers the mesh to begin fading in or out
  38782. * @param value if the object should fade in or out (true to fade in)
  38783. */
  38784. fadeIn(value: boolean): void;
  38785. private _update;
  38786. private _setAllVisibility;
  38787. }
  38788. }
  38789. declare module BABYLON {
  38790. /**
  38791. * Class containing a set of static utilities functions for managing Pivots
  38792. * @hidden
  38793. */
  38794. export class PivotTools {
  38795. private static _PivotCached;
  38796. private static _OldPivotPoint;
  38797. private static _PivotTranslation;
  38798. private static _PivotTmpVector;
  38799. /** @hidden */
  38800. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38801. /** @hidden */
  38802. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38803. }
  38804. }
  38805. declare module BABYLON {
  38806. /**
  38807. * Class containing static functions to help procedurally build meshes
  38808. */
  38809. export class PlaneBuilder {
  38810. /**
  38811. * Creates a plane mesh
  38812. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38813. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38814. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38816. * * 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
  38817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38818. * @param name defines the name of the mesh
  38819. * @param options defines the options used to create the mesh
  38820. * @param scene defines the hosting scene
  38821. * @returns the plane mesh
  38822. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38823. */
  38824. static CreatePlane(name: string, options: {
  38825. size?: number;
  38826. width?: number;
  38827. height?: number;
  38828. sideOrientation?: number;
  38829. frontUVs?: Vector4;
  38830. backUVs?: Vector4;
  38831. updatable?: boolean;
  38832. sourcePlane?: Plane;
  38833. }, scene?: Nullable<Scene>): Mesh;
  38834. }
  38835. }
  38836. declare module BABYLON {
  38837. /**
  38838. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38839. */
  38840. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38841. private static _AnyMouseID;
  38842. /**
  38843. * Abstract mesh the behavior is set on
  38844. */
  38845. attachedNode: AbstractMesh;
  38846. private _dragPlane;
  38847. private _scene;
  38848. private _pointerObserver;
  38849. private _beforeRenderObserver;
  38850. private static _planeScene;
  38851. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38852. /**
  38853. * 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)
  38854. */
  38855. maxDragAngle: number;
  38856. /**
  38857. * @hidden
  38858. */
  38859. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38860. /**
  38861. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38862. */
  38863. currentDraggingPointerID: number;
  38864. /**
  38865. * The last position where the pointer hit the drag plane in world space
  38866. */
  38867. lastDragPosition: Vector3;
  38868. /**
  38869. * If the behavior is currently in a dragging state
  38870. */
  38871. dragging: boolean;
  38872. /**
  38873. * 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)
  38874. */
  38875. dragDeltaRatio: number;
  38876. /**
  38877. * If the drag plane orientation should be updated during the dragging (Default: true)
  38878. */
  38879. updateDragPlane: boolean;
  38880. private _debugMode;
  38881. private _moving;
  38882. /**
  38883. * Fires each time the attached mesh is dragged with the pointer
  38884. * * delta between last drag position and current drag position in world space
  38885. * * dragDistance along the drag axis
  38886. * * dragPlaneNormal normal of the current drag plane used during the drag
  38887. * * dragPlanePoint in world space where the drag intersects the drag plane
  38888. */
  38889. onDragObservable: Observable<{
  38890. delta: Vector3;
  38891. dragPlanePoint: Vector3;
  38892. dragPlaneNormal: Vector3;
  38893. dragDistance: number;
  38894. pointerId: number;
  38895. }>;
  38896. /**
  38897. * Fires each time a drag begins (eg. mouse down on mesh)
  38898. */
  38899. onDragStartObservable: Observable<{
  38900. dragPlanePoint: Vector3;
  38901. pointerId: number;
  38902. }>;
  38903. /**
  38904. * Fires each time a drag ends (eg. mouse release after drag)
  38905. */
  38906. onDragEndObservable: Observable<{
  38907. dragPlanePoint: Vector3;
  38908. pointerId: number;
  38909. }>;
  38910. /**
  38911. * If the attached mesh should be moved when dragged
  38912. */
  38913. moveAttached: boolean;
  38914. /**
  38915. * If the drag behavior will react to drag events (Default: true)
  38916. */
  38917. enabled: boolean;
  38918. /**
  38919. * If pointer events should start and release the drag (Default: true)
  38920. */
  38921. startAndReleaseDragOnPointerEvents: boolean;
  38922. /**
  38923. * If camera controls should be detached during the drag
  38924. */
  38925. detachCameraControls: boolean;
  38926. /**
  38927. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38928. */
  38929. useObjectOrienationForDragging: boolean;
  38930. private _options;
  38931. /**
  38932. * Gets the options used by the behavior
  38933. */
  38934. get options(): {
  38935. dragAxis?: Vector3;
  38936. dragPlaneNormal?: Vector3;
  38937. };
  38938. /**
  38939. * Sets the options used by the behavior
  38940. */
  38941. set options(options: {
  38942. dragAxis?: Vector3;
  38943. dragPlaneNormal?: Vector3;
  38944. });
  38945. /**
  38946. * Creates a pointer drag behavior that can be attached to a mesh
  38947. * @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)
  38948. */
  38949. constructor(options?: {
  38950. dragAxis?: Vector3;
  38951. dragPlaneNormal?: Vector3;
  38952. });
  38953. /**
  38954. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38955. */
  38956. validateDrag: (targetPosition: Vector3) => boolean;
  38957. /**
  38958. * The name of the behavior
  38959. */
  38960. get name(): string;
  38961. /**
  38962. * Initializes the behavior
  38963. */
  38964. init(): void;
  38965. private _tmpVector;
  38966. private _alternatePickedPoint;
  38967. private _worldDragAxis;
  38968. private _targetPosition;
  38969. private _attachedElement;
  38970. /**
  38971. * Attaches the drag behavior the passed in mesh
  38972. * @param ownerNode The mesh that will be dragged around once attached
  38973. * @param predicate Predicate to use for pick filtering
  38974. */
  38975. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38976. /**
  38977. * Force relase the drag action by code.
  38978. */
  38979. releaseDrag(): void;
  38980. private _startDragRay;
  38981. private _lastPointerRay;
  38982. /**
  38983. * Simulates the start of a pointer drag event on the behavior
  38984. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38985. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38986. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38987. */
  38988. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38989. private _startDrag;
  38990. private _dragDelta;
  38991. private _moveDrag;
  38992. private _pickWithRayOnDragPlane;
  38993. private _pointA;
  38994. private _pointB;
  38995. private _pointC;
  38996. private _lineA;
  38997. private _lineB;
  38998. private _localAxis;
  38999. private _lookAt;
  39000. private _updateDragPlanePosition;
  39001. /**
  39002. * Detaches the behavior from the mesh
  39003. */
  39004. detach(): void;
  39005. }
  39006. }
  39007. declare module BABYLON {
  39008. /**
  39009. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39010. */
  39011. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39012. private _dragBehaviorA;
  39013. private _dragBehaviorB;
  39014. private _startDistance;
  39015. private _initialScale;
  39016. private _targetScale;
  39017. private _ownerNode;
  39018. private _sceneRenderObserver;
  39019. /**
  39020. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39021. */
  39022. constructor();
  39023. /**
  39024. * The name of the behavior
  39025. */
  39026. get name(): string;
  39027. /**
  39028. * Initializes the behavior
  39029. */
  39030. init(): void;
  39031. private _getCurrentDistance;
  39032. /**
  39033. * Attaches the scale behavior the passed in mesh
  39034. * @param ownerNode The mesh that will be scaled around once attached
  39035. */
  39036. attach(ownerNode: Mesh): void;
  39037. /**
  39038. * Detaches the behavior from the mesh
  39039. */
  39040. detach(): void;
  39041. }
  39042. }
  39043. declare module BABYLON {
  39044. /**
  39045. * 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
  39046. */
  39047. export class SixDofDragBehavior implements Behavior<Mesh> {
  39048. private static _virtualScene;
  39049. private _ownerNode;
  39050. private _sceneRenderObserver;
  39051. private _scene;
  39052. private _targetPosition;
  39053. private _virtualOriginMesh;
  39054. private _virtualDragMesh;
  39055. private _pointerObserver;
  39056. private _moving;
  39057. private _startingOrientation;
  39058. /**
  39059. * 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)
  39060. */
  39061. private zDragFactor;
  39062. /**
  39063. * If the object should rotate to face the drag origin
  39064. */
  39065. rotateDraggedObject: boolean;
  39066. /**
  39067. * If the behavior is currently in a dragging state
  39068. */
  39069. dragging: boolean;
  39070. /**
  39071. * 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)
  39072. */
  39073. dragDeltaRatio: number;
  39074. /**
  39075. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39076. */
  39077. currentDraggingPointerID: number;
  39078. /**
  39079. * If camera controls should be detached during the drag
  39080. */
  39081. detachCameraControls: boolean;
  39082. /**
  39083. * Fires each time a drag starts
  39084. */
  39085. onDragStartObservable: Observable<{}>;
  39086. /**
  39087. * Fires each time a drag ends (eg. mouse release after drag)
  39088. */
  39089. onDragEndObservable: Observable<{}>;
  39090. /**
  39091. * 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
  39092. */
  39093. constructor();
  39094. /**
  39095. * The name of the behavior
  39096. */
  39097. get name(): string;
  39098. /**
  39099. * Initializes the behavior
  39100. */
  39101. init(): void;
  39102. /**
  39103. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39104. */
  39105. private get _pointerCamera();
  39106. /**
  39107. * Attaches the scale behavior the passed in mesh
  39108. * @param ownerNode The mesh that will be scaled around once attached
  39109. */
  39110. attach(ownerNode: Mesh): void;
  39111. /**
  39112. * Detaches the behavior from the mesh
  39113. */
  39114. detach(): void;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * Class used to apply inverse kinematics to bones
  39120. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39121. */
  39122. export class BoneIKController {
  39123. private static _tmpVecs;
  39124. private static _tmpQuat;
  39125. private static _tmpMats;
  39126. /**
  39127. * Gets or sets the target mesh
  39128. */
  39129. targetMesh: AbstractMesh;
  39130. /** Gets or sets the mesh used as pole */
  39131. poleTargetMesh: AbstractMesh;
  39132. /**
  39133. * Gets or sets the bone used as pole
  39134. */
  39135. poleTargetBone: Nullable<Bone>;
  39136. /**
  39137. * Gets or sets the target position
  39138. */
  39139. targetPosition: Vector3;
  39140. /**
  39141. * Gets or sets the pole target position
  39142. */
  39143. poleTargetPosition: Vector3;
  39144. /**
  39145. * Gets or sets the pole target local offset
  39146. */
  39147. poleTargetLocalOffset: Vector3;
  39148. /**
  39149. * Gets or sets the pole angle
  39150. */
  39151. poleAngle: number;
  39152. /**
  39153. * Gets or sets the mesh associated with the controller
  39154. */
  39155. mesh: AbstractMesh;
  39156. /**
  39157. * 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)
  39158. */
  39159. slerpAmount: number;
  39160. private _bone1Quat;
  39161. private _bone1Mat;
  39162. private _bone2Ang;
  39163. private _bone1;
  39164. private _bone2;
  39165. private _bone1Length;
  39166. private _bone2Length;
  39167. private _maxAngle;
  39168. private _maxReach;
  39169. private _rightHandedSystem;
  39170. private _bendAxis;
  39171. private _slerping;
  39172. private _adjustRoll;
  39173. /**
  39174. * Gets or sets maximum allowed angle
  39175. */
  39176. get maxAngle(): number;
  39177. set maxAngle(value: number);
  39178. /**
  39179. * Creates a new BoneIKController
  39180. * @param mesh defines the mesh to control
  39181. * @param bone defines the bone to control
  39182. * @param options defines options to set up the controller
  39183. */
  39184. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39185. targetMesh?: AbstractMesh;
  39186. poleTargetMesh?: AbstractMesh;
  39187. poleTargetBone?: Bone;
  39188. poleTargetLocalOffset?: Vector3;
  39189. poleAngle?: number;
  39190. bendAxis?: Vector3;
  39191. maxAngle?: number;
  39192. slerpAmount?: number;
  39193. });
  39194. private _setMaxAngle;
  39195. /**
  39196. * Force the controller to update the bones
  39197. */
  39198. update(): void;
  39199. }
  39200. }
  39201. declare module BABYLON {
  39202. /**
  39203. * Class used to make a bone look toward a point in space
  39204. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39205. */
  39206. export class BoneLookController {
  39207. private static _tmpVecs;
  39208. private static _tmpQuat;
  39209. private static _tmpMats;
  39210. /**
  39211. * The target Vector3 that the bone will look at
  39212. */
  39213. target: Vector3;
  39214. /**
  39215. * The mesh that the bone is attached to
  39216. */
  39217. mesh: AbstractMesh;
  39218. /**
  39219. * The bone that will be looking to the target
  39220. */
  39221. bone: Bone;
  39222. /**
  39223. * The up axis of the coordinate system that is used when the bone is rotated
  39224. */
  39225. upAxis: Vector3;
  39226. /**
  39227. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39228. */
  39229. upAxisSpace: Space;
  39230. /**
  39231. * Used to make an adjustment to the yaw of the bone
  39232. */
  39233. adjustYaw: number;
  39234. /**
  39235. * Used to make an adjustment to the pitch of the bone
  39236. */
  39237. adjustPitch: number;
  39238. /**
  39239. * Used to make an adjustment to the roll of the bone
  39240. */
  39241. adjustRoll: number;
  39242. /**
  39243. * 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)
  39244. */
  39245. slerpAmount: number;
  39246. private _minYaw;
  39247. private _maxYaw;
  39248. private _minPitch;
  39249. private _maxPitch;
  39250. private _minYawSin;
  39251. private _minYawCos;
  39252. private _maxYawSin;
  39253. private _maxYawCos;
  39254. private _midYawConstraint;
  39255. private _minPitchTan;
  39256. private _maxPitchTan;
  39257. private _boneQuat;
  39258. private _slerping;
  39259. private _transformYawPitch;
  39260. private _transformYawPitchInv;
  39261. private _firstFrameSkipped;
  39262. private _yawRange;
  39263. private _fowardAxis;
  39264. /**
  39265. * Gets or sets the minimum yaw angle that the bone can look to
  39266. */
  39267. get minYaw(): number;
  39268. set minYaw(value: number);
  39269. /**
  39270. * Gets or sets the maximum yaw angle that the bone can look to
  39271. */
  39272. get maxYaw(): number;
  39273. set maxYaw(value: number);
  39274. /**
  39275. * Gets or sets the minimum pitch angle that the bone can look to
  39276. */
  39277. get minPitch(): number;
  39278. set minPitch(value: number);
  39279. /**
  39280. * Gets or sets the maximum pitch angle that the bone can look to
  39281. */
  39282. get maxPitch(): number;
  39283. set maxPitch(value: number);
  39284. /**
  39285. * Create a BoneLookController
  39286. * @param mesh the mesh that the bone belongs to
  39287. * @param bone the bone that will be looking to the target
  39288. * @param target the target Vector3 to look at
  39289. * @param options optional settings:
  39290. * * maxYaw: the maximum angle the bone will yaw to
  39291. * * minYaw: the minimum angle the bone will yaw to
  39292. * * maxPitch: the maximum angle the bone will pitch to
  39293. * * minPitch: the minimum angle the bone will yaw to
  39294. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39295. * * upAxis: the up axis of the coordinate system
  39296. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39297. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39298. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39299. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39300. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39301. * * adjustRoll: used to make an adjustment to the roll of the bone
  39302. **/
  39303. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39304. maxYaw?: number;
  39305. minYaw?: number;
  39306. maxPitch?: number;
  39307. minPitch?: number;
  39308. slerpAmount?: number;
  39309. upAxis?: Vector3;
  39310. upAxisSpace?: Space;
  39311. yawAxis?: Vector3;
  39312. pitchAxis?: Vector3;
  39313. adjustYaw?: number;
  39314. adjustPitch?: number;
  39315. adjustRoll?: number;
  39316. });
  39317. /**
  39318. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39319. */
  39320. update(): void;
  39321. private _getAngleDiff;
  39322. private _getAngleBetween;
  39323. private _isAngleBetween;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * Manage the gamepad inputs to control an arc rotate camera.
  39329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39330. */
  39331. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39332. /**
  39333. * Defines the camera the input is attached to.
  39334. */
  39335. camera: ArcRotateCamera;
  39336. /**
  39337. * Defines the gamepad the input is gathering event from.
  39338. */
  39339. gamepad: Nullable<Gamepad>;
  39340. /**
  39341. * Defines the gamepad rotation sensiblity.
  39342. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39343. */
  39344. gamepadRotationSensibility: number;
  39345. /**
  39346. * Defines the gamepad move sensiblity.
  39347. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39348. */
  39349. gamepadMoveSensibility: number;
  39350. private _yAxisScale;
  39351. /**
  39352. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39353. */
  39354. get invertYAxis(): boolean;
  39355. set invertYAxis(value: boolean);
  39356. private _onGamepadConnectedObserver;
  39357. private _onGamepadDisconnectedObserver;
  39358. /**
  39359. * Attach the input controls to a specific dom element to get the input from.
  39360. * @param element Defines the element the controls should be listened from
  39361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39362. */
  39363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39364. /**
  39365. * Detach the current controls from the specified dom element.
  39366. * @param element Defines the element to stop listening the inputs from
  39367. */
  39368. detachControl(element: Nullable<HTMLElement>): void;
  39369. /**
  39370. * Update the current camera state depending on the inputs that have been used this frame.
  39371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39372. */
  39373. checkInputs(): void;
  39374. /**
  39375. * Gets the class name of the current intput.
  39376. * @returns the class name
  39377. */
  39378. getClassName(): string;
  39379. /**
  39380. * Get the friendly name associated with the input class.
  39381. * @returns the input friendly name
  39382. */
  39383. getSimpleName(): string;
  39384. }
  39385. }
  39386. declare module BABYLON {
  39387. interface ArcRotateCameraInputsManager {
  39388. /**
  39389. * Add orientation input support to the input manager.
  39390. * @returns the current input manager
  39391. */
  39392. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39393. }
  39394. /**
  39395. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39397. */
  39398. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39399. /**
  39400. * Defines the camera the input is attached to.
  39401. */
  39402. camera: ArcRotateCamera;
  39403. /**
  39404. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39405. */
  39406. alphaCorrection: number;
  39407. /**
  39408. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39409. */
  39410. gammaCorrection: number;
  39411. private _alpha;
  39412. private _gamma;
  39413. private _dirty;
  39414. private _deviceOrientationHandler;
  39415. /**
  39416. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39417. */
  39418. constructor();
  39419. /**
  39420. * Attach the input controls to a specific dom element to get the input from.
  39421. * @param element Defines the element the controls should be listened from
  39422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39423. */
  39424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39425. /** @hidden */
  39426. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39427. /**
  39428. * Update the current camera state depending on the inputs that have been used this frame.
  39429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39430. */
  39431. checkInputs(): void;
  39432. /**
  39433. * Detach the current controls from the specified dom element.
  39434. * @param element Defines the element to stop listening the inputs from
  39435. */
  39436. detachControl(element: Nullable<HTMLElement>): void;
  39437. /**
  39438. * Gets the class name of the current intput.
  39439. * @returns the class name
  39440. */
  39441. getClassName(): string;
  39442. /**
  39443. * Get the friendly name associated with the input class.
  39444. * @returns the input friendly name
  39445. */
  39446. getSimpleName(): string;
  39447. }
  39448. }
  39449. declare module BABYLON {
  39450. /**
  39451. * Listen to mouse events to control the camera.
  39452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39453. */
  39454. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39455. /**
  39456. * Defines the camera the input is attached to.
  39457. */
  39458. camera: FlyCamera;
  39459. /**
  39460. * Defines if touch is enabled. (Default is true.)
  39461. */
  39462. touchEnabled: boolean;
  39463. /**
  39464. * Defines the buttons associated with the input to handle camera rotation.
  39465. */
  39466. buttons: number[];
  39467. /**
  39468. * Assign buttons for Yaw control.
  39469. */
  39470. buttonsYaw: number[];
  39471. /**
  39472. * Assign buttons for Pitch control.
  39473. */
  39474. buttonsPitch: number[];
  39475. /**
  39476. * Assign buttons for Roll control.
  39477. */
  39478. buttonsRoll: number[];
  39479. /**
  39480. * Detect if any button is being pressed while mouse is moved.
  39481. * -1 = Mouse locked.
  39482. * 0 = Left button.
  39483. * 1 = Middle Button.
  39484. * 2 = Right Button.
  39485. */
  39486. activeButton: number;
  39487. /**
  39488. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39489. * Higher values reduce its sensitivity.
  39490. */
  39491. angularSensibility: number;
  39492. private _mousemoveCallback;
  39493. private _observer;
  39494. private _rollObserver;
  39495. private previousPosition;
  39496. private noPreventDefault;
  39497. private element;
  39498. /**
  39499. * Listen to mouse events to control the camera.
  39500. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39502. */
  39503. constructor(touchEnabled?: boolean);
  39504. /**
  39505. * Attach the mouse control to the HTML DOM element.
  39506. * @param element Defines the element that listens to the input events.
  39507. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39508. */
  39509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39510. /**
  39511. * Detach the current controls from the specified dom element.
  39512. * @param element Defines the element to stop listening the inputs from
  39513. */
  39514. detachControl(element: Nullable<HTMLElement>): void;
  39515. /**
  39516. * Gets the class name of the current input.
  39517. * @returns the class name.
  39518. */
  39519. getClassName(): string;
  39520. /**
  39521. * Get the friendly name associated with the input class.
  39522. * @returns the input's friendly name.
  39523. */
  39524. getSimpleName(): string;
  39525. private _pointerInput;
  39526. private _onMouseMove;
  39527. /**
  39528. * Rotate camera by mouse offset.
  39529. */
  39530. private rotateCamera;
  39531. }
  39532. }
  39533. declare module BABYLON {
  39534. /**
  39535. * Default Inputs manager for the FlyCamera.
  39536. * It groups all the default supported inputs for ease of use.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39540. /**
  39541. * Instantiates a new FlyCameraInputsManager.
  39542. * @param camera Defines the camera the inputs belong to.
  39543. */
  39544. constructor(camera: FlyCamera);
  39545. /**
  39546. * Add keyboard input support to the input manager.
  39547. * @returns the new FlyCameraKeyboardMoveInput().
  39548. */
  39549. addKeyboard(): FlyCameraInputsManager;
  39550. /**
  39551. * Add mouse input support to the input manager.
  39552. * @param touchEnabled Enable touch screen support.
  39553. * @returns the new FlyCameraMouseInput().
  39554. */
  39555. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39556. }
  39557. }
  39558. declare module BABYLON {
  39559. /**
  39560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39561. * such as in a 3D Space Shooter or a Flight Simulator.
  39562. */
  39563. export class FlyCamera extends TargetCamera {
  39564. /**
  39565. * Define the collision ellipsoid of the camera.
  39566. * This is helpful for simulating a camera body, like a player's body.
  39567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39568. */
  39569. ellipsoid: Vector3;
  39570. /**
  39571. * Define an offset for the position of the ellipsoid around the camera.
  39572. * This can be helpful if the camera is attached away from the player's body center,
  39573. * such as at its head.
  39574. */
  39575. ellipsoidOffset: Vector3;
  39576. /**
  39577. * Enable or disable collisions of the camera with the rest of the scene objects.
  39578. */
  39579. checkCollisions: boolean;
  39580. /**
  39581. * Enable or disable gravity on the camera.
  39582. */
  39583. applyGravity: boolean;
  39584. /**
  39585. * Define the current direction the camera is moving to.
  39586. */
  39587. cameraDirection: Vector3;
  39588. /**
  39589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39590. * This overrides and empties cameraRotation.
  39591. */
  39592. rotationQuaternion: Quaternion;
  39593. /**
  39594. * Track Roll to maintain the wanted Rolling when looking around.
  39595. */
  39596. _trackRoll: number;
  39597. /**
  39598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39599. */
  39600. rollCorrect: number;
  39601. /**
  39602. * Mimic a banked turn, Rolling the camera when Yawing.
  39603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39604. */
  39605. bankedTurn: boolean;
  39606. /**
  39607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39608. */
  39609. bankedTurnLimit: number;
  39610. /**
  39611. * Value of 0 disables the banked Roll.
  39612. * Value of 1 is equal to the Yaw angle in radians.
  39613. */
  39614. bankedTurnMultiplier: number;
  39615. /**
  39616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39617. */
  39618. inputs: FlyCameraInputsManager;
  39619. /**
  39620. * Gets the input sensibility for mouse input.
  39621. * Higher values reduce sensitivity.
  39622. */
  39623. get angularSensibility(): number;
  39624. /**
  39625. * Sets the input sensibility for a mouse input.
  39626. * Higher values reduce sensitivity.
  39627. */
  39628. set angularSensibility(value: number);
  39629. /**
  39630. * Get the keys for camera movement forward.
  39631. */
  39632. get keysForward(): number[];
  39633. /**
  39634. * Set the keys for camera movement forward.
  39635. */
  39636. set keysForward(value: number[]);
  39637. /**
  39638. * Get the keys for camera movement backward.
  39639. */
  39640. get keysBackward(): number[];
  39641. set keysBackward(value: number[]);
  39642. /**
  39643. * Get the keys for camera movement up.
  39644. */
  39645. get keysUp(): number[];
  39646. /**
  39647. * Set the keys for camera movement up.
  39648. */
  39649. set keysUp(value: number[]);
  39650. /**
  39651. * Get the keys for camera movement down.
  39652. */
  39653. get keysDown(): number[];
  39654. /**
  39655. * Set the keys for camera movement down.
  39656. */
  39657. set keysDown(value: number[]);
  39658. /**
  39659. * Get the keys for camera movement left.
  39660. */
  39661. get keysLeft(): number[];
  39662. /**
  39663. * Set the keys for camera movement left.
  39664. */
  39665. set keysLeft(value: number[]);
  39666. /**
  39667. * Set the keys for camera movement right.
  39668. */
  39669. get keysRight(): number[];
  39670. /**
  39671. * Set the keys for camera movement right.
  39672. */
  39673. set keysRight(value: number[]);
  39674. /**
  39675. * Event raised when the camera collides with a mesh in the scene.
  39676. */
  39677. onCollide: (collidedMesh: AbstractMesh) => void;
  39678. private _collider;
  39679. private _needMoveForGravity;
  39680. private _oldPosition;
  39681. private _diffPosition;
  39682. private _newPosition;
  39683. /** @hidden */
  39684. _localDirection: Vector3;
  39685. /** @hidden */
  39686. _transformedDirection: Vector3;
  39687. /**
  39688. * Instantiates a FlyCamera.
  39689. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39690. * such as in a 3D Space Shooter or a Flight Simulator.
  39691. * @param name Define the name of the camera in the scene.
  39692. * @param position Define the starting position of the camera in the scene.
  39693. * @param scene Define the scene the camera belongs to.
  39694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39695. */
  39696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39697. /**
  39698. * Attach a control to the HTML DOM element.
  39699. * @param element Defines the element that listens to the input events.
  39700. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39701. */
  39702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39703. /**
  39704. * Detach a control from the HTML DOM element.
  39705. * The camera will stop reacting to that input.
  39706. * @param element Defines the element that listens to the input events.
  39707. */
  39708. detachControl(element: HTMLElement): void;
  39709. private _collisionMask;
  39710. /**
  39711. * Get the mask that the camera ignores in collision events.
  39712. */
  39713. get collisionMask(): number;
  39714. /**
  39715. * Set the mask that the camera ignores in collision events.
  39716. */
  39717. set collisionMask(mask: number);
  39718. /** @hidden */
  39719. _collideWithWorld(displacement: Vector3): void;
  39720. /** @hidden */
  39721. private _onCollisionPositionChange;
  39722. /** @hidden */
  39723. _checkInputs(): void;
  39724. /** @hidden */
  39725. _decideIfNeedsToMove(): boolean;
  39726. /** @hidden */
  39727. _updatePosition(): void;
  39728. /**
  39729. * Restore the Roll to its target value at the rate specified.
  39730. * @param rate - Higher means slower restoring.
  39731. * @hidden
  39732. */
  39733. restoreRoll(rate: number): void;
  39734. /**
  39735. * Destroy the camera and release the current resources held by it.
  39736. */
  39737. dispose(): void;
  39738. /**
  39739. * Get the current object class name.
  39740. * @returns the class name.
  39741. */
  39742. getClassName(): string;
  39743. }
  39744. }
  39745. declare module BABYLON {
  39746. /**
  39747. * Listen to keyboard events to control the camera.
  39748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39749. */
  39750. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39751. /**
  39752. * Defines the camera the input is attached to.
  39753. */
  39754. camera: FlyCamera;
  39755. /**
  39756. * The list of keyboard keys used to control the forward move of the camera.
  39757. */
  39758. keysForward: number[];
  39759. /**
  39760. * The list of keyboard keys used to control the backward move of the camera.
  39761. */
  39762. keysBackward: number[];
  39763. /**
  39764. * The list of keyboard keys used to control the forward move of the camera.
  39765. */
  39766. keysUp: number[];
  39767. /**
  39768. * The list of keyboard keys used to control the backward move of the camera.
  39769. */
  39770. keysDown: number[];
  39771. /**
  39772. * The list of keyboard keys used to control the right strafe move of the camera.
  39773. */
  39774. keysRight: number[];
  39775. /**
  39776. * The list of keyboard keys used to control the left strafe move of the camera.
  39777. */
  39778. keysLeft: number[];
  39779. private _keys;
  39780. private _onCanvasBlurObserver;
  39781. private _onKeyboardObserver;
  39782. private _engine;
  39783. private _scene;
  39784. /**
  39785. * Attach the input controls to a specific dom element to get the input from.
  39786. * @param element Defines the element the controls should be listened from
  39787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39788. */
  39789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39790. /**
  39791. * Detach the current controls from the specified dom element.
  39792. * @param element Defines the element to stop listening the inputs from
  39793. */
  39794. detachControl(element: Nullable<HTMLElement>): void;
  39795. /**
  39796. * Gets the class name of the current intput.
  39797. * @returns the class name
  39798. */
  39799. getClassName(): string;
  39800. /** @hidden */
  39801. _onLostFocus(e: FocusEvent): void;
  39802. /**
  39803. * Get the friendly name associated with the input class.
  39804. * @returns the input friendly name
  39805. */
  39806. getSimpleName(): string;
  39807. /**
  39808. * Update the current camera state depending on the inputs that have been used this frame.
  39809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39810. */
  39811. checkInputs(): void;
  39812. }
  39813. }
  39814. declare module BABYLON {
  39815. /**
  39816. * Manage the mouse wheel inputs to control a follow camera.
  39817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39818. */
  39819. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39820. /**
  39821. * Defines the camera the input is attached to.
  39822. */
  39823. camera: FollowCamera;
  39824. /**
  39825. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39826. */
  39827. axisControlRadius: boolean;
  39828. /**
  39829. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39830. */
  39831. axisControlHeight: boolean;
  39832. /**
  39833. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39834. */
  39835. axisControlRotation: boolean;
  39836. /**
  39837. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39838. * relation to mouseWheel events.
  39839. */
  39840. wheelPrecision: number;
  39841. /**
  39842. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39843. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39844. */
  39845. wheelDeltaPercentage: number;
  39846. private _wheel;
  39847. private _observer;
  39848. /**
  39849. * Attach the input controls to a specific dom element to get the input from.
  39850. * @param element Defines the element the controls should be listened from
  39851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39852. */
  39853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39854. /**
  39855. * Detach the current controls from the specified dom element.
  39856. * @param element Defines the element to stop listening the inputs from
  39857. */
  39858. detachControl(element: Nullable<HTMLElement>): void;
  39859. /**
  39860. * Gets the class name of the current intput.
  39861. * @returns the class name
  39862. */
  39863. getClassName(): string;
  39864. /**
  39865. * Get the friendly name associated with the input class.
  39866. * @returns the input friendly name
  39867. */
  39868. getSimpleName(): string;
  39869. }
  39870. }
  39871. declare module BABYLON {
  39872. /**
  39873. * Manage the pointers inputs to control an follow camera.
  39874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39875. */
  39876. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39877. /**
  39878. * Defines the camera the input is attached to.
  39879. */
  39880. camera: FollowCamera;
  39881. /**
  39882. * Gets the class name of the current input.
  39883. * @returns the class name
  39884. */
  39885. getClassName(): string;
  39886. /**
  39887. * Defines the pointer angular sensibility along the X axis or how fast is
  39888. * the camera rotating.
  39889. * A negative number will reverse the axis direction.
  39890. */
  39891. angularSensibilityX: number;
  39892. /**
  39893. * Defines the pointer angular sensibility along the Y axis or how fast is
  39894. * the camera rotating.
  39895. * A negative number will reverse the axis direction.
  39896. */
  39897. angularSensibilityY: number;
  39898. /**
  39899. * Defines the pointer pinch precision or how fast is the camera zooming.
  39900. * A negative number will reverse the axis direction.
  39901. */
  39902. pinchPrecision: number;
  39903. /**
  39904. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39905. * from 0.
  39906. * It defines the percentage of current camera.radius to use as delta when
  39907. * pinch zoom is used.
  39908. */
  39909. pinchDeltaPercentage: number;
  39910. /**
  39911. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39912. */
  39913. axisXControlRadius: boolean;
  39914. /**
  39915. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39916. */
  39917. axisXControlHeight: boolean;
  39918. /**
  39919. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39920. */
  39921. axisXControlRotation: boolean;
  39922. /**
  39923. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39924. */
  39925. axisYControlRadius: boolean;
  39926. /**
  39927. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39928. */
  39929. axisYControlHeight: boolean;
  39930. /**
  39931. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39932. */
  39933. axisYControlRotation: boolean;
  39934. /**
  39935. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39936. */
  39937. axisPinchControlRadius: boolean;
  39938. /**
  39939. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39940. */
  39941. axisPinchControlHeight: boolean;
  39942. /**
  39943. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39944. */
  39945. axisPinchControlRotation: boolean;
  39946. /**
  39947. * Log error messages if basic misconfiguration has occurred.
  39948. */
  39949. warningEnable: boolean;
  39950. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39951. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39952. private _warningCounter;
  39953. private _warning;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /**
  39958. * Default Inputs manager for the FollowCamera.
  39959. * It groups all the default supported inputs for ease of use.
  39960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39961. */
  39962. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39963. /**
  39964. * Instantiates a new FollowCameraInputsManager.
  39965. * @param camera Defines the camera the inputs belong to
  39966. */
  39967. constructor(camera: FollowCamera);
  39968. /**
  39969. * Add keyboard input support to the input manager.
  39970. * @returns the current input manager
  39971. */
  39972. addKeyboard(): FollowCameraInputsManager;
  39973. /**
  39974. * Add mouse wheel input support to the input manager.
  39975. * @returns the current input manager
  39976. */
  39977. addMouseWheel(): FollowCameraInputsManager;
  39978. /**
  39979. * Add pointers input support to the input manager.
  39980. * @returns the current input manager
  39981. */
  39982. addPointers(): FollowCameraInputsManager;
  39983. /**
  39984. * Add orientation input support to the input manager.
  39985. * @returns the current input manager
  39986. */
  39987. addVRDeviceOrientation(): FollowCameraInputsManager;
  39988. }
  39989. }
  39990. declare module BABYLON {
  39991. /**
  39992. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39993. * an arc rotate version arcFollowCamera are available.
  39994. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39995. */
  39996. export class FollowCamera extends TargetCamera {
  39997. /**
  39998. * Distance the follow camera should follow an object at
  39999. */
  40000. radius: number;
  40001. /**
  40002. * Minimum allowed distance of the camera to the axis of rotation
  40003. * (The camera can not get closer).
  40004. * This can help limiting how the Camera is able to move in the scene.
  40005. */
  40006. lowerRadiusLimit: Nullable<number>;
  40007. /**
  40008. * Maximum allowed distance of the camera to the axis of rotation
  40009. * (The camera can not get further).
  40010. * This can help limiting how the Camera is able to move in the scene.
  40011. */
  40012. upperRadiusLimit: Nullable<number>;
  40013. /**
  40014. * Define a rotation offset between the camera and the object it follows
  40015. */
  40016. rotationOffset: number;
  40017. /**
  40018. * Minimum allowed angle to camera position relative to target object.
  40019. * This can help limiting how the Camera is able to move in the scene.
  40020. */
  40021. lowerRotationOffsetLimit: Nullable<number>;
  40022. /**
  40023. * Maximum allowed angle to camera position relative to target object.
  40024. * This can help limiting how the Camera is able to move in the scene.
  40025. */
  40026. upperRotationOffsetLimit: Nullable<number>;
  40027. /**
  40028. * Define a height offset between the camera and the object it follows.
  40029. * It can help following an object from the top (like a car chaing a plane)
  40030. */
  40031. heightOffset: number;
  40032. /**
  40033. * Minimum allowed height of camera position relative to target object.
  40034. * This can help limiting how the Camera is able to move in the scene.
  40035. */
  40036. lowerHeightOffsetLimit: Nullable<number>;
  40037. /**
  40038. * Maximum allowed height of camera position relative to target object.
  40039. * This can help limiting how the Camera is able to move in the scene.
  40040. */
  40041. upperHeightOffsetLimit: Nullable<number>;
  40042. /**
  40043. * Define how fast the camera can accelerate to follow it s target.
  40044. */
  40045. cameraAcceleration: number;
  40046. /**
  40047. * Define the speed limit of the camera following an object.
  40048. */
  40049. maxCameraSpeed: number;
  40050. /**
  40051. * Define the target of the camera.
  40052. */
  40053. lockedTarget: Nullable<AbstractMesh>;
  40054. /**
  40055. * Defines the input associated with the camera.
  40056. */
  40057. inputs: FollowCameraInputsManager;
  40058. /**
  40059. * Instantiates the follow camera.
  40060. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40061. * @param name Define the name of the camera in the scene
  40062. * @param position Define the position of the camera
  40063. * @param scene Define the scene the camera belong to
  40064. * @param lockedTarget Define the target of the camera
  40065. */
  40066. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40067. private _follow;
  40068. /**
  40069. * Attached controls to the current camera.
  40070. * @param element Defines the element the controls should be listened from
  40071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40072. */
  40073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40074. /**
  40075. * Detach the current controls from the camera.
  40076. * The camera will stop reacting to inputs.
  40077. * @param element Defines the element to stop listening the inputs from
  40078. */
  40079. detachControl(element: HTMLElement): void;
  40080. /** @hidden */
  40081. _checkInputs(): void;
  40082. private _checkLimits;
  40083. /**
  40084. * Gets the camera class name.
  40085. * @returns the class name
  40086. */
  40087. getClassName(): string;
  40088. }
  40089. /**
  40090. * Arc Rotate version of the follow camera.
  40091. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40092. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40093. */
  40094. export class ArcFollowCamera extends TargetCamera {
  40095. /** The longitudinal angle of the camera */
  40096. alpha: number;
  40097. /** The latitudinal angle of the camera */
  40098. beta: number;
  40099. /** The radius of the camera from its target */
  40100. radius: number;
  40101. /** Define the camera target (the messh it should follow) */
  40102. target: Nullable<AbstractMesh>;
  40103. private _cartesianCoordinates;
  40104. /**
  40105. * Instantiates a new ArcFollowCamera
  40106. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40107. * @param name Define the name of the camera
  40108. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40109. * @param beta Define the rotation angle of the camera around the elevation axis
  40110. * @param radius Define the radius of the camera from its target point
  40111. * @param target Define the target of the camera
  40112. * @param scene Define the scene the camera belongs to
  40113. */
  40114. constructor(name: string,
  40115. /** The longitudinal angle of the camera */
  40116. alpha: number,
  40117. /** The latitudinal angle of the camera */
  40118. beta: number,
  40119. /** The radius of the camera from its target */
  40120. radius: number,
  40121. /** Define the camera target (the messh it should follow) */
  40122. target: Nullable<AbstractMesh>, scene: Scene);
  40123. private _follow;
  40124. /** @hidden */
  40125. _checkInputs(): void;
  40126. /**
  40127. * Returns the class name of the object.
  40128. * It is mostly used internally for serialization purposes.
  40129. */
  40130. getClassName(): string;
  40131. }
  40132. }
  40133. declare module BABYLON {
  40134. /**
  40135. * Manage the keyboard inputs to control the movement of a follow camera.
  40136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40137. */
  40138. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40139. /**
  40140. * Defines the camera the input is attached to.
  40141. */
  40142. camera: FollowCamera;
  40143. /**
  40144. * Defines the list of key codes associated with the up action (increase heightOffset)
  40145. */
  40146. keysHeightOffsetIncr: number[];
  40147. /**
  40148. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40149. */
  40150. keysHeightOffsetDecr: number[];
  40151. /**
  40152. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40153. */
  40154. keysHeightOffsetModifierAlt: boolean;
  40155. /**
  40156. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40157. */
  40158. keysHeightOffsetModifierCtrl: boolean;
  40159. /**
  40160. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40161. */
  40162. keysHeightOffsetModifierShift: boolean;
  40163. /**
  40164. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40165. */
  40166. keysRotationOffsetIncr: number[];
  40167. /**
  40168. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40169. */
  40170. keysRotationOffsetDecr: number[];
  40171. /**
  40172. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40173. */
  40174. keysRotationOffsetModifierAlt: boolean;
  40175. /**
  40176. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40177. */
  40178. keysRotationOffsetModifierCtrl: boolean;
  40179. /**
  40180. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40181. */
  40182. keysRotationOffsetModifierShift: boolean;
  40183. /**
  40184. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40185. */
  40186. keysRadiusIncr: number[];
  40187. /**
  40188. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40189. */
  40190. keysRadiusDecr: number[];
  40191. /**
  40192. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40193. */
  40194. keysRadiusModifierAlt: boolean;
  40195. /**
  40196. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40197. */
  40198. keysRadiusModifierCtrl: boolean;
  40199. /**
  40200. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40201. */
  40202. keysRadiusModifierShift: boolean;
  40203. /**
  40204. * Defines the rate of change of heightOffset.
  40205. */
  40206. heightSensibility: number;
  40207. /**
  40208. * Defines the rate of change of rotationOffset.
  40209. */
  40210. rotationSensibility: number;
  40211. /**
  40212. * Defines the rate of change of radius.
  40213. */
  40214. radiusSensibility: number;
  40215. private _keys;
  40216. private _ctrlPressed;
  40217. private _altPressed;
  40218. private _shiftPressed;
  40219. private _onCanvasBlurObserver;
  40220. private _onKeyboardObserver;
  40221. private _engine;
  40222. private _scene;
  40223. /**
  40224. * Attach the input controls to a specific dom element to get the input from.
  40225. * @param element Defines the element the controls should be listened from
  40226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40227. */
  40228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40229. /**
  40230. * Detach the current controls from the specified dom element.
  40231. * @param element Defines the element to stop listening the inputs from
  40232. */
  40233. detachControl(element: Nullable<HTMLElement>): void;
  40234. /**
  40235. * Update the current camera state depending on the inputs that have been used this frame.
  40236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40237. */
  40238. checkInputs(): void;
  40239. /**
  40240. * Gets the class name of the current input.
  40241. * @returns the class name
  40242. */
  40243. getClassName(): string;
  40244. /**
  40245. * Get the friendly name associated with the input class.
  40246. * @returns the input friendly name
  40247. */
  40248. getSimpleName(): string;
  40249. /**
  40250. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40251. * allow modification of the heightOffset value.
  40252. */
  40253. private _modifierHeightOffset;
  40254. /**
  40255. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40256. * allow modification of the rotationOffset value.
  40257. */
  40258. private _modifierRotationOffset;
  40259. /**
  40260. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40261. * allow modification of the radius value.
  40262. */
  40263. private _modifierRadius;
  40264. }
  40265. }
  40266. declare module BABYLON {
  40267. interface FreeCameraInputsManager {
  40268. /**
  40269. * @hidden
  40270. */
  40271. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40272. /**
  40273. * Add orientation input support to the input manager.
  40274. * @returns the current input manager
  40275. */
  40276. addDeviceOrientation(): FreeCameraInputsManager;
  40277. }
  40278. /**
  40279. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40280. * Screen rotation is taken into account.
  40281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40282. */
  40283. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40284. private _camera;
  40285. private _screenOrientationAngle;
  40286. private _constantTranform;
  40287. private _screenQuaternion;
  40288. private _alpha;
  40289. private _beta;
  40290. private _gamma;
  40291. /**
  40292. * Can be used to detect if a device orientation sensor is available on a device
  40293. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40294. * @returns a promise that will resolve on orientation change
  40295. */
  40296. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40297. /**
  40298. * @hidden
  40299. */
  40300. _onDeviceOrientationChangedObservable: Observable<void>;
  40301. /**
  40302. * Instantiates a new input
  40303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40304. */
  40305. constructor();
  40306. /**
  40307. * Define the camera controlled by the input.
  40308. */
  40309. get camera(): FreeCamera;
  40310. set camera(camera: FreeCamera);
  40311. /**
  40312. * Attach the input controls to a specific dom element to get the input from.
  40313. * @param element Defines the element the controls should be listened from
  40314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40315. */
  40316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40317. private _orientationChanged;
  40318. private _deviceOrientation;
  40319. /**
  40320. * Detach the current controls from the specified dom element.
  40321. * @param element Defines the element to stop listening the inputs from
  40322. */
  40323. detachControl(element: Nullable<HTMLElement>): void;
  40324. /**
  40325. * Update the current camera state depending on the inputs that have been used this frame.
  40326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40327. */
  40328. checkInputs(): void;
  40329. /**
  40330. * Gets the class name of the current intput.
  40331. * @returns the class name
  40332. */
  40333. getClassName(): string;
  40334. /**
  40335. * Get the friendly name associated with the input class.
  40336. * @returns the input friendly name
  40337. */
  40338. getSimpleName(): string;
  40339. }
  40340. }
  40341. declare module BABYLON {
  40342. /**
  40343. * Manage the gamepad inputs to control a free camera.
  40344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40345. */
  40346. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40347. /**
  40348. * Define the camera the input is attached to.
  40349. */
  40350. camera: FreeCamera;
  40351. /**
  40352. * Define the Gamepad controlling the input
  40353. */
  40354. gamepad: Nullable<Gamepad>;
  40355. /**
  40356. * Defines the gamepad rotation sensiblity.
  40357. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40358. */
  40359. gamepadAngularSensibility: number;
  40360. /**
  40361. * Defines the gamepad move sensiblity.
  40362. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40363. */
  40364. gamepadMoveSensibility: number;
  40365. private _yAxisScale;
  40366. /**
  40367. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40368. */
  40369. get invertYAxis(): boolean;
  40370. set invertYAxis(value: boolean);
  40371. private _onGamepadConnectedObserver;
  40372. private _onGamepadDisconnectedObserver;
  40373. private _cameraTransform;
  40374. private _deltaTransform;
  40375. private _vector3;
  40376. private _vector2;
  40377. /**
  40378. * Attach the input controls to a specific dom element to get the input from.
  40379. * @param element Defines the element the controls should be listened from
  40380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40381. */
  40382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40383. /**
  40384. * Detach the current controls from the specified dom element.
  40385. * @param element Defines the element to stop listening the inputs from
  40386. */
  40387. detachControl(element: Nullable<HTMLElement>): void;
  40388. /**
  40389. * Update the current camera state depending on the inputs that have been used this frame.
  40390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40391. */
  40392. checkInputs(): void;
  40393. /**
  40394. * Gets the class name of the current intput.
  40395. * @returns the class name
  40396. */
  40397. getClassName(): string;
  40398. /**
  40399. * Get the friendly name associated with the input class.
  40400. * @returns the input friendly name
  40401. */
  40402. getSimpleName(): string;
  40403. }
  40404. }
  40405. declare module BABYLON {
  40406. /**
  40407. * Defines the potential axis of a Joystick
  40408. */
  40409. export enum JoystickAxis {
  40410. /** X axis */
  40411. X = 0,
  40412. /** Y axis */
  40413. Y = 1,
  40414. /** Z axis */
  40415. Z = 2
  40416. }
  40417. /**
  40418. * Class used to define virtual joystick (used in touch mode)
  40419. */
  40420. export class VirtualJoystick {
  40421. /**
  40422. * Gets or sets a boolean indicating that left and right values must be inverted
  40423. */
  40424. reverseLeftRight: boolean;
  40425. /**
  40426. * Gets or sets a boolean indicating that up and down values must be inverted
  40427. */
  40428. reverseUpDown: boolean;
  40429. /**
  40430. * Gets the offset value for the position (ie. the change of the position value)
  40431. */
  40432. deltaPosition: Vector3;
  40433. /**
  40434. * Gets a boolean indicating if the virtual joystick was pressed
  40435. */
  40436. pressed: boolean;
  40437. /**
  40438. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40439. */
  40440. static Canvas: Nullable<HTMLCanvasElement>;
  40441. private static _globalJoystickIndex;
  40442. private static vjCanvasContext;
  40443. private static vjCanvasWidth;
  40444. private static vjCanvasHeight;
  40445. private static halfWidth;
  40446. private _action;
  40447. private _axisTargetedByLeftAndRight;
  40448. private _axisTargetedByUpAndDown;
  40449. private _joystickSensibility;
  40450. private _inversedSensibility;
  40451. private _joystickPointerID;
  40452. private _joystickColor;
  40453. private _joystickPointerPos;
  40454. private _joystickPreviousPointerPos;
  40455. private _joystickPointerStartPos;
  40456. private _deltaJoystickVector;
  40457. private _leftJoystick;
  40458. private _touches;
  40459. private _onPointerDownHandlerRef;
  40460. private _onPointerMoveHandlerRef;
  40461. private _onPointerUpHandlerRef;
  40462. private _onResize;
  40463. /**
  40464. * Creates a new virtual joystick
  40465. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40466. */
  40467. constructor(leftJoystick?: boolean);
  40468. /**
  40469. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40470. * @param newJoystickSensibility defines the new sensibility
  40471. */
  40472. setJoystickSensibility(newJoystickSensibility: number): void;
  40473. private _onPointerDown;
  40474. private _onPointerMove;
  40475. private _onPointerUp;
  40476. /**
  40477. * Change the color of the virtual joystick
  40478. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40479. */
  40480. setJoystickColor(newColor: string): void;
  40481. /**
  40482. * Defines a callback to call when the joystick is touched
  40483. * @param action defines the callback
  40484. */
  40485. setActionOnTouch(action: () => any): void;
  40486. /**
  40487. * Defines which axis you'd like to control for left & right
  40488. * @param axis defines the axis to use
  40489. */
  40490. setAxisForLeftRight(axis: JoystickAxis): void;
  40491. /**
  40492. * Defines which axis you'd like to control for up & down
  40493. * @param axis defines the axis to use
  40494. */
  40495. setAxisForUpDown(axis: JoystickAxis): void;
  40496. private _drawVirtualJoystick;
  40497. /**
  40498. * Release internal HTML canvas
  40499. */
  40500. releaseCanvas(): void;
  40501. }
  40502. }
  40503. declare module BABYLON {
  40504. interface FreeCameraInputsManager {
  40505. /**
  40506. * Add virtual joystick input support to the input manager.
  40507. * @returns the current input manager
  40508. */
  40509. addVirtualJoystick(): FreeCameraInputsManager;
  40510. }
  40511. /**
  40512. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40514. */
  40515. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40516. /**
  40517. * Defines the camera the input is attached to.
  40518. */
  40519. camera: FreeCamera;
  40520. private _leftjoystick;
  40521. private _rightjoystick;
  40522. /**
  40523. * Gets the left stick of the virtual joystick.
  40524. * @returns The virtual Joystick
  40525. */
  40526. getLeftJoystick(): VirtualJoystick;
  40527. /**
  40528. * Gets the right stick of the virtual joystick.
  40529. * @returns The virtual Joystick
  40530. */
  40531. getRightJoystick(): VirtualJoystick;
  40532. /**
  40533. * Update the current camera state depending on the inputs that have been used this frame.
  40534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40535. */
  40536. checkInputs(): void;
  40537. /**
  40538. * Attach the input controls to a specific dom element to get the input from.
  40539. * @param element Defines the element the controls should be listened from
  40540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40541. */
  40542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40543. /**
  40544. * Detach the current controls from the specified dom element.
  40545. * @param element Defines the element to stop listening the inputs from
  40546. */
  40547. detachControl(element: Nullable<HTMLElement>): void;
  40548. /**
  40549. * Gets the class name of the current intput.
  40550. * @returns the class name
  40551. */
  40552. getClassName(): string;
  40553. /**
  40554. * Get the friendly name associated with the input class.
  40555. * @returns the input friendly name
  40556. */
  40557. getSimpleName(): string;
  40558. }
  40559. }
  40560. declare module BABYLON {
  40561. /**
  40562. * This represents a FPS type of camera controlled by touch.
  40563. * This is like a universal camera minus the Gamepad controls.
  40564. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40565. */
  40566. export class TouchCamera extends FreeCamera {
  40567. /**
  40568. * Defines the touch sensibility for rotation.
  40569. * The higher the faster.
  40570. */
  40571. get touchAngularSensibility(): number;
  40572. set touchAngularSensibility(value: number);
  40573. /**
  40574. * Defines the touch sensibility for move.
  40575. * The higher the faster.
  40576. */
  40577. get touchMoveSensibility(): number;
  40578. set touchMoveSensibility(value: number);
  40579. /**
  40580. * Instantiates a new touch camera.
  40581. * This represents a FPS type of camera controlled by touch.
  40582. * This is like a universal camera minus the Gamepad controls.
  40583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40584. * @param name Define the name of the camera in the scene
  40585. * @param position Define the start position of the camera in the scene
  40586. * @param scene Define the scene the camera belongs to
  40587. */
  40588. constructor(name: string, position: Vector3, scene: Scene);
  40589. /**
  40590. * Gets the current object class name.
  40591. * @return the class name
  40592. */
  40593. getClassName(): string;
  40594. /** @hidden */
  40595. _setupInputs(): void;
  40596. }
  40597. }
  40598. declare module BABYLON {
  40599. /**
  40600. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40601. * being tilted forward or back and left or right.
  40602. */
  40603. export class DeviceOrientationCamera extends FreeCamera {
  40604. private _initialQuaternion;
  40605. private _quaternionCache;
  40606. private _tmpDragQuaternion;
  40607. private _disablePointerInputWhenUsingDeviceOrientation;
  40608. /**
  40609. * Creates a new device orientation camera
  40610. * @param name The name of the camera
  40611. * @param position The start position camera
  40612. * @param scene The scene the camera belongs to
  40613. */
  40614. constructor(name: string, position: Vector3, scene: Scene);
  40615. /**
  40616. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40617. */
  40618. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40619. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40620. private _dragFactor;
  40621. /**
  40622. * Enabled turning on the y axis when the orientation sensor is active
  40623. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40624. */
  40625. enableHorizontalDragging(dragFactor?: number): void;
  40626. /**
  40627. * Gets the current instance class name ("DeviceOrientationCamera").
  40628. * This helps avoiding instanceof at run time.
  40629. * @returns the class name
  40630. */
  40631. getClassName(): string;
  40632. /**
  40633. * @hidden
  40634. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40635. */
  40636. _checkInputs(): void;
  40637. /**
  40638. * Reset the camera to its default orientation on the specified axis only.
  40639. * @param axis The axis to reset
  40640. */
  40641. resetToCurrentRotation(axis?: Axis): void;
  40642. }
  40643. }
  40644. declare module BABYLON {
  40645. /**
  40646. * Defines supported buttons for XBox360 compatible gamepads
  40647. */
  40648. export enum Xbox360Button {
  40649. /** A */
  40650. A = 0,
  40651. /** B */
  40652. B = 1,
  40653. /** X */
  40654. X = 2,
  40655. /** Y */
  40656. Y = 3,
  40657. /** Start */
  40658. Start = 4,
  40659. /** Back */
  40660. Back = 5,
  40661. /** Left button */
  40662. LB = 6,
  40663. /** Right button */
  40664. RB = 7,
  40665. /** Left stick */
  40666. LeftStick = 8,
  40667. /** Right stick */
  40668. RightStick = 9
  40669. }
  40670. /** Defines values for XBox360 DPad */
  40671. export enum Xbox360Dpad {
  40672. /** Up */
  40673. Up = 0,
  40674. /** Down */
  40675. Down = 1,
  40676. /** Left */
  40677. Left = 2,
  40678. /** Right */
  40679. Right = 3
  40680. }
  40681. /**
  40682. * Defines a XBox360 gamepad
  40683. */
  40684. export class Xbox360Pad extends Gamepad {
  40685. private _leftTrigger;
  40686. private _rightTrigger;
  40687. private _onlefttriggerchanged;
  40688. private _onrighttriggerchanged;
  40689. private _onbuttondown;
  40690. private _onbuttonup;
  40691. private _ondpaddown;
  40692. private _ondpadup;
  40693. /** Observable raised when a button is pressed */
  40694. onButtonDownObservable: Observable<Xbox360Button>;
  40695. /** Observable raised when a button is released */
  40696. onButtonUpObservable: Observable<Xbox360Button>;
  40697. /** Observable raised when a pad is pressed */
  40698. onPadDownObservable: Observable<Xbox360Dpad>;
  40699. /** Observable raised when a pad is released */
  40700. onPadUpObservable: Observable<Xbox360Dpad>;
  40701. private _buttonA;
  40702. private _buttonB;
  40703. private _buttonX;
  40704. private _buttonY;
  40705. private _buttonBack;
  40706. private _buttonStart;
  40707. private _buttonLB;
  40708. private _buttonRB;
  40709. private _buttonLeftStick;
  40710. private _buttonRightStick;
  40711. private _dPadUp;
  40712. private _dPadDown;
  40713. private _dPadLeft;
  40714. private _dPadRight;
  40715. private _isXboxOnePad;
  40716. /**
  40717. * Creates a new XBox360 gamepad object
  40718. * @param id defines the id of this gamepad
  40719. * @param index defines its index
  40720. * @param gamepad defines the internal HTML gamepad object
  40721. * @param xboxOne defines if it is a XBox One gamepad
  40722. */
  40723. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40724. /**
  40725. * Defines the callback to call when left trigger is pressed
  40726. * @param callback defines the callback to use
  40727. */
  40728. onlefttriggerchanged(callback: (value: number) => void): void;
  40729. /**
  40730. * Defines the callback to call when right trigger is pressed
  40731. * @param callback defines the callback to use
  40732. */
  40733. onrighttriggerchanged(callback: (value: number) => void): void;
  40734. /**
  40735. * Gets the left trigger value
  40736. */
  40737. get leftTrigger(): number;
  40738. /**
  40739. * Sets the left trigger value
  40740. */
  40741. set leftTrigger(newValue: number);
  40742. /**
  40743. * Gets the right trigger value
  40744. */
  40745. get rightTrigger(): number;
  40746. /**
  40747. * Sets the right trigger value
  40748. */
  40749. set rightTrigger(newValue: number);
  40750. /**
  40751. * Defines the callback to call when a button is pressed
  40752. * @param callback defines the callback to use
  40753. */
  40754. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40755. /**
  40756. * Defines the callback to call when a button is released
  40757. * @param callback defines the callback to use
  40758. */
  40759. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40760. /**
  40761. * Defines the callback to call when a pad is pressed
  40762. * @param callback defines the callback to use
  40763. */
  40764. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40765. /**
  40766. * Defines the callback to call when a pad is released
  40767. * @param callback defines the callback to use
  40768. */
  40769. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40770. private _setButtonValue;
  40771. private _setDPadValue;
  40772. /**
  40773. * Gets the value of the `A` button
  40774. */
  40775. get buttonA(): number;
  40776. /**
  40777. * Sets the value of the `A` button
  40778. */
  40779. set buttonA(value: number);
  40780. /**
  40781. * Gets the value of the `B` button
  40782. */
  40783. get buttonB(): number;
  40784. /**
  40785. * Sets the value of the `B` button
  40786. */
  40787. set buttonB(value: number);
  40788. /**
  40789. * Gets the value of the `X` button
  40790. */
  40791. get buttonX(): number;
  40792. /**
  40793. * Sets the value of the `X` button
  40794. */
  40795. set buttonX(value: number);
  40796. /**
  40797. * Gets the value of the `Y` button
  40798. */
  40799. get buttonY(): number;
  40800. /**
  40801. * Sets the value of the `Y` button
  40802. */
  40803. set buttonY(value: number);
  40804. /**
  40805. * Gets the value of the `Start` button
  40806. */
  40807. get buttonStart(): number;
  40808. /**
  40809. * Sets the value of the `Start` button
  40810. */
  40811. set buttonStart(value: number);
  40812. /**
  40813. * Gets the value of the `Back` button
  40814. */
  40815. get buttonBack(): number;
  40816. /**
  40817. * Sets the value of the `Back` button
  40818. */
  40819. set buttonBack(value: number);
  40820. /**
  40821. * Gets the value of the `Left` button
  40822. */
  40823. get buttonLB(): number;
  40824. /**
  40825. * Sets the value of the `Left` button
  40826. */
  40827. set buttonLB(value: number);
  40828. /**
  40829. * Gets the value of the `Right` button
  40830. */
  40831. get buttonRB(): number;
  40832. /**
  40833. * Sets the value of the `Right` button
  40834. */
  40835. set buttonRB(value: number);
  40836. /**
  40837. * Gets the value of the Left joystick
  40838. */
  40839. get buttonLeftStick(): number;
  40840. /**
  40841. * Sets the value of the Left joystick
  40842. */
  40843. set buttonLeftStick(value: number);
  40844. /**
  40845. * Gets the value of the Right joystick
  40846. */
  40847. get buttonRightStick(): number;
  40848. /**
  40849. * Sets the value of the Right joystick
  40850. */
  40851. set buttonRightStick(value: number);
  40852. /**
  40853. * Gets the value of D-pad up
  40854. */
  40855. get dPadUp(): number;
  40856. /**
  40857. * Sets the value of D-pad up
  40858. */
  40859. set dPadUp(value: number);
  40860. /**
  40861. * Gets the value of D-pad down
  40862. */
  40863. get dPadDown(): number;
  40864. /**
  40865. * Sets the value of D-pad down
  40866. */
  40867. set dPadDown(value: number);
  40868. /**
  40869. * Gets the value of D-pad left
  40870. */
  40871. get dPadLeft(): number;
  40872. /**
  40873. * Sets the value of D-pad left
  40874. */
  40875. set dPadLeft(value: number);
  40876. /**
  40877. * Gets the value of D-pad right
  40878. */
  40879. get dPadRight(): number;
  40880. /**
  40881. * Sets the value of D-pad right
  40882. */
  40883. set dPadRight(value: number);
  40884. /**
  40885. * Force the gamepad to synchronize with device values
  40886. */
  40887. update(): void;
  40888. /**
  40889. * Disposes the gamepad
  40890. */
  40891. dispose(): void;
  40892. }
  40893. }
  40894. declare module BABYLON {
  40895. /**
  40896. * Defines supported buttons for DualShock compatible gamepads
  40897. */
  40898. export enum DualShockButton {
  40899. /** Cross */
  40900. Cross = 0,
  40901. /** Circle */
  40902. Circle = 1,
  40903. /** Square */
  40904. Square = 2,
  40905. /** Triangle */
  40906. Triangle = 3,
  40907. /** Options */
  40908. Options = 4,
  40909. /** Share */
  40910. Share = 5,
  40911. /** L1 */
  40912. L1 = 6,
  40913. /** R1 */
  40914. R1 = 7,
  40915. /** Left stick */
  40916. LeftStick = 8,
  40917. /** Right stick */
  40918. RightStick = 9
  40919. }
  40920. /** Defines values for DualShock DPad */
  40921. export enum DualShockDpad {
  40922. /** Up */
  40923. Up = 0,
  40924. /** Down */
  40925. Down = 1,
  40926. /** Left */
  40927. Left = 2,
  40928. /** Right */
  40929. Right = 3
  40930. }
  40931. /**
  40932. * Defines a DualShock gamepad
  40933. */
  40934. export class DualShockPad extends Gamepad {
  40935. private _leftTrigger;
  40936. private _rightTrigger;
  40937. private _onlefttriggerchanged;
  40938. private _onrighttriggerchanged;
  40939. private _onbuttondown;
  40940. private _onbuttonup;
  40941. private _ondpaddown;
  40942. private _ondpadup;
  40943. /** Observable raised when a button is pressed */
  40944. onButtonDownObservable: Observable<DualShockButton>;
  40945. /** Observable raised when a button is released */
  40946. onButtonUpObservable: Observable<DualShockButton>;
  40947. /** Observable raised when a pad is pressed */
  40948. onPadDownObservable: Observable<DualShockDpad>;
  40949. /** Observable raised when a pad is released */
  40950. onPadUpObservable: Observable<DualShockDpad>;
  40951. private _buttonCross;
  40952. private _buttonCircle;
  40953. private _buttonSquare;
  40954. private _buttonTriangle;
  40955. private _buttonShare;
  40956. private _buttonOptions;
  40957. private _buttonL1;
  40958. private _buttonR1;
  40959. private _buttonLeftStick;
  40960. private _buttonRightStick;
  40961. private _dPadUp;
  40962. private _dPadDown;
  40963. private _dPadLeft;
  40964. private _dPadRight;
  40965. /**
  40966. * Creates a new DualShock gamepad object
  40967. * @param id defines the id of this gamepad
  40968. * @param index defines its index
  40969. * @param gamepad defines the internal HTML gamepad object
  40970. */
  40971. constructor(id: string, index: number, gamepad: any);
  40972. /**
  40973. * Defines the callback to call when left trigger is pressed
  40974. * @param callback defines the callback to use
  40975. */
  40976. onlefttriggerchanged(callback: (value: number) => void): void;
  40977. /**
  40978. * Defines the callback to call when right trigger is pressed
  40979. * @param callback defines the callback to use
  40980. */
  40981. onrighttriggerchanged(callback: (value: number) => void): void;
  40982. /**
  40983. * Gets the left trigger value
  40984. */
  40985. get leftTrigger(): number;
  40986. /**
  40987. * Sets the left trigger value
  40988. */
  40989. set leftTrigger(newValue: number);
  40990. /**
  40991. * Gets the right trigger value
  40992. */
  40993. get rightTrigger(): number;
  40994. /**
  40995. * Sets the right trigger value
  40996. */
  40997. set rightTrigger(newValue: number);
  40998. /**
  40999. * Defines the callback to call when a button is pressed
  41000. * @param callback defines the callback to use
  41001. */
  41002. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41003. /**
  41004. * Defines the callback to call when a button is released
  41005. * @param callback defines the callback to use
  41006. */
  41007. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41008. /**
  41009. * Defines the callback to call when a pad is pressed
  41010. * @param callback defines the callback to use
  41011. */
  41012. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41013. /**
  41014. * Defines the callback to call when a pad is released
  41015. * @param callback defines the callback to use
  41016. */
  41017. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41018. private _setButtonValue;
  41019. private _setDPadValue;
  41020. /**
  41021. * Gets the value of the `Cross` button
  41022. */
  41023. get buttonCross(): number;
  41024. /**
  41025. * Sets the value of the `Cross` button
  41026. */
  41027. set buttonCross(value: number);
  41028. /**
  41029. * Gets the value of the `Circle` button
  41030. */
  41031. get buttonCircle(): number;
  41032. /**
  41033. * Sets the value of the `Circle` button
  41034. */
  41035. set buttonCircle(value: number);
  41036. /**
  41037. * Gets the value of the `Square` button
  41038. */
  41039. get buttonSquare(): number;
  41040. /**
  41041. * Sets the value of the `Square` button
  41042. */
  41043. set buttonSquare(value: number);
  41044. /**
  41045. * Gets the value of the `Triangle` button
  41046. */
  41047. get buttonTriangle(): number;
  41048. /**
  41049. * Sets the value of the `Triangle` button
  41050. */
  41051. set buttonTriangle(value: number);
  41052. /**
  41053. * Gets the value of the `Options` button
  41054. */
  41055. get buttonOptions(): number;
  41056. /**
  41057. * Sets the value of the `Options` button
  41058. */
  41059. set buttonOptions(value: number);
  41060. /**
  41061. * Gets the value of the `Share` button
  41062. */
  41063. get buttonShare(): number;
  41064. /**
  41065. * Sets the value of the `Share` button
  41066. */
  41067. set buttonShare(value: number);
  41068. /**
  41069. * Gets the value of the `L1` button
  41070. */
  41071. get buttonL1(): number;
  41072. /**
  41073. * Sets the value of the `L1` button
  41074. */
  41075. set buttonL1(value: number);
  41076. /**
  41077. * Gets the value of the `R1` button
  41078. */
  41079. get buttonR1(): number;
  41080. /**
  41081. * Sets the value of the `R1` button
  41082. */
  41083. set buttonR1(value: number);
  41084. /**
  41085. * Gets the value of the Left joystick
  41086. */
  41087. get buttonLeftStick(): number;
  41088. /**
  41089. * Sets the value of the Left joystick
  41090. */
  41091. set buttonLeftStick(value: number);
  41092. /**
  41093. * Gets the value of the Right joystick
  41094. */
  41095. get buttonRightStick(): number;
  41096. /**
  41097. * Sets the value of the Right joystick
  41098. */
  41099. set buttonRightStick(value: number);
  41100. /**
  41101. * Gets the value of D-pad up
  41102. */
  41103. get dPadUp(): number;
  41104. /**
  41105. * Sets the value of D-pad up
  41106. */
  41107. set dPadUp(value: number);
  41108. /**
  41109. * Gets the value of D-pad down
  41110. */
  41111. get dPadDown(): number;
  41112. /**
  41113. * Sets the value of D-pad down
  41114. */
  41115. set dPadDown(value: number);
  41116. /**
  41117. * Gets the value of D-pad left
  41118. */
  41119. get dPadLeft(): number;
  41120. /**
  41121. * Sets the value of D-pad left
  41122. */
  41123. set dPadLeft(value: number);
  41124. /**
  41125. * Gets the value of D-pad right
  41126. */
  41127. get dPadRight(): number;
  41128. /**
  41129. * Sets the value of D-pad right
  41130. */
  41131. set dPadRight(value: number);
  41132. /**
  41133. * Force the gamepad to synchronize with device values
  41134. */
  41135. update(): void;
  41136. /**
  41137. * Disposes the gamepad
  41138. */
  41139. dispose(): void;
  41140. }
  41141. }
  41142. declare module BABYLON {
  41143. /**
  41144. * Manager for handling gamepads
  41145. */
  41146. export class GamepadManager {
  41147. private _scene?;
  41148. private _babylonGamepads;
  41149. private _oneGamepadConnected;
  41150. /** @hidden */
  41151. _isMonitoring: boolean;
  41152. private _gamepadEventSupported;
  41153. private _gamepadSupport?;
  41154. /**
  41155. * observable to be triggered when the gamepad controller has been connected
  41156. */
  41157. onGamepadConnectedObservable: Observable<Gamepad>;
  41158. /**
  41159. * observable to be triggered when the gamepad controller has been disconnected
  41160. */
  41161. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41162. private _onGamepadConnectedEvent;
  41163. private _onGamepadDisconnectedEvent;
  41164. /**
  41165. * Initializes the gamepad manager
  41166. * @param _scene BabylonJS scene
  41167. */
  41168. constructor(_scene?: Scene | undefined);
  41169. /**
  41170. * The gamepads in the game pad manager
  41171. */
  41172. get gamepads(): Gamepad[];
  41173. /**
  41174. * Get the gamepad controllers based on type
  41175. * @param type The type of gamepad controller
  41176. * @returns Nullable gamepad
  41177. */
  41178. getGamepadByType(type?: number): Nullable<Gamepad>;
  41179. /**
  41180. * Disposes the gamepad manager
  41181. */
  41182. dispose(): void;
  41183. private _addNewGamepad;
  41184. private _startMonitoringGamepads;
  41185. private _stopMonitoringGamepads;
  41186. /** @hidden */
  41187. _checkGamepadsStatus(): void;
  41188. private _updateGamepadObjects;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. interface Scene {
  41193. /** @hidden */
  41194. _gamepadManager: Nullable<GamepadManager>;
  41195. /**
  41196. * Gets the gamepad manager associated with the scene
  41197. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41198. */
  41199. gamepadManager: GamepadManager;
  41200. }
  41201. /**
  41202. * Interface representing a free camera inputs manager
  41203. */
  41204. interface FreeCameraInputsManager {
  41205. /**
  41206. * Adds gamepad input support to the FreeCameraInputsManager.
  41207. * @returns the FreeCameraInputsManager
  41208. */
  41209. addGamepad(): FreeCameraInputsManager;
  41210. }
  41211. /**
  41212. * Interface representing an arc rotate camera inputs manager
  41213. */
  41214. interface ArcRotateCameraInputsManager {
  41215. /**
  41216. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41217. * @returns the camera inputs manager
  41218. */
  41219. addGamepad(): ArcRotateCameraInputsManager;
  41220. }
  41221. /**
  41222. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41223. */
  41224. export class GamepadSystemSceneComponent implements ISceneComponent {
  41225. /**
  41226. * The component name helpfull to identify the component in the list of scene components.
  41227. */
  41228. readonly name: string;
  41229. /**
  41230. * The scene the component belongs to.
  41231. */
  41232. scene: Scene;
  41233. /**
  41234. * Creates a new instance of the component for the given scene
  41235. * @param scene Defines the scene to register the component in
  41236. */
  41237. constructor(scene: Scene);
  41238. /**
  41239. * Registers the component in a given scene
  41240. */
  41241. register(): void;
  41242. /**
  41243. * Rebuilds the elements related to this component in case of
  41244. * context lost for instance.
  41245. */
  41246. rebuild(): void;
  41247. /**
  41248. * Disposes the component and the associated ressources
  41249. */
  41250. dispose(): void;
  41251. private _beforeCameraUpdate;
  41252. }
  41253. }
  41254. declare module BABYLON {
  41255. /**
  41256. * 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,
  41257. * which still works and will still be found in many Playgrounds.
  41258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41259. */
  41260. export class UniversalCamera extends TouchCamera {
  41261. /**
  41262. * Defines the gamepad rotation sensiblity.
  41263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41264. */
  41265. get gamepadAngularSensibility(): number;
  41266. set gamepadAngularSensibility(value: number);
  41267. /**
  41268. * Defines the gamepad move sensiblity.
  41269. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41270. */
  41271. get gamepadMoveSensibility(): number;
  41272. set gamepadMoveSensibility(value: number);
  41273. /**
  41274. * 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,
  41275. * which still works and will still be found in many Playgrounds.
  41276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41277. * @param name Define the name of the camera in the scene
  41278. * @param position Define the start position of the camera in the scene
  41279. * @param scene Define the scene the camera belongs to
  41280. */
  41281. constructor(name: string, position: Vector3, scene: Scene);
  41282. /**
  41283. * Gets the current object class name.
  41284. * @return the class name
  41285. */
  41286. getClassName(): string;
  41287. }
  41288. }
  41289. declare module BABYLON {
  41290. /**
  41291. * This represents a FPS type of camera. This is only here for back compat purpose.
  41292. * Please use the UniversalCamera instead as both are identical.
  41293. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41294. */
  41295. export class GamepadCamera extends UniversalCamera {
  41296. /**
  41297. * Instantiates a new Gamepad Camera
  41298. * This represents a FPS type of camera. This is only here for back compat purpose.
  41299. * Please use the UniversalCamera instead as both are identical.
  41300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41301. * @param name Define the name of the camera in the scene
  41302. * @param position Define the start position of the camera in the scene
  41303. * @param scene Define the scene the camera belongs to
  41304. */
  41305. constructor(name: string, position: Vector3, scene: Scene);
  41306. /**
  41307. * Gets the current object class name.
  41308. * @return the class name
  41309. */
  41310. getClassName(): string;
  41311. }
  41312. }
  41313. declare module BABYLON {
  41314. /** @hidden */
  41315. export var passPixelShader: {
  41316. name: string;
  41317. shader: string;
  41318. };
  41319. }
  41320. declare module BABYLON {
  41321. /** @hidden */
  41322. export var passCubePixelShader: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * PassPostProcess which produces an output the same as it's input
  41330. */
  41331. export class PassPostProcess extends PostProcess {
  41332. /**
  41333. * Creates the PassPostProcess
  41334. * @param name The name of the effect.
  41335. * @param options The required width/height ratio to downsize to before computing the render pass.
  41336. * @param camera The camera to apply the render pass to.
  41337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41338. * @param engine The engine which the post process will be applied. (default: current engine)
  41339. * @param reusable If the post process can be reused on the same frame. (default: false)
  41340. * @param textureType The type of texture to be used when performing the post processing.
  41341. * @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)
  41342. */
  41343. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41344. }
  41345. /**
  41346. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41347. */
  41348. export class PassCubePostProcess extends PostProcess {
  41349. private _face;
  41350. /**
  41351. * Gets or sets the cube face to display.
  41352. * * 0 is +X
  41353. * * 1 is -X
  41354. * * 2 is +Y
  41355. * * 3 is -Y
  41356. * * 4 is +Z
  41357. * * 5 is -Z
  41358. */
  41359. get face(): number;
  41360. set face(value: number);
  41361. /**
  41362. * Creates the PassCubePostProcess
  41363. * @param name The name of the effect.
  41364. * @param options The required width/height ratio to downsize to before computing the render pass.
  41365. * @param camera The camera to apply the render pass to.
  41366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41367. * @param engine The engine which the post process will be applied. (default: current engine)
  41368. * @param reusable If the post process can be reused on the same frame. (default: false)
  41369. * @param textureType The type of texture to be used when performing the post processing.
  41370. * @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)
  41371. */
  41372. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41373. }
  41374. }
  41375. declare module BABYLON {
  41376. /** @hidden */
  41377. export var anaglyphPixelShader: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module BABYLON {
  41383. /**
  41384. * Postprocess used to generate anaglyphic rendering
  41385. */
  41386. export class AnaglyphPostProcess extends PostProcess {
  41387. private _passedProcess;
  41388. /**
  41389. * Creates a new AnaglyphPostProcess
  41390. * @param name defines postprocess name
  41391. * @param options defines creation options or target ratio scale
  41392. * @param rigCameras defines cameras using this postprocess
  41393. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41394. * @param engine defines hosting engine
  41395. * @param reusable defines if the postprocess will be reused multiple times per frame
  41396. */
  41397. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41404. */
  41405. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41406. /**
  41407. * Creates a new AnaglyphArcRotateCamera
  41408. * @param name defines camera name
  41409. * @param alpha defines alpha angle (in radians)
  41410. * @param beta defines beta angle (in radians)
  41411. * @param radius defines radius
  41412. * @param target defines camera target
  41413. * @param interaxialDistance defines distance between each color axis
  41414. * @param scene defines the hosting scene
  41415. */
  41416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41417. /**
  41418. * Gets camera class name
  41419. * @returns AnaglyphArcRotateCamera
  41420. */
  41421. getClassName(): string;
  41422. }
  41423. }
  41424. declare module BABYLON {
  41425. /**
  41426. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41428. */
  41429. export class AnaglyphFreeCamera extends FreeCamera {
  41430. /**
  41431. * Creates a new AnaglyphFreeCamera
  41432. * @param name defines camera name
  41433. * @param position defines initial position
  41434. * @param interaxialDistance defines distance between each color axis
  41435. * @param scene defines the hosting scene
  41436. */
  41437. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41438. /**
  41439. * Gets camera class name
  41440. * @returns AnaglyphFreeCamera
  41441. */
  41442. getClassName(): string;
  41443. }
  41444. }
  41445. declare module BABYLON {
  41446. /**
  41447. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41449. */
  41450. export class AnaglyphGamepadCamera extends GamepadCamera {
  41451. /**
  41452. * Creates a new AnaglyphGamepadCamera
  41453. * @param name defines camera name
  41454. * @param position defines initial position
  41455. * @param interaxialDistance defines distance between each color axis
  41456. * @param scene defines the hosting scene
  41457. */
  41458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41459. /**
  41460. * Gets camera class name
  41461. * @returns AnaglyphGamepadCamera
  41462. */
  41463. getClassName(): string;
  41464. }
  41465. }
  41466. declare module BABYLON {
  41467. /**
  41468. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41469. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41470. */
  41471. export class AnaglyphUniversalCamera extends UniversalCamera {
  41472. /**
  41473. * Creates a new AnaglyphUniversalCamera
  41474. * @param name defines camera name
  41475. * @param position defines initial position
  41476. * @param interaxialDistance defines distance between each color axis
  41477. * @param scene defines the hosting scene
  41478. */
  41479. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41480. /**
  41481. * Gets camera class name
  41482. * @returns AnaglyphUniversalCamera
  41483. */
  41484. getClassName(): string;
  41485. }
  41486. }
  41487. declare module BABYLON {
  41488. /** @hidden */
  41489. export var stereoscopicInterlacePixelShader: {
  41490. name: string;
  41491. shader: string;
  41492. };
  41493. }
  41494. declare module BABYLON {
  41495. /**
  41496. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41497. */
  41498. export class StereoscopicInterlacePostProcess extends PostProcess {
  41499. private _stepSize;
  41500. private _passedProcess;
  41501. /**
  41502. * Initializes a StereoscopicInterlacePostProcess
  41503. * @param name The name of the effect.
  41504. * @param rigCameras The rig cameras to be appled to the post process
  41505. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41507. * @param engine The engine which the post process will be applied. (default: current engine)
  41508. * @param reusable If the post process can be reused on the same frame. (default: false)
  41509. */
  41510. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41511. }
  41512. }
  41513. declare module BABYLON {
  41514. /**
  41515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41516. * @see http://doc.babylonjs.com/features/cameras
  41517. */
  41518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41519. /**
  41520. * Creates a new StereoscopicArcRotateCamera
  41521. * @param name defines camera name
  41522. * @param alpha defines alpha angle (in radians)
  41523. * @param beta defines beta angle (in radians)
  41524. * @param radius defines radius
  41525. * @param target defines camera target
  41526. * @param interaxialDistance defines distance between each color axis
  41527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41528. * @param scene defines the hosting scene
  41529. */
  41530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41531. /**
  41532. * Gets camera class name
  41533. * @returns StereoscopicArcRotateCamera
  41534. */
  41535. getClassName(): string;
  41536. }
  41537. }
  41538. declare module BABYLON {
  41539. /**
  41540. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41541. * @see http://doc.babylonjs.com/features/cameras
  41542. */
  41543. export class StereoscopicFreeCamera extends FreeCamera {
  41544. /**
  41545. * Creates a new StereoscopicFreeCamera
  41546. * @param name defines camera name
  41547. * @param position defines initial position
  41548. * @param interaxialDistance defines distance between each color axis
  41549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41550. * @param scene defines the hosting scene
  41551. */
  41552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41553. /**
  41554. * Gets camera class name
  41555. * @returns StereoscopicFreeCamera
  41556. */
  41557. getClassName(): string;
  41558. }
  41559. }
  41560. declare module BABYLON {
  41561. /**
  41562. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41563. * @see http://doc.babylonjs.com/features/cameras
  41564. */
  41565. export class StereoscopicGamepadCamera extends GamepadCamera {
  41566. /**
  41567. * Creates a new StereoscopicGamepadCamera
  41568. * @param name defines camera name
  41569. * @param position defines initial position
  41570. * @param interaxialDistance defines distance between each color axis
  41571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41572. * @param scene defines the hosting scene
  41573. */
  41574. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41575. /**
  41576. * Gets camera class name
  41577. * @returns StereoscopicGamepadCamera
  41578. */
  41579. getClassName(): string;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41585. * @see http://doc.babylonjs.com/features/cameras
  41586. */
  41587. export class StereoscopicUniversalCamera extends UniversalCamera {
  41588. /**
  41589. * Creates a new StereoscopicUniversalCamera
  41590. * @param name defines camera name
  41591. * @param position defines initial position
  41592. * @param interaxialDistance defines distance between each color axis
  41593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41594. * @param scene defines the hosting scene
  41595. */
  41596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41597. /**
  41598. * Gets camera class name
  41599. * @returns StereoscopicUniversalCamera
  41600. */
  41601. getClassName(): string;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41610. */
  41611. export class VirtualJoysticksCamera extends FreeCamera {
  41612. /**
  41613. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41617. * @param name Define the name of the camera in the scene
  41618. * @param position Define the start position of the camera in the scene
  41619. * @param scene Define the scene the camera belongs to
  41620. */
  41621. constructor(name: string, position: Vector3, scene: Scene);
  41622. /**
  41623. * Gets the current object class name.
  41624. * @return the class name
  41625. */
  41626. getClassName(): string;
  41627. }
  41628. }
  41629. declare module BABYLON {
  41630. /**
  41631. * This represents all the required metrics to create a VR camera.
  41632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41633. */
  41634. export class VRCameraMetrics {
  41635. /**
  41636. * Define the horizontal resolution off the screen.
  41637. */
  41638. hResolution: number;
  41639. /**
  41640. * Define the vertical resolution off the screen.
  41641. */
  41642. vResolution: number;
  41643. /**
  41644. * Define the horizontal screen size.
  41645. */
  41646. hScreenSize: number;
  41647. /**
  41648. * Define the vertical screen size.
  41649. */
  41650. vScreenSize: number;
  41651. /**
  41652. * Define the vertical screen center position.
  41653. */
  41654. vScreenCenter: number;
  41655. /**
  41656. * Define the distance of the eyes to the screen.
  41657. */
  41658. eyeToScreenDistance: number;
  41659. /**
  41660. * Define the distance between both lenses
  41661. */
  41662. lensSeparationDistance: number;
  41663. /**
  41664. * Define the distance between both viewer's eyes.
  41665. */
  41666. interpupillaryDistance: number;
  41667. /**
  41668. * Define the distortion factor of the VR postprocess.
  41669. * Please, touch with care.
  41670. */
  41671. distortionK: number[];
  41672. /**
  41673. * Define the chromatic aberration correction factors for the VR post process.
  41674. */
  41675. chromaAbCorrection: number[];
  41676. /**
  41677. * Define the scale factor of the post process.
  41678. * The smaller the better but the slower.
  41679. */
  41680. postProcessScaleFactor: number;
  41681. /**
  41682. * Define an offset for the lens center.
  41683. */
  41684. lensCenterOffset: number;
  41685. /**
  41686. * Define if the current vr camera should compensate the distortion of the lense or not.
  41687. */
  41688. compensateDistortion: boolean;
  41689. /**
  41690. * Defines if multiview should be enabled when rendering (Default: false)
  41691. */
  41692. multiviewEnabled: boolean;
  41693. /**
  41694. * Gets the rendering aspect ratio based on the provided resolutions.
  41695. */
  41696. get aspectRatio(): number;
  41697. /**
  41698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41699. */
  41700. get aspectRatioFov(): number;
  41701. /**
  41702. * @hidden
  41703. */
  41704. get leftHMatrix(): Matrix;
  41705. /**
  41706. * @hidden
  41707. */
  41708. get rightHMatrix(): Matrix;
  41709. /**
  41710. * @hidden
  41711. */
  41712. get leftPreViewMatrix(): Matrix;
  41713. /**
  41714. * @hidden
  41715. */
  41716. get rightPreViewMatrix(): Matrix;
  41717. /**
  41718. * Get the default VRMetrics based on the most generic setup.
  41719. * @returns the default vr metrics
  41720. */
  41721. static GetDefault(): VRCameraMetrics;
  41722. }
  41723. }
  41724. declare module BABYLON {
  41725. /** @hidden */
  41726. export var vrDistortionCorrectionPixelShader: {
  41727. name: string;
  41728. shader: string;
  41729. };
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * VRDistortionCorrectionPostProcess used for mobile VR
  41734. */
  41735. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41736. private _isRightEye;
  41737. private _distortionFactors;
  41738. private _postProcessScaleFactor;
  41739. private _lensCenterOffset;
  41740. private _scaleIn;
  41741. private _scaleFactor;
  41742. private _lensCenter;
  41743. /**
  41744. * Initializes the VRDistortionCorrectionPostProcess
  41745. * @param name The name of the effect.
  41746. * @param camera The camera to apply the render pass to.
  41747. * @param isRightEye If this is for the right eye distortion
  41748. * @param vrMetrics All the required metrics for the VR camera
  41749. */
  41750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41751. }
  41752. }
  41753. declare module BABYLON {
  41754. /**
  41755. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41757. */
  41758. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41759. /**
  41760. * Creates a new VRDeviceOrientationArcRotateCamera
  41761. * @param name defines camera name
  41762. * @param alpha defines the camera rotation along the logitudinal axis
  41763. * @param beta defines the camera rotation along the latitudinal axis
  41764. * @param radius defines the camera distance from its target
  41765. * @param target defines the camera target
  41766. * @param scene defines the scene the camera belongs to
  41767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41769. */
  41770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41771. /**
  41772. * Gets camera class name
  41773. * @returns VRDeviceOrientationArcRotateCamera
  41774. */
  41775. getClassName(): string;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * Camera used to simulate VR rendering (based on FreeCamera)
  41781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41782. */
  41783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41784. /**
  41785. * Creates a new VRDeviceOrientationFreeCamera
  41786. * @param name defines camera name
  41787. * @param position defines the start position of the camera
  41788. * @param scene defines the scene the camera belongs to
  41789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41791. */
  41792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41793. /**
  41794. * Gets camera class name
  41795. * @returns VRDeviceOrientationFreeCamera
  41796. */
  41797. getClassName(): string;
  41798. }
  41799. }
  41800. declare module BABYLON {
  41801. /**
  41802. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41804. */
  41805. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41806. /**
  41807. * Creates a new VRDeviceOrientationGamepadCamera
  41808. * @param name defines camera name
  41809. * @param position defines the start position of the camera
  41810. * @param scene defines the scene the camera belongs to
  41811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41813. */
  41814. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41815. /**
  41816. * Gets camera class name
  41817. * @returns VRDeviceOrientationGamepadCamera
  41818. */
  41819. getClassName(): string;
  41820. }
  41821. }
  41822. declare module BABYLON {
  41823. /** @hidden */
  41824. export var imageProcessingPixelShader: {
  41825. name: string;
  41826. shader: string;
  41827. };
  41828. }
  41829. declare module BABYLON {
  41830. /**
  41831. * ImageProcessingPostProcess
  41832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41833. */
  41834. export class ImageProcessingPostProcess extends PostProcess {
  41835. /**
  41836. * Default configuration related to image processing available in the PBR Material.
  41837. */
  41838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41839. /**
  41840. * Gets the image processing configuration used either in this material.
  41841. */
  41842. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41843. /**
  41844. * Sets the Default image processing configuration used either in the this material.
  41845. *
  41846. * If sets to null, the scene one is in use.
  41847. */
  41848. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41849. /**
  41850. * Keep track of the image processing observer to allow dispose and replace.
  41851. */
  41852. private _imageProcessingObserver;
  41853. /**
  41854. * Attaches a new image processing configuration to the PBR Material.
  41855. * @param configuration
  41856. */
  41857. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41858. /**
  41859. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41860. */
  41861. get colorCurves(): Nullable<ColorCurves>;
  41862. /**
  41863. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41864. */
  41865. set colorCurves(value: Nullable<ColorCurves>);
  41866. /**
  41867. * Gets wether the color curves effect is enabled.
  41868. */
  41869. get colorCurvesEnabled(): boolean;
  41870. /**
  41871. * Sets wether the color curves effect is enabled.
  41872. */
  41873. set colorCurvesEnabled(value: boolean);
  41874. /**
  41875. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41876. */
  41877. get colorGradingTexture(): Nullable<BaseTexture>;
  41878. /**
  41879. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41880. */
  41881. set colorGradingTexture(value: Nullable<BaseTexture>);
  41882. /**
  41883. * Gets wether the color grading effect is enabled.
  41884. */
  41885. get colorGradingEnabled(): boolean;
  41886. /**
  41887. * Gets wether the color grading effect is enabled.
  41888. */
  41889. set colorGradingEnabled(value: boolean);
  41890. /**
  41891. * Gets exposure used in the effect.
  41892. */
  41893. get exposure(): number;
  41894. /**
  41895. * Sets exposure used in the effect.
  41896. */
  41897. set exposure(value: number);
  41898. /**
  41899. * Gets wether tonemapping is enabled or not.
  41900. */
  41901. get toneMappingEnabled(): boolean;
  41902. /**
  41903. * Sets wether tonemapping is enabled or not
  41904. */
  41905. set toneMappingEnabled(value: boolean);
  41906. /**
  41907. * Gets the type of tone mapping effect.
  41908. */
  41909. get toneMappingType(): number;
  41910. /**
  41911. * Sets the type of tone mapping effect.
  41912. */
  41913. set toneMappingType(value: number);
  41914. /**
  41915. * Gets contrast used in the effect.
  41916. */
  41917. get contrast(): number;
  41918. /**
  41919. * Sets contrast used in the effect.
  41920. */
  41921. set contrast(value: number);
  41922. /**
  41923. * Gets Vignette stretch size.
  41924. */
  41925. get vignetteStretch(): number;
  41926. /**
  41927. * Sets Vignette stretch size.
  41928. */
  41929. set vignetteStretch(value: number);
  41930. /**
  41931. * Gets Vignette centre X Offset.
  41932. */
  41933. get vignetteCentreX(): number;
  41934. /**
  41935. * Sets Vignette centre X Offset.
  41936. */
  41937. set vignetteCentreX(value: number);
  41938. /**
  41939. * Gets Vignette centre Y Offset.
  41940. */
  41941. get vignetteCentreY(): number;
  41942. /**
  41943. * Sets Vignette centre Y Offset.
  41944. */
  41945. set vignetteCentreY(value: number);
  41946. /**
  41947. * Gets Vignette weight or intensity of the vignette effect.
  41948. */
  41949. get vignetteWeight(): number;
  41950. /**
  41951. * Sets Vignette weight or intensity of the vignette effect.
  41952. */
  41953. set vignetteWeight(value: number);
  41954. /**
  41955. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41956. * if vignetteEnabled is set to true.
  41957. */
  41958. get vignetteColor(): Color4;
  41959. /**
  41960. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41961. * if vignetteEnabled is set to true.
  41962. */
  41963. set vignetteColor(value: Color4);
  41964. /**
  41965. * Gets Camera field of view used by the Vignette effect.
  41966. */
  41967. get vignetteCameraFov(): number;
  41968. /**
  41969. * Sets Camera field of view used by the Vignette effect.
  41970. */
  41971. set vignetteCameraFov(value: number);
  41972. /**
  41973. * Gets the vignette blend mode allowing different kind of effect.
  41974. */
  41975. get vignetteBlendMode(): number;
  41976. /**
  41977. * Sets the vignette blend mode allowing different kind of effect.
  41978. */
  41979. set vignetteBlendMode(value: number);
  41980. /**
  41981. * Gets wether the vignette effect is enabled.
  41982. */
  41983. get vignetteEnabled(): boolean;
  41984. /**
  41985. * Sets wether the vignette effect is enabled.
  41986. */
  41987. set vignetteEnabled(value: boolean);
  41988. private _fromLinearSpace;
  41989. /**
  41990. * Gets wether the input of the processing is in Gamma or Linear Space.
  41991. */
  41992. get fromLinearSpace(): boolean;
  41993. /**
  41994. * Sets wether the input of the processing is in Gamma or Linear Space.
  41995. */
  41996. set fromLinearSpace(value: boolean);
  41997. /**
  41998. * Defines cache preventing GC.
  41999. */
  42000. private _defines;
  42001. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42002. /**
  42003. * "ImageProcessingPostProcess"
  42004. * @returns "ImageProcessingPostProcess"
  42005. */
  42006. getClassName(): string;
  42007. protected _updateParameters(): void;
  42008. dispose(camera?: Camera): void;
  42009. }
  42010. }
  42011. declare module BABYLON {
  42012. /**
  42013. * Class containing static functions to help procedurally build meshes
  42014. */
  42015. export class GroundBuilder {
  42016. /**
  42017. * Creates a ground mesh
  42018. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42019. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42021. * @param name defines the name of the mesh
  42022. * @param options defines the options used to create the mesh
  42023. * @param scene defines the hosting scene
  42024. * @returns the ground mesh
  42025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42026. */
  42027. static CreateGround(name: string, options: {
  42028. width?: number;
  42029. height?: number;
  42030. subdivisions?: number;
  42031. subdivisionsX?: number;
  42032. subdivisionsY?: number;
  42033. updatable?: boolean;
  42034. }, scene: any): Mesh;
  42035. /**
  42036. * Creates a tiled ground mesh
  42037. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42038. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42039. * * 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
  42040. * * 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
  42041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42042. * @param name defines the name of the mesh
  42043. * @param options defines the options used to create the mesh
  42044. * @param scene defines the hosting scene
  42045. * @returns the tiled ground mesh
  42046. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42047. */
  42048. static CreateTiledGround(name: string, options: {
  42049. xmin: number;
  42050. zmin: number;
  42051. xmax: number;
  42052. zmax: number;
  42053. subdivisions?: {
  42054. w: number;
  42055. h: number;
  42056. };
  42057. precision?: {
  42058. w: number;
  42059. h: number;
  42060. };
  42061. updatable?: boolean;
  42062. }, scene?: Nullable<Scene>): Mesh;
  42063. /**
  42064. * Creates a ground mesh from a height map
  42065. * * The parameter `url` sets the URL of the height map image resource.
  42066. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42067. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42068. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42069. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42070. * * 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.
  42071. * * 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).
  42072. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42074. * @param name defines the name of the mesh
  42075. * @param url defines the url to the height map
  42076. * @param options defines the options used to create the mesh
  42077. * @param scene defines the hosting scene
  42078. * @returns the ground mesh
  42079. * @see https://doc.babylonjs.com/babylon101/height_map
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42081. */
  42082. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. minHeight?: number;
  42087. maxHeight?: number;
  42088. colorFilter?: Color3;
  42089. alphaFilter?: number;
  42090. updatable?: boolean;
  42091. onReady?: (mesh: GroundMesh) => void;
  42092. }, scene?: Nullable<Scene>): GroundMesh;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * Class containing static functions to help procedurally build meshes
  42098. */
  42099. export class TorusBuilder {
  42100. /**
  42101. * Creates a torus mesh
  42102. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42103. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42104. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42106. * * 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
  42107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42108. * @param name defines the name of the mesh
  42109. * @param options defines the options used to create the mesh
  42110. * @param scene defines the hosting scene
  42111. * @returns the torus mesh
  42112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42113. */
  42114. static CreateTorus(name: string, options: {
  42115. diameter?: number;
  42116. thickness?: number;
  42117. tessellation?: number;
  42118. updatable?: boolean;
  42119. sideOrientation?: number;
  42120. frontUVs?: Vector4;
  42121. backUVs?: Vector4;
  42122. }, scene: any): Mesh;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /**
  42127. * Class containing static functions to help procedurally build meshes
  42128. */
  42129. export class CylinderBuilder {
  42130. /**
  42131. * Creates a cylinder or a cone mesh
  42132. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42133. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42134. * * 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.
  42135. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42136. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42137. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42138. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42139. * * 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).
  42140. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42141. * * 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).
  42142. * * 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
  42143. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42144. * * 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
  42145. * * 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.
  42146. * * If `enclose` is false, a ring surface is one element.
  42147. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42148. * * 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
  42149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42150. * * 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
  42151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42152. * @param name defines the name of the mesh
  42153. * @param options defines the options used to create the mesh
  42154. * @param scene defines the hosting scene
  42155. * @returns the cylinder mesh
  42156. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42157. */
  42158. static CreateCylinder(name: string, options: {
  42159. height?: number;
  42160. diameterTop?: number;
  42161. diameterBottom?: number;
  42162. diameter?: number;
  42163. tessellation?: number;
  42164. subdivisions?: number;
  42165. arc?: number;
  42166. faceColors?: Color4[];
  42167. faceUV?: Vector4[];
  42168. updatable?: boolean;
  42169. hasRings?: boolean;
  42170. enclose?: boolean;
  42171. cap?: number;
  42172. sideOrientation?: number;
  42173. frontUVs?: Vector4;
  42174. backUVs?: Vector4;
  42175. }, scene: any): Mesh;
  42176. }
  42177. }
  42178. declare module BABYLON {
  42179. /**
  42180. * States of the webXR experience
  42181. */
  42182. export enum WebXRState {
  42183. /**
  42184. * Transitioning to being in XR mode
  42185. */
  42186. ENTERING_XR = 0,
  42187. /**
  42188. * Transitioning to non XR mode
  42189. */
  42190. EXITING_XR = 1,
  42191. /**
  42192. * In XR mode and presenting
  42193. */
  42194. IN_XR = 2,
  42195. /**
  42196. * Not entered XR mode
  42197. */
  42198. NOT_IN_XR = 3
  42199. }
  42200. /**
  42201. * Abstraction of the XR render target
  42202. */
  42203. export interface WebXRRenderTarget extends IDisposable {
  42204. /**
  42205. * xrpresent context of the canvas which can be used to display/mirror xr content
  42206. */
  42207. canvasContext: WebGLRenderingContext;
  42208. /**
  42209. * xr layer for the canvas
  42210. */
  42211. xrLayer: Nullable<XRWebGLLayer>;
  42212. /**
  42213. * Initializes the xr layer for the session
  42214. * @param xrSession xr session
  42215. * @returns a promise that will resolve once the XR Layer has been created
  42216. */
  42217. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42218. }
  42219. }
  42220. declare module BABYLON {
  42221. /**
  42222. * COnfiguration object for WebXR output canvas
  42223. */
  42224. export class WebXRManagedOutputCanvasOptions {
  42225. /**
  42226. * Options for this XR Layer output
  42227. */
  42228. canvasOptions: XRWebGLLayerOptions;
  42229. /**
  42230. * CSS styling for a newly created canvas (if not provided)
  42231. */
  42232. newCanvasCssStyle?: string;
  42233. /**
  42234. * Get the default values of the configuration object
  42235. * @returns default values of this configuration object
  42236. */
  42237. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42238. }
  42239. /**
  42240. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42241. */
  42242. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42243. private configuration;
  42244. private _engine;
  42245. private _canvas;
  42246. /**
  42247. * xrpresent context of the canvas which can be used to display/mirror xr content
  42248. */
  42249. canvasContext: WebGLRenderingContext;
  42250. /**
  42251. * xr layer for the canvas
  42252. */
  42253. xrLayer: Nullable<XRWebGLLayer>;
  42254. /**
  42255. * Initializes the xr layer for the session
  42256. * @param xrSession xr session
  42257. * @returns a promise that will resolve once the XR Layer has been created
  42258. */
  42259. initializeXRLayerAsync(xrSession: any): any;
  42260. /**
  42261. * Initializes the canvas to be added/removed upon entering/exiting xr
  42262. * @param engine the Babylon engine
  42263. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42264. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42265. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42266. */
  42267. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42268. /**
  42269. * Disposes of the object
  42270. */
  42271. dispose(): void;
  42272. private _setManagedOutputCanvas;
  42273. private _addCanvas;
  42274. private _removeCanvas;
  42275. }
  42276. }
  42277. declare module BABYLON {
  42278. /**
  42279. * Manages an XRSession to work with Babylon's engine
  42280. * @see https://doc.babylonjs.com/how_to/webxr
  42281. */
  42282. export class WebXRSessionManager implements IDisposable {
  42283. /** The scene which the session should be created for */
  42284. scene: Scene;
  42285. /**
  42286. * Fires every time a new xrFrame arrives which can be used to update the camera
  42287. */
  42288. onXRFrameObservable: Observable<XRFrame>;
  42289. /**
  42290. * Fires when the xr session is ended either by the device or manually done
  42291. */
  42292. onXRSessionEnded: Observable<any>;
  42293. /**
  42294. * Fires when the xr session is ended either by the device or manually done
  42295. */
  42296. onXRSessionInit: Observable<XRSession>;
  42297. /**
  42298. * Underlying xr session
  42299. */
  42300. session: XRSession;
  42301. /**
  42302. * Type of reference space used when creating the session
  42303. */
  42304. referenceSpace: XRReferenceSpace;
  42305. /**
  42306. * Current XR frame
  42307. */
  42308. currentFrame: Nullable<XRFrame>;
  42309. /** WebXR timestamp updated every frame */
  42310. currentTimestamp: number;
  42311. private _xrNavigator;
  42312. private baseLayer;
  42313. private _rttProvider;
  42314. private _sessionEnded;
  42315. /**
  42316. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42317. * @param scene The scene which the session should be created for
  42318. */
  42319. constructor(
  42320. /** The scene which the session should be created for */
  42321. scene: Scene);
  42322. /**
  42323. * Initializes the manager
  42324. * After initialization enterXR can be called to start an XR session
  42325. * @returns Promise which resolves after it is initialized
  42326. */
  42327. initializeAsync(): Promise<void>;
  42328. /**
  42329. * Initializes an xr session
  42330. * @param xrSessionMode mode to initialize
  42331. * @param optionalFeatures defines optional values to pass to the session builder
  42332. * @returns a promise which will resolve once the session has been initialized
  42333. */
  42334. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42335. /**
  42336. * Sets the reference space on the xr session
  42337. * @param referenceSpace space to set
  42338. * @returns a promise that will resolve once the reference space has been set
  42339. */
  42340. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42341. /**
  42342. * Updates the render state of the session
  42343. * @param state state to set
  42344. * @returns a promise that resolves once the render state has been updated
  42345. */
  42346. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42347. /**
  42348. * Starts rendering to the xr layer
  42349. * @returns a promise that will resolve once rendering has started
  42350. */
  42351. startRenderingToXRAsync(): Promise<void>;
  42352. /**
  42353. * Gets the correct render target texture to be rendered this frame for this eye
  42354. * @param eye the eye for which to get the render target
  42355. * @returns the render target for the specified eye
  42356. */
  42357. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42358. /**
  42359. * Stops the xrSession and restores the renderloop
  42360. * @returns Promise which resolves after it exits XR
  42361. */
  42362. exitXRAsync(): Promise<void>;
  42363. /**
  42364. * Checks if a session would be supported for the creation options specified
  42365. * @param sessionMode session mode to check if supported eg. immersive-vr
  42366. * @returns true if supported
  42367. */
  42368. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42369. /**
  42370. * Creates a WebXRRenderTarget object for the XR session
  42371. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42372. * @param options optional options to provide when creating a new render target
  42373. * @returns a WebXR render target to which the session can render
  42374. */
  42375. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42376. /**
  42377. * @hidden
  42378. * Converts the render layer of xrSession to a render target
  42379. * @param session session to create render target for
  42380. * @param scene scene the new render target should be created for
  42381. * @param baseLayer the webgl layer to create the render target for
  42382. */
  42383. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42384. /**
  42385. * Disposes of the session manager
  42386. */
  42387. dispose(): void;
  42388. /**
  42389. * Gets a promise returning true when fullfiled if the given session mode is supported
  42390. * @param sessionMode defines the session to test
  42391. * @returns a promise
  42392. */
  42393. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * WebXR Camera which holds the views for the xrSession
  42399. * @see https://doc.babylonjs.com/how_to/webxr
  42400. */
  42401. export class WebXRCamera extends FreeCamera {
  42402. /**
  42403. * Is the camera in debug mode. Used when using an emulator
  42404. */
  42405. debugMode: boolean;
  42406. /**
  42407. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42408. * @param name the name of the camera
  42409. * @param scene the scene to add the camera to
  42410. */
  42411. constructor(name: string, scene: Scene);
  42412. private _updateNumberOfRigCameras;
  42413. /** @hidden */
  42414. _updateForDualEyeDebugging(): void;
  42415. /**
  42416. * Updates the cameras position from the current pose information of the XR session
  42417. * @param xrSessionManager the session containing pose information
  42418. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42419. */
  42420. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42421. }
  42422. }
  42423. declare module BABYLON {
  42424. /**
  42425. * Defining the interface required for a (webxr) feature
  42426. */
  42427. export interface IWebXRFeature extends IDisposable {
  42428. /**
  42429. * Attach the feature to the session
  42430. * Will usually be called by the features manager
  42431. *
  42432. * @returns true if successful.
  42433. */
  42434. attach(): boolean;
  42435. /**
  42436. * Detach the feature from the session
  42437. * Will usually be called by the features manager
  42438. *
  42439. * @returns true if successful.
  42440. */
  42441. detach(): boolean;
  42442. }
  42443. /**
  42444. * Defining the constructor of a feature. Used to register the modules.
  42445. */
  42446. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42447. /**
  42448. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42449. * It is mainly used in AR sessions.
  42450. *
  42451. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42452. */
  42453. export class WebXRFeaturesManager implements IDisposable {
  42454. private _xrSessionManager;
  42455. private static readonly _AvailableFeatures;
  42456. /**
  42457. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42458. * Mainly used internally.
  42459. *
  42460. * @param featureName the name of the feature to register
  42461. * @param constructorFunction the function used to construct the module
  42462. * @param version the (babylon) version of the module
  42463. * @param stable is that a stable version of this module
  42464. */
  42465. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42466. /**
  42467. * Returns a constructor of a specific feature.
  42468. *
  42469. * @param featureName the name of the feature to construct
  42470. * @param version the version of the feature to load
  42471. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42472. * @param options optional options provided to the module.
  42473. * @returns a function that, when called, will return a new instance of this feature
  42474. */
  42475. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42476. /**
  42477. * Return the latest unstable version of this feature
  42478. * @param featureName the name of the feature to search
  42479. * @returns the version number. if not found will return -1
  42480. */
  42481. static GetLatestVersionOfFeature(featureName: string): number;
  42482. /**
  42483. * Return the latest stable version of this feature
  42484. * @param featureName the name of the feature to search
  42485. * @returns the version number. if not found will return -1
  42486. */
  42487. static GetStableVersionOfFeature(featureName: string): number;
  42488. /**
  42489. * Can be used to return the list of features currently registered
  42490. *
  42491. * @returns an Array of available features
  42492. */
  42493. static GetAvailableFeatures(): string[];
  42494. /**
  42495. * Gets the versions available for a specific feature
  42496. * @param featureName the name of the feature
  42497. * @returns an array with the available versions
  42498. */
  42499. static GetAvailableVersions(featureName: string): string[];
  42500. private _features;
  42501. /**
  42502. * constructs a new features manages.
  42503. *
  42504. * @param _xrSessionManager an instance of WebXRSessionManager
  42505. */
  42506. constructor(_xrSessionManager: WebXRSessionManager);
  42507. /**
  42508. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  42509. *
  42510. * @param featureName the name of the feature to load or the class of the feature
  42511. * @param version optional version to load. if not provided the latest version will be enabled
  42512. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42513. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42514. * @returns a new constructed feature or throws an error if feature not found.
  42515. */
  42516. enableFeature(featureName: string | {
  42517. Name: string;
  42518. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42519. /**
  42520. * Used to disable an already-enabled feature
  42521. * @param featureName the feature to disable
  42522. * @returns true if disable was successful
  42523. */
  42524. disableFeature(featureName: string | {
  42525. Name: string;
  42526. }): boolean;
  42527. /**
  42528. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42529. * Can be used during a session to start a feature
  42530. * @param featureName the name of feature to attach
  42531. */
  42532. attachFeature(featureName: string): void;
  42533. /**
  42534. * Can be used inside a session or when the session ends to detach a specific feature
  42535. * @param featureName the name of the feature to detach
  42536. */
  42537. detachFeature(featureName: string): void;
  42538. /**
  42539. * Get the list of enabled features
  42540. * @returns an array of enabled features
  42541. */
  42542. getEnabledFeatures(): string[];
  42543. /**
  42544. * get the implementation of an enabled feature.
  42545. * @param featureName the name of the feature to load
  42546. * @returns the feature class, if found
  42547. */
  42548. getEnabledFeature(featureName: string): IWebXRFeature;
  42549. /**
  42550. * dispose this features manager
  42551. */
  42552. dispose(): void;
  42553. }
  42554. }
  42555. declare module BABYLON {
  42556. /**
  42557. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42558. * @see https://doc.babylonjs.com/how_to/webxr
  42559. */
  42560. export class WebXRExperienceHelper implements IDisposable {
  42561. private scene;
  42562. /**
  42563. * 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
  42564. */
  42565. container: AbstractMesh;
  42566. /**
  42567. * Camera used to render xr content
  42568. */
  42569. camera: WebXRCamera;
  42570. /**
  42571. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42572. */
  42573. state: WebXRState;
  42574. private _setState;
  42575. private static _TmpVector;
  42576. /**
  42577. * Fires when the state of the experience helper has changed
  42578. */
  42579. onStateChangedObservable: Observable<WebXRState>;
  42580. /** Session manager used to keep track of xr session */
  42581. sessionManager: WebXRSessionManager;
  42582. /** A features manager for this xr session */
  42583. featuresManager: WebXRFeaturesManager;
  42584. private _nonVRCamera;
  42585. private _originalSceneAutoClear;
  42586. private _supported;
  42587. /**
  42588. * Creates the experience helper
  42589. * @param scene the scene to attach the experience helper to
  42590. * @returns a promise for the experience helper
  42591. */
  42592. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42593. /**
  42594. * Creates a WebXRExperienceHelper
  42595. * @param scene The scene the helper should be created in
  42596. */
  42597. private constructor();
  42598. /**
  42599. * Exits XR mode and returns the scene to its original state
  42600. * @returns promise that resolves after xr mode has exited
  42601. */
  42602. exitXRAsync(): Promise<void>;
  42603. /**
  42604. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42605. * @param sessionMode options for the XR session
  42606. * @param referenceSpaceType frame of reference of the XR session
  42607. * @param renderTarget the output canvas that will be used to enter XR mode
  42608. * @returns promise that resolves after xr mode has entered
  42609. */
  42610. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42611. /**
  42612. * Updates the global position of the camera by moving the camera's container
  42613. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42614. * @param position The desired global position of the camera
  42615. */
  42616. setPositionOfCameraUsingContainer(position: Vector3): void;
  42617. /**
  42618. * Rotates the xr camera by rotating the camera's container around the camera's position
  42619. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42620. * @param rotation the desired quaternion rotation to apply to the camera
  42621. */
  42622. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42623. /**
  42624. * Disposes of the experience helper
  42625. */
  42626. dispose(): void;
  42627. }
  42628. }
  42629. declare module BABYLON {
  42630. /**
  42631. * Represents an XR input
  42632. */
  42633. export class WebXRController {
  42634. private scene;
  42635. /** The underlying input source for the controller */
  42636. inputSource: XRInputSource;
  42637. private parentContainer;
  42638. /**
  42639. * 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
  42640. */
  42641. grip?: AbstractMesh;
  42642. /**
  42643. * Pointer which can be used to select objects or attach a visible laser to
  42644. */
  42645. pointer: AbstractMesh;
  42646. private _gamepadMode;
  42647. /**
  42648. * If available, this is the gamepad object related to this controller.
  42649. * Using this object it is possible to get click events and trackpad changes of the
  42650. * webxr controller that is currently being used.
  42651. */
  42652. gamepadController?: WebVRController;
  42653. /**
  42654. * Event that fires when the controller is removed/disposed
  42655. */
  42656. onDisposeObservable: Observable<{}>;
  42657. private _tmpQuaternion;
  42658. private _tmpVector;
  42659. /**
  42660. * Creates the controller
  42661. * @see https://doc.babylonjs.com/how_to/webxr
  42662. * @param scene the scene which the controller should be associated to
  42663. * @param inputSource the underlying input source for the controller
  42664. * @param parentContainer parent that the controller meshes should be children of
  42665. */
  42666. constructor(scene: Scene,
  42667. /** The underlying input source for the controller */
  42668. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42669. /**
  42670. * Updates the controller pose based on the given XRFrame
  42671. * @param xrFrame xr frame to update the pose with
  42672. * @param referenceSpace reference space to use
  42673. */
  42674. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42675. /**
  42676. * Gets a world space ray coming from the controller
  42677. * @param result the resulting ray
  42678. */
  42679. getWorldPointerRayToRef(result: Ray): void;
  42680. /**
  42681. * Get the scene associated with this controller
  42682. * @returns the scene object
  42683. */
  42684. getScene(): Scene;
  42685. /**
  42686. * Disposes of the object
  42687. */
  42688. dispose(): void;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * XR input used to track XR inputs such as controllers/rays
  42694. */
  42695. export class WebXRInput implements IDisposable {
  42696. /**
  42697. * Base experience the input listens to
  42698. */
  42699. baseExperience: WebXRExperienceHelper;
  42700. /**
  42701. * XR controllers being tracked
  42702. */
  42703. controllers: Array<WebXRController>;
  42704. private _frameObserver;
  42705. private _stateObserver;
  42706. /**
  42707. * Event when a controller has been connected/added
  42708. */
  42709. onControllerAddedObservable: Observable<WebXRController>;
  42710. /**
  42711. * Event when a controller has been removed/disconnected
  42712. */
  42713. onControllerRemovedObservable: Observable<WebXRController>;
  42714. /**
  42715. * Initializes the WebXRInput
  42716. * @param baseExperience experience helper which the input should be created for
  42717. */
  42718. constructor(
  42719. /**
  42720. * Base experience the input listens to
  42721. */
  42722. baseExperience: WebXRExperienceHelper);
  42723. private _onInputSourcesChange;
  42724. private _addAndRemoveControllers;
  42725. /**
  42726. * Disposes of the object
  42727. */
  42728. dispose(): void;
  42729. }
  42730. }
  42731. declare module BABYLON {
  42732. /**
  42733. * Class used to represent data loading progression
  42734. */
  42735. export class SceneLoaderProgressEvent {
  42736. /** defines if data length to load can be evaluated */
  42737. readonly lengthComputable: boolean;
  42738. /** defines the loaded data length */
  42739. readonly loaded: number;
  42740. /** defines the data length to load */
  42741. readonly total: number;
  42742. /**
  42743. * Create a new progress event
  42744. * @param lengthComputable defines if data length to load can be evaluated
  42745. * @param loaded defines the loaded data length
  42746. * @param total defines the data length to load
  42747. */
  42748. constructor(
  42749. /** defines if data length to load can be evaluated */
  42750. lengthComputable: boolean,
  42751. /** defines the loaded data length */
  42752. loaded: number,
  42753. /** defines the data length to load */
  42754. total: number);
  42755. /**
  42756. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42757. * @param event defines the source event
  42758. * @returns a new SceneLoaderProgressEvent
  42759. */
  42760. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42761. }
  42762. /**
  42763. * Interface used by SceneLoader plugins to define supported file extensions
  42764. */
  42765. export interface ISceneLoaderPluginExtensions {
  42766. /**
  42767. * Defines the list of supported extensions
  42768. */
  42769. [extension: string]: {
  42770. isBinary: boolean;
  42771. };
  42772. }
  42773. /**
  42774. * Interface used by SceneLoader plugin factory
  42775. */
  42776. export interface ISceneLoaderPluginFactory {
  42777. /**
  42778. * Defines the name of the factory
  42779. */
  42780. name: string;
  42781. /**
  42782. * Function called to create a new plugin
  42783. * @return the new plugin
  42784. */
  42785. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42786. /**
  42787. * The callback that returns true if the data can be directly loaded.
  42788. * @param data string containing the file data
  42789. * @returns if the data can be loaded directly
  42790. */
  42791. canDirectLoad?(data: string): boolean;
  42792. }
  42793. /**
  42794. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42795. */
  42796. export interface ISceneLoaderPluginBase {
  42797. /**
  42798. * The friendly name of this plugin.
  42799. */
  42800. name: string;
  42801. /**
  42802. * The file extensions supported by this plugin.
  42803. */
  42804. extensions: string | ISceneLoaderPluginExtensions;
  42805. /**
  42806. * The callback called when loading from a url.
  42807. * @param scene scene loading this url
  42808. * @param url url to load
  42809. * @param onSuccess callback called when the file successfully loads
  42810. * @param onProgress callback called while file is loading (if the server supports this mode)
  42811. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42812. * @param onError callback called when the file fails to load
  42813. * @returns a file request object
  42814. */
  42815. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42816. /**
  42817. * The callback called when loading from a file object.
  42818. * @param scene scene loading this file
  42819. * @param file defines the file to load
  42820. * @param onSuccess defines the callback to call when data is loaded
  42821. * @param onProgress defines the callback to call during loading process
  42822. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42823. * @param onError defines the callback to call when an error occurs
  42824. * @returns a file request object
  42825. */
  42826. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42827. /**
  42828. * The callback that returns true if the data can be directly loaded.
  42829. * @param data string containing the file data
  42830. * @returns if the data can be loaded directly
  42831. */
  42832. canDirectLoad?(data: string): boolean;
  42833. /**
  42834. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42835. * @param scene scene loading this data
  42836. * @param data string containing the data
  42837. * @returns data to pass to the plugin
  42838. */
  42839. directLoad?(scene: Scene, data: string): any;
  42840. /**
  42841. * The callback that allows custom handling of the root url based on the response url.
  42842. * @param rootUrl the original root url
  42843. * @param responseURL the response url if available
  42844. * @returns the new root url
  42845. */
  42846. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42847. }
  42848. /**
  42849. * Interface used to define a SceneLoader plugin
  42850. */
  42851. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42852. /**
  42853. * Import meshes into a scene.
  42854. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42855. * @param scene The scene to import into
  42856. * @param data The data to import
  42857. * @param rootUrl The root url for scene and resources
  42858. * @param meshes The meshes array to import into
  42859. * @param particleSystems The particle systems array to import into
  42860. * @param skeletons The skeletons array to import into
  42861. * @param onError The callback when import fails
  42862. * @returns True if successful or false otherwise
  42863. */
  42864. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42865. /**
  42866. * Load into a scene.
  42867. * @param scene The scene to load into
  42868. * @param data The data to import
  42869. * @param rootUrl The root url for scene and resources
  42870. * @param onError The callback when import fails
  42871. * @returns True if successful or false otherwise
  42872. */
  42873. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42874. /**
  42875. * Load into an asset container.
  42876. * @param scene The scene to load into
  42877. * @param data The data to import
  42878. * @param rootUrl The root url for scene and resources
  42879. * @param onError The callback when import fails
  42880. * @returns The loaded asset container
  42881. */
  42882. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42883. }
  42884. /**
  42885. * Interface used to define an async SceneLoader plugin
  42886. */
  42887. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42888. /**
  42889. * Import meshes into a scene.
  42890. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42891. * @param scene The scene to import into
  42892. * @param data The data to import
  42893. * @param rootUrl The root url for scene and resources
  42894. * @param onProgress The callback when the load progresses
  42895. * @param fileName Defines the name of the file to load
  42896. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42897. */
  42898. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42899. meshes: AbstractMesh[];
  42900. particleSystems: IParticleSystem[];
  42901. skeletons: Skeleton[];
  42902. animationGroups: AnimationGroup[];
  42903. }>;
  42904. /**
  42905. * Load into a scene.
  42906. * @param scene The scene to load into
  42907. * @param data The data to import
  42908. * @param rootUrl The root url for scene and resources
  42909. * @param onProgress The callback when the load progresses
  42910. * @param fileName Defines the name of the file to load
  42911. * @returns Nothing
  42912. */
  42913. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42914. /**
  42915. * Load into an asset container.
  42916. * @param scene The scene to load into
  42917. * @param data The data to import
  42918. * @param rootUrl The root url for scene and resources
  42919. * @param onProgress The callback when the load progresses
  42920. * @param fileName Defines the name of the file to load
  42921. * @returns The loaded asset container
  42922. */
  42923. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42924. }
  42925. /**
  42926. * Mode that determines how to handle old animation groups before loading new ones.
  42927. */
  42928. export enum SceneLoaderAnimationGroupLoadingMode {
  42929. /**
  42930. * Reset all old animations to initial state then dispose them.
  42931. */
  42932. Clean = 0,
  42933. /**
  42934. * Stop all old animations.
  42935. */
  42936. Stop = 1,
  42937. /**
  42938. * Restart old animations from first frame.
  42939. */
  42940. Sync = 2,
  42941. /**
  42942. * Old animations remains untouched.
  42943. */
  42944. NoSync = 3
  42945. }
  42946. /**
  42947. * Class used to load scene from various file formats using registered plugins
  42948. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42949. */
  42950. export class SceneLoader {
  42951. /**
  42952. * No logging while loading
  42953. */
  42954. static readonly NO_LOGGING: number;
  42955. /**
  42956. * Minimal logging while loading
  42957. */
  42958. static readonly MINIMAL_LOGGING: number;
  42959. /**
  42960. * Summary logging while loading
  42961. */
  42962. static readonly SUMMARY_LOGGING: number;
  42963. /**
  42964. * Detailled logging while loading
  42965. */
  42966. static readonly DETAILED_LOGGING: number;
  42967. /**
  42968. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42969. */
  42970. static get ForceFullSceneLoadingForIncremental(): boolean;
  42971. static set ForceFullSceneLoadingForIncremental(value: boolean);
  42972. /**
  42973. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42974. */
  42975. static get ShowLoadingScreen(): boolean;
  42976. static set ShowLoadingScreen(value: boolean);
  42977. /**
  42978. * Defines the current logging level (while loading the scene)
  42979. * @ignorenaming
  42980. */
  42981. static get loggingLevel(): number;
  42982. static set loggingLevel(value: number);
  42983. /**
  42984. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42985. */
  42986. static get CleanBoneMatrixWeights(): boolean;
  42987. static set CleanBoneMatrixWeights(value: boolean);
  42988. /**
  42989. * Event raised when a plugin is used to load a scene
  42990. */
  42991. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42992. private static _registeredPlugins;
  42993. private static _getDefaultPlugin;
  42994. private static _getPluginForExtension;
  42995. private static _getPluginForDirectLoad;
  42996. private static _getPluginForFilename;
  42997. private static _getDirectLoad;
  42998. private static _loadData;
  42999. private static _getFileInfo;
  43000. /**
  43001. * Gets a plugin that can load the given extension
  43002. * @param extension defines the extension to load
  43003. * @returns a plugin or null if none works
  43004. */
  43005. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43006. /**
  43007. * Gets a boolean indicating that the given extension can be loaded
  43008. * @param extension defines the extension to load
  43009. * @returns true if the extension is supported
  43010. */
  43011. static IsPluginForExtensionAvailable(extension: string): boolean;
  43012. /**
  43013. * Adds a new plugin to the list of registered plugins
  43014. * @param plugin defines the plugin to add
  43015. */
  43016. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43017. /**
  43018. * Import meshes into a scene
  43019. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43020. * @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)
  43021. * @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)
  43022. * @param scene the instance of BABYLON.Scene to append to
  43023. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43024. * @param onProgress a callback with a progress event for each file being loaded
  43025. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43026. * @param pluginExtension the extension used to determine the plugin
  43027. * @returns The loaded plugin
  43028. */
  43029. 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>;
  43030. /**
  43031. * Import meshes into a scene
  43032. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43033. * @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)
  43034. * @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)
  43035. * @param scene the instance of BABYLON.Scene to append to
  43036. * @param onProgress a callback with a progress event for each file being loaded
  43037. * @param pluginExtension the extension used to determine the plugin
  43038. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43039. */
  43040. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43041. meshes: AbstractMesh[];
  43042. particleSystems: IParticleSystem[];
  43043. skeletons: Skeleton[];
  43044. animationGroups: AnimationGroup[];
  43045. }>;
  43046. /**
  43047. * Load a scene
  43048. * @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)
  43049. * @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)
  43050. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43051. * @param onSuccess a callback with the scene when import succeeds
  43052. * @param onProgress a callback with a progress event for each file being loaded
  43053. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43054. * @param pluginExtension the extension used to determine the plugin
  43055. * @returns The loaded plugin
  43056. */
  43057. 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>;
  43058. /**
  43059. * Load a scene
  43060. * @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)
  43061. * @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)
  43062. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43063. * @param onProgress a callback with a progress event for each file being loaded
  43064. * @param pluginExtension the extension used to determine the plugin
  43065. * @returns The loaded scene
  43066. */
  43067. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43068. /**
  43069. * Append a scene
  43070. * @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)
  43071. * @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)
  43072. * @param scene is the instance of BABYLON.Scene to append to
  43073. * @param onSuccess a callback with the scene when import succeeds
  43074. * @param onProgress a callback with a progress event for each file being loaded
  43075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43076. * @param pluginExtension the extension used to determine the plugin
  43077. * @returns The loaded plugin
  43078. */
  43079. 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>;
  43080. /**
  43081. * Append a scene
  43082. * @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)
  43083. * @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)
  43084. * @param scene is the instance of BABYLON.Scene to append to
  43085. * @param onProgress a callback with a progress event for each file being loaded
  43086. * @param pluginExtension the extension used to determine the plugin
  43087. * @returns The given scene
  43088. */
  43089. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43090. /**
  43091. * Load a scene into an asset container
  43092. * @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)
  43093. * @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)
  43094. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43095. * @param onSuccess a callback with the scene when import succeeds
  43096. * @param onProgress a callback with a progress event for each file being loaded
  43097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43098. * @param pluginExtension the extension used to determine the plugin
  43099. * @returns The loaded plugin
  43100. */
  43101. 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>;
  43102. /**
  43103. * Load a scene into an asset container
  43104. * @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)
  43105. * @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)
  43106. * @param scene is the instance of Scene to append to
  43107. * @param onProgress a callback with a progress event for each file being loaded
  43108. * @param pluginExtension the extension used to determine the plugin
  43109. * @returns The loaded asset container
  43110. */
  43111. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43112. /**
  43113. * Import animations from a file into a scene
  43114. * @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)
  43115. * @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)
  43116. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43117. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43118. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43119. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43120. * @param onSuccess a callback with the scene when import succeeds
  43121. * @param onProgress a callback with a progress event for each file being loaded
  43122. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43123. */
  43124. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43125. /**
  43126. * Import animations from a file into a scene
  43127. * @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)
  43128. * @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)
  43129. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43130. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43131. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43132. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43133. * @param onSuccess a callback with the scene when import succeeds
  43134. * @param onProgress a callback with a progress event for each file being loaded
  43135. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43136. * @returns the updated scene with imported animations
  43137. */
  43138. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43139. }
  43140. }
  43141. declare module BABYLON {
  43142. /**
  43143. * Generic Controller
  43144. */
  43145. export class GenericController extends WebVRController {
  43146. /**
  43147. * Base Url for the controller model.
  43148. */
  43149. static readonly MODEL_BASE_URL: string;
  43150. /**
  43151. * File name for the controller model.
  43152. */
  43153. static readonly MODEL_FILENAME: string;
  43154. /**
  43155. * Creates a new GenericController from a gamepad
  43156. * @param vrGamepad the gamepad that the controller should be created from
  43157. */
  43158. constructor(vrGamepad: any);
  43159. /**
  43160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43161. * @param scene scene in which to add meshes
  43162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43163. */
  43164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43165. /**
  43166. * Called once for each button that changed state since the last frame
  43167. * @param buttonIdx Which button index changed
  43168. * @param state New state of the button
  43169. * @param changes Which properties on the state changed since last frame
  43170. */
  43171. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43172. }
  43173. }
  43174. declare module BABYLON {
  43175. /**
  43176. * Defines the WindowsMotionController object that the state of the windows motion controller
  43177. */
  43178. export class WindowsMotionController extends WebVRController {
  43179. /**
  43180. * The base url used to load the left and right controller models
  43181. */
  43182. static MODEL_BASE_URL: string;
  43183. /**
  43184. * The name of the left controller model file
  43185. */
  43186. static MODEL_LEFT_FILENAME: string;
  43187. /**
  43188. * The name of the right controller model file
  43189. */
  43190. static MODEL_RIGHT_FILENAME: string;
  43191. /**
  43192. * The controller name prefix for this controller type
  43193. */
  43194. static readonly GAMEPAD_ID_PREFIX: string;
  43195. /**
  43196. * The controller id pattern for this controller type
  43197. */
  43198. private static readonly GAMEPAD_ID_PATTERN;
  43199. private _loadedMeshInfo;
  43200. protected readonly _mapping: {
  43201. buttons: string[];
  43202. buttonMeshNames: {
  43203. 'trigger': string;
  43204. 'menu': string;
  43205. 'grip': string;
  43206. 'thumbstick': string;
  43207. 'trackpad': string;
  43208. };
  43209. buttonObservableNames: {
  43210. 'trigger': string;
  43211. 'menu': string;
  43212. 'grip': string;
  43213. 'thumbstick': string;
  43214. 'trackpad': string;
  43215. };
  43216. axisMeshNames: string[];
  43217. pointingPoseMeshName: string;
  43218. };
  43219. /**
  43220. * Fired when the trackpad on this controller is clicked
  43221. */
  43222. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43223. /**
  43224. * Fired when the trackpad on this controller is modified
  43225. */
  43226. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43227. /**
  43228. * The current x and y values of this controller's trackpad
  43229. */
  43230. trackpad: StickValues;
  43231. /**
  43232. * Creates a new WindowsMotionController from a gamepad
  43233. * @param vrGamepad the gamepad that the controller should be created from
  43234. */
  43235. constructor(vrGamepad: any);
  43236. /**
  43237. * Fired when the trigger on this controller is modified
  43238. */
  43239. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43240. /**
  43241. * Fired when the menu button on this controller is modified
  43242. */
  43243. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43244. /**
  43245. * Fired when the grip button on this controller is modified
  43246. */
  43247. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43248. /**
  43249. * Fired when the thumbstick button on this controller is modified
  43250. */
  43251. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43252. /**
  43253. * Fired when the touchpad button on this controller is modified
  43254. */
  43255. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43256. /**
  43257. * Fired when the touchpad values on this controller are modified
  43258. */
  43259. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43260. protected _updateTrackpad(): void;
  43261. /**
  43262. * Called once per frame by the engine.
  43263. */
  43264. update(): void;
  43265. /**
  43266. * Called once for each button that changed state since the last frame
  43267. * @param buttonIdx Which button index changed
  43268. * @param state New state of the button
  43269. * @param changes Which properties on the state changed since last frame
  43270. */
  43271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43272. /**
  43273. * Moves the buttons on the controller mesh based on their current state
  43274. * @param buttonName the name of the button to move
  43275. * @param buttonValue the value of the button which determines the buttons new position
  43276. */
  43277. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43278. /**
  43279. * Moves the axis on the controller mesh based on its current state
  43280. * @param axis the index of the axis
  43281. * @param axisValue the value of the axis which determines the meshes new position
  43282. * @hidden
  43283. */
  43284. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43285. /**
  43286. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43287. * @param scene scene in which to add meshes
  43288. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43289. */
  43290. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43291. /**
  43292. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43293. * can be transformed by button presses and axes values, based on this._mapping.
  43294. *
  43295. * @param scene scene in which the meshes exist
  43296. * @param meshes list of meshes that make up the controller model to process
  43297. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43298. */
  43299. private processModel;
  43300. private createMeshInfo;
  43301. /**
  43302. * Gets the ray of the controller in the direction the controller is pointing
  43303. * @param length the length the resulting ray should be
  43304. * @returns a ray in the direction the controller is pointing
  43305. */
  43306. getForwardRay(length?: number): Ray;
  43307. /**
  43308. * Disposes of the controller
  43309. */
  43310. dispose(): void;
  43311. }
  43312. /**
  43313. * This class represents a new windows motion controller in XR.
  43314. */
  43315. export class XRWindowsMotionController extends WindowsMotionController {
  43316. /**
  43317. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43318. */
  43319. protected readonly _mapping: {
  43320. buttons: string[];
  43321. buttonMeshNames: {
  43322. 'trigger': string;
  43323. 'menu': string;
  43324. 'grip': string;
  43325. 'thumbstick': string;
  43326. 'trackpad': string;
  43327. };
  43328. buttonObservableNames: {
  43329. 'trigger': string;
  43330. 'menu': string;
  43331. 'grip': string;
  43332. 'thumbstick': string;
  43333. 'trackpad': string;
  43334. };
  43335. axisMeshNames: string[];
  43336. pointingPoseMeshName: string;
  43337. };
  43338. /**
  43339. * Construct a new XR-Based windows motion controller
  43340. *
  43341. * @param gamepadInfo the gamepad object from the browser
  43342. */
  43343. constructor(gamepadInfo: any);
  43344. /**
  43345. * holds the thumbstick values (X,Y)
  43346. */
  43347. thumbstickValues: StickValues;
  43348. /**
  43349. * Fired when the thumbstick on this controller is clicked
  43350. */
  43351. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43352. /**
  43353. * Fired when the thumbstick on this controller is modified
  43354. */
  43355. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43356. /**
  43357. * Fired when the touchpad button on this controller is modified
  43358. */
  43359. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43360. /**
  43361. * Fired when the touchpad values on this controller are modified
  43362. */
  43363. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43364. /**
  43365. * Fired when the thumbstick button on this controller is modified
  43366. * here to prevent breaking changes
  43367. */
  43368. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43369. /**
  43370. * updating the thumbstick(!) and not the trackpad.
  43371. * This is named this way due to the difference between WebVR and XR and to avoid
  43372. * changing the parent class.
  43373. */
  43374. protected _updateTrackpad(): void;
  43375. /**
  43376. * Disposes the class with joy
  43377. */
  43378. dispose(): void;
  43379. }
  43380. }
  43381. declare module BABYLON {
  43382. /**
  43383. * Oculus Touch Controller
  43384. */
  43385. export class OculusTouchController extends WebVRController {
  43386. /**
  43387. * Base Url for the controller model.
  43388. */
  43389. static MODEL_BASE_URL: string;
  43390. /**
  43391. * File name for the left controller model.
  43392. */
  43393. static MODEL_LEFT_FILENAME: string;
  43394. /**
  43395. * File name for the right controller model.
  43396. */
  43397. static MODEL_RIGHT_FILENAME: string;
  43398. /**
  43399. * Base Url for the Quest controller model.
  43400. */
  43401. static QUEST_MODEL_BASE_URL: string;
  43402. /**
  43403. * @hidden
  43404. * If the controllers are running on a device that needs the updated Quest controller models
  43405. */
  43406. static _IsQuest: boolean;
  43407. /**
  43408. * Fired when the secondary trigger on this controller is modified
  43409. */
  43410. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43411. /**
  43412. * Fired when the thumb rest on this controller is modified
  43413. */
  43414. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43415. /**
  43416. * Creates a new OculusTouchController from a gamepad
  43417. * @param vrGamepad the gamepad that the controller should be created from
  43418. */
  43419. constructor(vrGamepad: any);
  43420. /**
  43421. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43422. * @param scene scene in which to add meshes
  43423. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43424. */
  43425. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43426. /**
  43427. * Fired when the A button on this controller is modified
  43428. */
  43429. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43430. /**
  43431. * Fired when the B button on this controller is modified
  43432. */
  43433. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43434. /**
  43435. * Fired when the X button on this controller is modified
  43436. */
  43437. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43438. /**
  43439. * Fired when the Y button on this controller is modified
  43440. */
  43441. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43442. /**
  43443. * Called once for each button that changed state since the last frame
  43444. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43445. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43446. * 2) secondary trigger (same)
  43447. * 3) A (right) X (left), touch, pressed = value
  43448. * 4) B / Y
  43449. * 5) thumb rest
  43450. * @param buttonIdx Which button index changed
  43451. * @param state New state of the button
  43452. * @param changes Which properties on the state changed since last frame
  43453. */
  43454. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43455. }
  43456. }
  43457. declare module BABYLON {
  43458. /**
  43459. * Vive Controller
  43460. */
  43461. export class ViveController extends WebVRController {
  43462. /**
  43463. * Base Url for the controller model.
  43464. */
  43465. static MODEL_BASE_URL: string;
  43466. /**
  43467. * File name for the controller model.
  43468. */
  43469. static MODEL_FILENAME: string;
  43470. /**
  43471. * Creates a new ViveController from a gamepad
  43472. * @param vrGamepad the gamepad that the controller should be created from
  43473. */
  43474. constructor(vrGamepad: any);
  43475. /**
  43476. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43477. * @param scene scene in which to add meshes
  43478. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43479. */
  43480. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43481. /**
  43482. * Fired when the left button on this controller is modified
  43483. */
  43484. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43485. /**
  43486. * Fired when the right button on this controller is modified
  43487. */
  43488. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43489. /**
  43490. * Fired when the menu button on this controller is modified
  43491. */
  43492. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43493. /**
  43494. * Called once for each button that changed state since the last frame
  43495. * Vive mapping:
  43496. * 0: touchpad
  43497. * 1: trigger
  43498. * 2: left AND right buttons
  43499. * 3: menu button
  43500. * @param buttonIdx Which button index changed
  43501. * @param state New state of the button
  43502. * @param changes Which properties on the state changed since last frame
  43503. */
  43504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43505. }
  43506. }
  43507. declare module BABYLON {
  43508. /**
  43509. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43510. */
  43511. export class WebXRControllerModelLoader {
  43512. /**
  43513. * an observable that triggers when a new model (the mesh itself) was initialized.
  43514. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43515. */
  43516. onControllerModelLoaded: Observable<WebXRController>;
  43517. /**
  43518. * Creates the WebXRControllerModelLoader
  43519. * @param input xr input that creates the controllers
  43520. */
  43521. constructor(input: WebXRInput);
  43522. }
  43523. }
  43524. declare module BABYLON {
  43525. /**
  43526. * Handles pointer input automatically for the pointer of XR controllers
  43527. */
  43528. export class WebXRControllerPointerSelection {
  43529. private static _idCounter;
  43530. private _tmpRay;
  43531. /**
  43532. * Creates a WebXRControllerPointerSelection
  43533. * @param input input manager to setup pointer selection
  43534. */
  43535. constructor(input: WebXRInput);
  43536. private _convertNormalToDirectionOfRay;
  43537. private _updatePointerDistance;
  43538. }
  43539. }
  43540. declare module BABYLON {
  43541. /**
  43542. * Enables teleportation
  43543. */
  43544. export class WebXRControllerTeleportation {
  43545. private _teleportationFillColor;
  43546. private _teleportationBorderColor;
  43547. private _tmpRay;
  43548. private _tmpVector;
  43549. /**
  43550. * when set to true (default) teleportation will wait for thumbstick changes.
  43551. * When set to false teleportation will be disabled.
  43552. *
  43553. * If set to false while teleporting results can be unexpected.
  43554. */
  43555. enabled: boolean;
  43556. /**
  43557. * Creates a WebXRControllerTeleportation
  43558. * @param input input manager to add teleportation to
  43559. * @param floorMeshes floormeshes which can be teleported to
  43560. */
  43561. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43562. }
  43563. }
  43564. declare module BABYLON {
  43565. /**
  43566. * Button which can be used to enter a different mode of XR
  43567. */
  43568. export class WebXREnterExitUIButton {
  43569. /** button element */
  43570. element: HTMLElement;
  43571. /** XR initialization options for the button */
  43572. sessionMode: XRSessionMode;
  43573. /** Reference space type */
  43574. referenceSpaceType: XRReferenceSpaceType;
  43575. /**
  43576. * Creates a WebXREnterExitUIButton
  43577. * @param element button element
  43578. * @param sessionMode XR initialization session mode
  43579. * @param referenceSpaceType the type of reference space to be used
  43580. */
  43581. constructor(
  43582. /** button element */
  43583. element: HTMLElement,
  43584. /** XR initialization options for the button */
  43585. sessionMode: XRSessionMode,
  43586. /** Reference space type */
  43587. referenceSpaceType: XRReferenceSpaceType);
  43588. /**
  43589. * Overwritable function which can be used to update the button's visuals when the state changes
  43590. * @param activeButton the current active button in the UI
  43591. */
  43592. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43593. }
  43594. /**
  43595. * Options to create the webXR UI
  43596. */
  43597. export class WebXREnterExitUIOptions {
  43598. /**
  43599. * Context to enter xr with
  43600. */
  43601. renderTarget?: Nullable<WebXRRenderTarget>;
  43602. /**
  43603. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43604. */
  43605. customButtons?: Array<WebXREnterExitUIButton>;
  43606. /**
  43607. * A session mode to use when creating the default button.
  43608. * Default is immersive-vr
  43609. */
  43610. sessionMode?: XRSessionMode;
  43611. /**
  43612. * A reference space type to use when creating the default button.
  43613. * Default is local-floor
  43614. */
  43615. referenceSpaceType?: XRReferenceSpaceType;
  43616. }
  43617. /**
  43618. * UI to allow the user to enter/exit XR mode
  43619. */
  43620. export class WebXREnterExitUI implements IDisposable {
  43621. private scene;
  43622. /** version of the options passed to this UI */
  43623. options: WebXREnterExitUIOptions;
  43624. private _overlay;
  43625. private _buttons;
  43626. private _activeButton;
  43627. /**
  43628. * Fired every time the active button is changed.
  43629. *
  43630. * When xr is entered via a button that launches xr that button will be the callback parameter
  43631. *
  43632. * When exiting xr the callback parameter will be null)
  43633. */
  43634. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43635. /**
  43636. * Creates UI to allow the user to enter/exit XR mode
  43637. * @param scene the scene to add the ui to
  43638. * @param helper the xr experience helper to enter/exit xr with
  43639. * @param options options to configure the UI
  43640. * @returns the created ui
  43641. */
  43642. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43643. /**
  43644. *
  43645. * @param scene babylon scene object to use
  43646. * @param options (read-only) version of the options passed to this UI
  43647. */
  43648. private constructor();
  43649. private _updateButtons;
  43650. /**
  43651. * Disposes of the object
  43652. */
  43653. dispose(): void;
  43654. }
  43655. }
  43656. declare module BABYLON {
  43657. /**
  43658. * Options for the default xr helper
  43659. */
  43660. export class WebXRDefaultExperienceOptions {
  43661. /**
  43662. * Floor meshes that should be used for teleporting
  43663. */
  43664. floorMeshes: Array<AbstractMesh>;
  43665. /**
  43666. * Enable or disable default UI to enter XR
  43667. */
  43668. disableDefaultUI?: boolean;
  43669. /**
  43670. * optional configuration for the output canvas
  43671. */
  43672. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43673. /**
  43674. * optional UI options. This can be used among other to change session mode and reference space type
  43675. */
  43676. uiOptions?: WebXREnterExitUIOptions;
  43677. }
  43678. /**
  43679. * Default experience which provides a similar setup to the previous webVRExperience
  43680. */
  43681. export class WebXRDefaultExperience {
  43682. /**
  43683. * Base experience
  43684. */
  43685. baseExperience: WebXRExperienceHelper;
  43686. /**
  43687. * Input experience extension
  43688. */
  43689. input: WebXRInput;
  43690. /**
  43691. * Loads the controller models
  43692. */
  43693. controllerModelLoader: WebXRControllerModelLoader;
  43694. /**
  43695. * Enables laser pointer and selection
  43696. */
  43697. pointerSelection: WebXRControllerPointerSelection;
  43698. /**
  43699. * Enables teleportation
  43700. */
  43701. teleportation: WebXRControllerTeleportation;
  43702. /**
  43703. * Enables ui for entering/exiting xr
  43704. */
  43705. enterExitUI: WebXREnterExitUI;
  43706. /**
  43707. * Default target xr should render to
  43708. */
  43709. renderTarget: WebXRRenderTarget;
  43710. /**
  43711. * Creates the default xr experience
  43712. * @param scene scene
  43713. * @param options options for basic configuration
  43714. * @returns resulting WebXRDefaultExperience
  43715. */
  43716. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43717. private constructor();
  43718. /**
  43719. * DIsposes of the experience helper
  43720. */
  43721. dispose(): void;
  43722. }
  43723. }
  43724. declare module BABYLON {
  43725. /**
  43726. * Options to modify the vr teleportation behavior.
  43727. */
  43728. export interface VRTeleportationOptions {
  43729. /**
  43730. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43731. */
  43732. floorMeshName?: string;
  43733. /**
  43734. * A list of meshes to be used as the teleportation floor. (default: empty)
  43735. */
  43736. floorMeshes?: Mesh[];
  43737. /**
  43738. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43739. */
  43740. teleportationMode?: number;
  43741. /**
  43742. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43743. */
  43744. teleportationTime?: number;
  43745. /**
  43746. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43747. */
  43748. teleportationSpeed?: number;
  43749. /**
  43750. * The easing function used in the animation or null for Linear. (default CircleEase)
  43751. */
  43752. easingFunction?: EasingFunction;
  43753. }
  43754. /**
  43755. * Options to modify the vr experience helper's behavior.
  43756. */
  43757. export interface VRExperienceHelperOptions extends WebVROptions {
  43758. /**
  43759. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43760. */
  43761. createDeviceOrientationCamera?: boolean;
  43762. /**
  43763. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43764. */
  43765. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43766. /**
  43767. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43768. */
  43769. laserToggle?: boolean;
  43770. /**
  43771. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43772. */
  43773. floorMeshes?: Mesh[];
  43774. /**
  43775. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43776. */
  43777. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43778. /**
  43779. * Defines if WebXR should be used instead of WebVR (if available)
  43780. */
  43781. useXR?: boolean;
  43782. }
  43783. /**
  43784. * Event containing information after VR has been entered
  43785. */
  43786. export class OnAfterEnteringVRObservableEvent {
  43787. /**
  43788. * If entering vr was successful
  43789. */
  43790. success: boolean;
  43791. }
  43792. /**
  43793. * Helps to quickly add VR support to an existing scene.
  43794. * See http://doc.babylonjs.com/how_to/webvr_helper
  43795. */
  43796. export class VRExperienceHelper {
  43797. /** Options to modify the vr experience helper's behavior. */
  43798. webVROptions: VRExperienceHelperOptions;
  43799. private _scene;
  43800. private _position;
  43801. private _btnVR;
  43802. private _btnVRDisplayed;
  43803. private _webVRsupported;
  43804. private _webVRready;
  43805. private _webVRrequesting;
  43806. private _webVRpresenting;
  43807. private _hasEnteredVR;
  43808. private _fullscreenVRpresenting;
  43809. private _inputElement;
  43810. private _webVRCamera;
  43811. private _vrDeviceOrientationCamera;
  43812. private _deviceOrientationCamera;
  43813. private _existingCamera;
  43814. private _onKeyDown;
  43815. private _onVrDisplayPresentChange;
  43816. private _onVRDisplayChanged;
  43817. private _onVRRequestPresentStart;
  43818. private _onVRRequestPresentComplete;
  43819. /**
  43820. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  43821. */
  43822. enableGazeEvenWhenNoPointerLock: boolean;
  43823. /**
  43824. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43825. */
  43826. exitVROnDoubleTap: boolean;
  43827. /**
  43828. * Observable raised right before entering VR.
  43829. */
  43830. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43831. /**
  43832. * Observable raised when entering VR has completed.
  43833. */
  43834. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43835. /**
  43836. * Observable raised when exiting VR.
  43837. */
  43838. onExitingVRObservable: Observable<VRExperienceHelper>;
  43839. /**
  43840. * Observable raised when controller mesh is loaded.
  43841. */
  43842. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43843. /** Return this.onEnteringVRObservable
  43844. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43845. */
  43846. get onEnteringVR(): Observable<VRExperienceHelper>;
  43847. /** Return this.onExitingVRObservable
  43848. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43849. */
  43850. get onExitingVR(): Observable<VRExperienceHelper>;
  43851. /** Return this.onControllerMeshLoadedObservable
  43852. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43853. */
  43854. get onControllerMeshLoaded(): Observable<WebVRController>;
  43855. private _rayLength;
  43856. private _useCustomVRButton;
  43857. private _teleportationRequested;
  43858. private _teleportActive;
  43859. private _floorMeshName;
  43860. private _floorMeshesCollection;
  43861. private _teleportationMode;
  43862. private _teleportationTime;
  43863. private _teleportationSpeed;
  43864. private _teleportationEasing;
  43865. private _rotationAllowed;
  43866. private _teleportBackwardsVector;
  43867. private _teleportationTarget;
  43868. private _isDefaultTeleportationTarget;
  43869. private _postProcessMove;
  43870. private _teleportationFillColor;
  43871. private _teleportationBorderColor;
  43872. private _rotationAngle;
  43873. private _haloCenter;
  43874. private _cameraGazer;
  43875. private _padSensibilityUp;
  43876. private _padSensibilityDown;
  43877. private _leftController;
  43878. private _rightController;
  43879. /**
  43880. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43881. */
  43882. onNewMeshSelected: Observable<AbstractMesh>;
  43883. /**
  43884. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43885. * This observable will provide the mesh and the controller used to select the mesh
  43886. */
  43887. onMeshSelectedWithController: Observable<{
  43888. mesh: AbstractMesh;
  43889. controller: WebVRController;
  43890. }>;
  43891. /**
  43892. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43893. */
  43894. onNewMeshPicked: Observable<PickingInfo>;
  43895. private _circleEase;
  43896. /**
  43897. * Observable raised before camera teleportation
  43898. */
  43899. onBeforeCameraTeleport: Observable<Vector3>;
  43900. /**
  43901. * Observable raised after camera teleportation
  43902. */
  43903. onAfterCameraTeleport: Observable<Vector3>;
  43904. /**
  43905. * Observable raised when current selected mesh gets unselected
  43906. */
  43907. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43908. private _raySelectionPredicate;
  43909. /**
  43910. * To be optionaly changed by user to define custom ray selection
  43911. */
  43912. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43913. /**
  43914. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43915. */
  43916. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43917. /**
  43918. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43919. */
  43920. teleportationEnabled: boolean;
  43921. private _defaultHeight;
  43922. private _teleportationInitialized;
  43923. private _interactionsEnabled;
  43924. private _interactionsRequested;
  43925. private _displayGaze;
  43926. private _displayLaserPointer;
  43927. /**
  43928. * The mesh used to display where the user is going to teleport.
  43929. */
  43930. get teleportationTarget(): Mesh;
  43931. /**
  43932. * Sets the mesh to be used to display where the user is going to teleport.
  43933. */
  43934. set teleportationTarget(value: Mesh);
  43935. /**
  43936. * 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
  43937. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43938. * See http://doc.babylonjs.com/resources/baking_transformations
  43939. */
  43940. get gazeTrackerMesh(): Mesh;
  43941. set gazeTrackerMesh(value: Mesh);
  43942. /**
  43943. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43944. */
  43945. updateGazeTrackerScale: boolean;
  43946. /**
  43947. * If the gaze trackers color should be updated when selecting meshes
  43948. */
  43949. updateGazeTrackerColor: boolean;
  43950. /**
  43951. * If the controller laser color should be updated when selecting meshes
  43952. */
  43953. updateControllerLaserColor: boolean;
  43954. /**
  43955. * The gaze tracking mesh corresponding to the left controller
  43956. */
  43957. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  43958. /**
  43959. * The gaze tracking mesh corresponding to the right controller
  43960. */
  43961. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  43962. /**
  43963. * If the ray of the gaze should be displayed.
  43964. */
  43965. get displayGaze(): boolean;
  43966. /**
  43967. * Sets if the ray of the gaze should be displayed.
  43968. */
  43969. set displayGaze(value: boolean);
  43970. /**
  43971. * If the ray of the LaserPointer should be displayed.
  43972. */
  43973. get displayLaserPointer(): boolean;
  43974. /**
  43975. * Sets if the ray of the LaserPointer should be displayed.
  43976. */
  43977. set displayLaserPointer(value: boolean);
  43978. /**
  43979. * The deviceOrientationCamera used as the camera when not in VR.
  43980. */
  43981. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  43982. /**
  43983. * Based on the current WebVR support, returns the current VR camera used.
  43984. */
  43985. get currentVRCamera(): Nullable<Camera>;
  43986. /**
  43987. * The webVRCamera which is used when in VR.
  43988. */
  43989. get webVRCamera(): WebVRFreeCamera;
  43990. /**
  43991. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43992. */
  43993. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  43994. /**
  43995. * The html button that is used to trigger entering into VR.
  43996. */
  43997. get vrButton(): Nullable<HTMLButtonElement>;
  43998. private get _teleportationRequestInitiated();
  43999. /**
  44000. * Defines wether or not Pointer lock should be requested when switching to
  44001. * full screen.
  44002. */
  44003. requestPointerLockOnFullScreen: boolean;
  44004. /**
  44005. * If asking to force XR, this will be populated with the default xr experience
  44006. */
  44007. xr: WebXRDefaultExperience;
  44008. /**
  44009. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44010. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44011. */
  44012. xrTestDone: boolean;
  44013. /**
  44014. * Instantiates a VRExperienceHelper.
  44015. * Helps to quickly add VR support to an existing scene.
  44016. * @param scene The scene the VRExperienceHelper belongs to.
  44017. * @param webVROptions Options to modify the vr experience helper's behavior.
  44018. */
  44019. constructor(scene: Scene,
  44020. /** Options to modify the vr experience helper's behavior. */
  44021. webVROptions?: VRExperienceHelperOptions);
  44022. private completeVRInit;
  44023. private _onDefaultMeshLoaded;
  44024. private _onResize;
  44025. private _onFullscreenChange;
  44026. /**
  44027. * Gets a value indicating if we are currently in VR mode.
  44028. */
  44029. get isInVRMode(): boolean;
  44030. private onVrDisplayPresentChange;
  44031. private onVRDisplayChanged;
  44032. private moveButtonToBottomRight;
  44033. private displayVRButton;
  44034. private updateButtonVisibility;
  44035. private _cachedAngularSensibility;
  44036. /**
  44037. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44038. * Otherwise, will use the fullscreen API.
  44039. */
  44040. enterVR(): void;
  44041. /**
  44042. * Attempt to exit VR, or fullscreen.
  44043. */
  44044. exitVR(): void;
  44045. /**
  44046. * The position of the vr experience helper.
  44047. */
  44048. get position(): Vector3;
  44049. /**
  44050. * Sets the position of the vr experience helper.
  44051. */
  44052. set position(value: Vector3);
  44053. /**
  44054. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44055. */
  44056. enableInteractions(): void;
  44057. private get _noControllerIsActive();
  44058. private beforeRender;
  44059. private _isTeleportationFloor;
  44060. /**
  44061. * Adds a floor mesh to be used for teleportation.
  44062. * @param floorMesh the mesh to be used for teleportation.
  44063. */
  44064. addFloorMesh(floorMesh: Mesh): void;
  44065. /**
  44066. * Removes a floor mesh from being used for teleportation.
  44067. * @param floorMesh the mesh to be removed.
  44068. */
  44069. removeFloorMesh(floorMesh: Mesh): void;
  44070. /**
  44071. * Enables interactions and teleportation using the VR controllers and gaze.
  44072. * @param vrTeleportationOptions options to modify teleportation behavior.
  44073. */
  44074. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44075. private _onNewGamepadConnected;
  44076. private _tryEnableInteractionOnController;
  44077. private _onNewGamepadDisconnected;
  44078. private _enableInteractionOnController;
  44079. private _checkTeleportWithRay;
  44080. private _checkRotate;
  44081. private _checkTeleportBackwards;
  44082. private _enableTeleportationOnController;
  44083. private _createTeleportationCircles;
  44084. private _displayTeleportationTarget;
  44085. private _hideTeleportationTarget;
  44086. private _rotateCamera;
  44087. private _moveTeleportationSelectorTo;
  44088. private _workingVector;
  44089. private _workingQuaternion;
  44090. private _workingMatrix;
  44091. /**
  44092. * Time Constant Teleportation Mode
  44093. */
  44094. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44095. /**
  44096. * Speed Constant Teleportation Mode
  44097. */
  44098. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44099. /**
  44100. * Teleports the users feet to the desired location
  44101. * @param location The location where the user's feet should be placed
  44102. */
  44103. teleportCamera(location: Vector3): void;
  44104. private _convertNormalToDirectionOfRay;
  44105. private _castRayAndSelectObject;
  44106. private _notifySelectedMeshUnselected;
  44107. /**
  44108. * Sets the color of the laser ray from the vr controllers.
  44109. * @param color new color for the ray.
  44110. */
  44111. changeLaserColor(color: Color3): void;
  44112. /**
  44113. * Sets the color of the ray from the vr headsets gaze.
  44114. * @param color new color for the ray.
  44115. */
  44116. changeGazeColor(color: Color3): void;
  44117. /**
  44118. * Exits VR and disposes of the vr experience helper
  44119. */
  44120. dispose(): void;
  44121. /**
  44122. * Gets the name of the VRExperienceHelper class
  44123. * @returns "VRExperienceHelper"
  44124. */
  44125. getClassName(): string;
  44126. }
  44127. }
  44128. declare module BABYLON {
  44129. /**
  44130. * Options used for hit testing
  44131. */
  44132. export interface IWebXRHitTestOptions {
  44133. /**
  44134. * Only test when user interacted with the scene. Default - hit test every frame
  44135. */
  44136. testOnPointerDownOnly?: boolean;
  44137. /**
  44138. * The node to use to transform the local results to world coordinates
  44139. */
  44140. worldParentNode?: TransformNode;
  44141. }
  44142. /**
  44143. * Interface defining the babylon result of raycasting/hit-test
  44144. */
  44145. export interface IWebXRHitResult {
  44146. /**
  44147. * The native hit test result
  44148. */
  44149. xrHitResult: XRHitResult;
  44150. /**
  44151. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44152. */
  44153. transformationMatrix: Matrix;
  44154. }
  44155. /**
  44156. * The currently-working hit-test module.
  44157. * Hit test (or raycasting) is used to interact with the real world.
  44158. * For further information read here - https://github.com/immersive-web/hit-test
  44159. */
  44160. export class WebXRHitTestLegacy implements IWebXRFeature {
  44161. private _xrSessionManager;
  44162. /**
  44163. * options to use when constructing this feature
  44164. */
  44165. readonly options: IWebXRHitTestOptions;
  44166. /**
  44167. * The module's name
  44168. */
  44169. static readonly Name: string;
  44170. /**
  44171. * The (Babylon) version of this module.
  44172. * This is an integer representing the implementation version.
  44173. * This number does not correspond to the webxr specs version
  44174. */
  44175. static readonly Version: number;
  44176. /**
  44177. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44178. * @param event the (select) event to use to select with
  44179. * @param referenceSpace the reference space to use for this hit test
  44180. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44181. */
  44182. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44183. /**
  44184. * execute a hit test with an XR Ray
  44185. *
  44186. * @param xrSession a native xrSession that will execute this hit test
  44187. * @param xrRay the ray (position and direction) to use for raycasting
  44188. * @param referenceSpace native XR reference space to use for the hit-test
  44189. * @param filter filter function that will filter the results
  44190. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44191. */
  44192. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44193. /**
  44194. * Triggered when new babylon (transformed) hit test results are available
  44195. */
  44196. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44197. /**
  44198. * Creates a new instance of the (legacy version) hit test feature
  44199. * @param _xrSessionManager an instance of WebXRSessionManager
  44200. * @param options options to use when constructing this feature
  44201. */
  44202. constructor(_xrSessionManager: WebXRSessionManager,
  44203. /**
  44204. * options to use when constructing this feature
  44205. */
  44206. options?: IWebXRHitTestOptions);
  44207. private _onSelectEnabled;
  44208. private _xrFrameObserver;
  44209. private _attached;
  44210. /**
  44211. * Populated with the last native XR Hit Results
  44212. */
  44213. lastNativeXRHitResults: XRHitResult[];
  44214. /**
  44215. * attach this feature
  44216. * Will usually be called by the features manager
  44217. *
  44218. * @returns true if successful.
  44219. */
  44220. attach(): boolean;
  44221. /**
  44222. * detach this feature.
  44223. * Will usually be called by the features manager
  44224. *
  44225. * @returns true if successful.
  44226. */
  44227. detach(): boolean;
  44228. private _onHitTestResults;
  44229. private _onSelect;
  44230. /**
  44231. * Dispose this feature and all of the resources attached
  44232. */
  44233. dispose(): void;
  44234. }
  44235. }
  44236. declare module BABYLON {
  44237. /**
  44238. * Options used in the plane detector module
  44239. */
  44240. export interface IWebXRPlaneDetectorOptions {
  44241. /**
  44242. * The node to use to transform the local results to world coordinates
  44243. */
  44244. worldParentNode?: TransformNode;
  44245. }
  44246. /**
  44247. * A babylon interface for a webxr plane.
  44248. * A Plane is actually a polygon, built from N points in space
  44249. */
  44250. export interface IWebXRPlane {
  44251. /**
  44252. * a babylon-assigned ID for this polygon
  44253. */
  44254. id: number;
  44255. /**
  44256. * the native xr-plane object
  44257. */
  44258. xrPlane: XRPlane;
  44259. /**
  44260. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44261. */
  44262. polygonDefinition: Array<Vector3>;
  44263. /**
  44264. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44265. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44266. */
  44267. transformationMatrix: Matrix;
  44268. }
  44269. /**
  44270. * The plane detector is used to detect planes in the real world when in AR
  44271. * For more information see https://github.com/immersive-web/real-world-geometry/
  44272. */
  44273. export class WebXRPlaneDetector implements IWebXRFeature {
  44274. private _xrSessionManager;
  44275. private _options;
  44276. /**
  44277. * The module's name
  44278. */
  44279. static readonly Name: string;
  44280. /**
  44281. * The (Babylon) version of this module.
  44282. * This is an integer representing the implementation version.
  44283. * This number does not correspond to the webxr specs version
  44284. */
  44285. static readonly Version: number;
  44286. /**
  44287. * Observers registered here will be executed when a new plane was added to the session
  44288. */
  44289. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44290. /**
  44291. * Observers registered here will be executed when a plane is no longer detected in the session
  44292. */
  44293. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44294. /**
  44295. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44296. * This can execute N times every frame
  44297. */
  44298. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44299. private _enabled;
  44300. private _attached;
  44301. private _detectedPlanes;
  44302. private _lastFrameDetected;
  44303. private _observerTracked;
  44304. /**
  44305. * construct a new Plane Detector
  44306. * @param _xrSessionManager an instance of xr Session manager
  44307. * @param _options configuration to use when constructing this feature
  44308. */
  44309. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44310. /**
  44311. * attach this feature
  44312. * Will usually be called by the features manager
  44313. *
  44314. * @returns true if successful.
  44315. */
  44316. attach(): boolean;
  44317. /**
  44318. * detach this feature.
  44319. * Will usually be called by the features manager
  44320. *
  44321. * @returns true if successful.
  44322. */
  44323. detach(): boolean;
  44324. /**
  44325. * Dispose this feature and all of the resources attached
  44326. */
  44327. dispose(): void;
  44328. private _updatePlaneWithXRPlane;
  44329. /**
  44330. * avoiding using Array.find for global support.
  44331. * @param xrPlane the plane to find in the array
  44332. */
  44333. private findIndexInPlaneArray;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * Configuration options of the anchor system
  44339. */
  44340. export interface IWebXRAnchorSystemOptions {
  44341. /**
  44342. * a node that will be used to convert local to world coordinates
  44343. */
  44344. worldParentNode?: TransformNode;
  44345. /**
  44346. * should the anchor system use plane detection.
  44347. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44348. */
  44349. usePlaneDetection?: boolean;
  44350. /**
  44351. * Should a new anchor be added every time a select event is triggered
  44352. */
  44353. addAnchorOnSelect?: boolean;
  44354. }
  44355. /**
  44356. * A babylon container for an XR Anchor
  44357. */
  44358. export interface IWebXRAnchor {
  44359. /**
  44360. * A babylon-assigned ID for this anchor
  44361. */
  44362. id: number;
  44363. /**
  44364. * The native anchor object
  44365. */
  44366. xrAnchor: XRAnchor;
  44367. /**
  44368. * Transformation matrix to apply to an object attached to this anchor
  44369. */
  44370. transformationMatrix: Matrix;
  44371. }
  44372. /**
  44373. * An implementation of the anchor system of WebXR.
  44374. * Note that the current documented implementation is not available in any browser. Future implementations
  44375. * will use the frame to create an anchor and not the session or a detected plane
  44376. * For further information see https://github.com/immersive-web/anchors/
  44377. */
  44378. export class WebXRAnchorSystem implements IWebXRFeature {
  44379. private _xrSessionManager;
  44380. private _options;
  44381. /**
  44382. * The module's name
  44383. */
  44384. static readonly Name: string;
  44385. /**
  44386. * The (Babylon) version of this module.
  44387. * This is an integer representing the implementation version.
  44388. * This number does not correspond to the webxr specs version
  44389. */
  44390. static readonly Version: number;
  44391. /**
  44392. * Observers registered here will be executed when a new anchor was added to the session
  44393. */
  44394. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44395. /**
  44396. * Observers registered here will be executed when an existing anchor updates
  44397. * This can execute N times every frame
  44398. */
  44399. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44400. /**
  44401. * Observers registered here will be executed when an anchor was removed from the session
  44402. */
  44403. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44404. private _planeDetector;
  44405. private _hitTestModule;
  44406. private _enabled;
  44407. private _attached;
  44408. private _trackedAnchors;
  44409. private _lastFrameDetected;
  44410. private _observerTracked;
  44411. /**
  44412. * constructs a new anchor system
  44413. * @param _xrSessionManager an instance of WebXRSessionManager
  44414. * @param _options configuration object for this feature
  44415. */
  44416. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44417. /**
  44418. * set the plane detector to use in order to create anchors from frames
  44419. * @param planeDetector the plane-detector module to use
  44420. * @param enable enable plane-anchors. default is true
  44421. */
  44422. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44423. /**
  44424. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44425. * @param hitTestModule the hit-test module to use.
  44426. */
  44427. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44428. /**
  44429. * attach this feature
  44430. * Will usually be called by the features manager
  44431. *
  44432. * @returns true if successful.
  44433. */
  44434. attach(): boolean;
  44435. /**
  44436. * detach this feature.
  44437. * Will usually be called by the features manager
  44438. *
  44439. * @returns true if successful.
  44440. */
  44441. detach(): boolean;
  44442. /**
  44443. * Dispose this feature and all of the resources attached
  44444. */
  44445. dispose(): void;
  44446. private _onSelect;
  44447. /**
  44448. * Add anchor at a specific XR point.
  44449. *
  44450. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44451. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44452. * @returns a promise the fulfills when the anchor was created
  44453. */
  44454. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44455. private _updateAnchorWithXRFrame;
  44456. /**
  44457. * avoiding using Array.find for global support.
  44458. * @param xrAnchor the plane to find in the array
  44459. */
  44460. private _findIndexInAnchorArray;
  44461. }
  44462. }
  44463. declare module BABYLON {
  44464. /**
  44465. * Options interface for the background remover plugin
  44466. */
  44467. export interface IWebXRBackgroundRemoverOptions {
  44468. /**
  44469. * don't disable the environment helper
  44470. */
  44471. ignoreEnvironmentHelper?: boolean;
  44472. /**
  44473. * flags to configure the removal of the environment helper.
  44474. * If not set, the entire background will be removed. If set, flags should be set as well.
  44475. */
  44476. environmentHelperRemovalFlags?: {
  44477. /**
  44478. * Should the skybox be removed (default false)
  44479. */
  44480. skyBox?: boolean;
  44481. /**
  44482. * Should the ground be removed (default false)
  44483. */
  44484. ground?: boolean;
  44485. };
  44486. /**
  44487. * Further background meshes to disable when entering AR
  44488. */
  44489. backgroundMeshes?: AbstractMesh[];
  44490. }
  44491. /**
  44492. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44493. */
  44494. export class WebXRBackgroundRemover implements IWebXRFeature {
  44495. private _xrSessionManager;
  44496. /**
  44497. * read-only options to be used in this module
  44498. */
  44499. readonly options: IWebXRBackgroundRemoverOptions;
  44500. /**
  44501. * The module's name
  44502. */
  44503. static readonly Name: string;
  44504. /**
  44505. * The (Babylon) version of this module.
  44506. * This is an integer representing the implementation version.
  44507. * This number does not correspond to the webxr specs version
  44508. */
  44509. static readonly Version: number;
  44510. /**
  44511. * registered observers will be triggered when the background state changes
  44512. */
  44513. onBackgroundStateChangedObservable: Observable<boolean>;
  44514. /**
  44515. * constructs a new background remover module
  44516. * @param _xrSessionManager the session manager for this module
  44517. * @param options read-only options to be used in this module
  44518. */
  44519. constructor(_xrSessionManager: WebXRSessionManager,
  44520. /**
  44521. * read-only options to be used in this module
  44522. */
  44523. options?: IWebXRBackgroundRemoverOptions);
  44524. /**
  44525. * attach this feature
  44526. * Will usually be called by the features manager
  44527. *
  44528. * @returns true if successful.
  44529. */
  44530. attach(): boolean;
  44531. /**
  44532. * detach this feature.
  44533. * Will usually be called by the features manager
  44534. *
  44535. * @returns true if successful.
  44536. */
  44537. detach(): boolean;
  44538. private _setBackgroundState;
  44539. /**
  44540. * Dispose this feature and all of the resources attached
  44541. */
  44542. dispose(): void;
  44543. }
  44544. }
  44545. declare module BABYLON {
  44546. /**
  44547. * Contains an array of blocks representing the octree
  44548. */
  44549. export interface IOctreeContainer<T> {
  44550. /**
  44551. * Blocks within the octree
  44552. */
  44553. blocks: Array<OctreeBlock<T>>;
  44554. }
  44555. /**
  44556. * Class used to store a cell in an octree
  44557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44558. */
  44559. export class OctreeBlock<T> {
  44560. /**
  44561. * Gets the content of the current block
  44562. */
  44563. entries: T[];
  44564. /**
  44565. * Gets the list of block children
  44566. */
  44567. blocks: Array<OctreeBlock<T>>;
  44568. private _depth;
  44569. private _maxDepth;
  44570. private _capacity;
  44571. private _minPoint;
  44572. private _maxPoint;
  44573. private _boundingVectors;
  44574. private _creationFunc;
  44575. /**
  44576. * Creates a new block
  44577. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44578. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44579. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44580. * @param depth defines the current depth of this block in the octree
  44581. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44582. * @param creationFunc defines a callback to call when an element is added to the block
  44583. */
  44584. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44585. /**
  44586. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44587. */
  44588. get capacity(): number;
  44589. /**
  44590. * Gets the minimum vector (in world space) of the block's bounding box
  44591. */
  44592. get minPoint(): Vector3;
  44593. /**
  44594. * Gets the maximum vector (in world space) of the block's bounding box
  44595. */
  44596. get maxPoint(): Vector3;
  44597. /**
  44598. * Add a new element to this block
  44599. * @param entry defines the element to add
  44600. */
  44601. addEntry(entry: T): void;
  44602. /**
  44603. * Remove an element from this block
  44604. * @param entry defines the element to remove
  44605. */
  44606. removeEntry(entry: T): void;
  44607. /**
  44608. * Add an array of elements to this block
  44609. * @param entries defines the array of elements to add
  44610. */
  44611. addEntries(entries: T[]): void;
  44612. /**
  44613. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44614. * @param frustumPlanes defines the frustum planes to test
  44615. * @param selection defines the array to store current content if selection is positive
  44616. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44617. */
  44618. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44619. /**
  44620. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44621. * @param sphereCenter defines the bounding sphere center
  44622. * @param sphereRadius defines the bounding sphere radius
  44623. * @param selection defines the array to store current content if selection is positive
  44624. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44625. */
  44626. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44627. /**
  44628. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44629. * @param ray defines the ray to test with
  44630. * @param selection defines the array to store current content if selection is positive
  44631. */
  44632. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44633. /**
  44634. * Subdivide the content into child blocks (this block will then be empty)
  44635. */
  44636. createInnerBlocks(): void;
  44637. /**
  44638. * @hidden
  44639. */
  44640. 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;
  44641. }
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44646. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44647. */
  44648. export class Octree<T> {
  44649. /** 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.) */
  44650. maxDepth: number;
  44651. /**
  44652. * Blocks within the octree containing objects
  44653. */
  44654. blocks: Array<OctreeBlock<T>>;
  44655. /**
  44656. * Content stored in the octree
  44657. */
  44658. dynamicContent: T[];
  44659. private _maxBlockCapacity;
  44660. private _selectionContent;
  44661. private _creationFunc;
  44662. /**
  44663. * Creates a octree
  44664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44665. * @param creationFunc function to be used to instatiate the octree
  44666. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44667. * @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.)
  44668. */
  44669. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44670. /** 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.) */
  44671. maxDepth?: number);
  44672. /**
  44673. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44674. * @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);
  44675. * @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);
  44676. * @param entries meshes to be added to the octree blocks
  44677. */
  44678. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44679. /**
  44680. * Adds a mesh to the octree
  44681. * @param entry Mesh to add to the octree
  44682. */
  44683. addMesh(entry: T): void;
  44684. /**
  44685. * Remove an element from the octree
  44686. * @param entry defines the element to remove
  44687. */
  44688. removeMesh(entry: T): void;
  44689. /**
  44690. * Selects an array of meshes within the frustum
  44691. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44692. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44693. * @returns array of meshes within the frustum
  44694. */
  44695. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44696. /**
  44697. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44698. * @param sphereCenter defines the bounding sphere center
  44699. * @param sphereRadius defines the bounding sphere radius
  44700. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44701. * @returns an array of objects that intersect the sphere
  44702. */
  44703. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44704. /**
  44705. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44706. * @param ray defines the ray to test with
  44707. * @returns array of intersected objects
  44708. */
  44709. intersectsRay(ray: Ray): SmartArray<T>;
  44710. /**
  44711. * Adds a mesh into the octree block if it intersects the block
  44712. */
  44713. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44714. /**
  44715. * Adds a submesh into the octree block if it intersects the block
  44716. */
  44717. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44718. }
  44719. }
  44720. declare module BABYLON {
  44721. interface Scene {
  44722. /**
  44723. * @hidden
  44724. * Backing Filed
  44725. */
  44726. _selectionOctree: Octree<AbstractMesh>;
  44727. /**
  44728. * Gets the octree used to boost mesh selection (picking)
  44729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44730. */
  44731. selectionOctree: Octree<AbstractMesh>;
  44732. /**
  44733. * Creates or updates the octree used to boost selection (picking)
  44734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44735. * @param maxCapacity defines the maximum capacity per leaf
  44736. * @param maxDepth defines the maximum depth of the octree
  44737. * @returns an octree of AbstractMesh
  44738. */
  44739. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44740. }
  44741. interface AbstractMesh {
  44742. /**
  44743. * @hidden
  44744. * Backing Field
  44745. */
  44746. _submeshesOctree: Octree<SubMesh>;
  44747. /**
  44748. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44749. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44750. * @param maxCapacity defines the maximum size of each block (64 by default)
  44751. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44752. * @returns the new octree
  44753. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44755. */
  44756. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44757. }
  44758. /**
  44759. * Defines the octree scene component responsible to manage any octrees
  44760. * in a given scene.
  44761. */
  44762. export class OctreeSceneComponent {
  44763. /**
  44764. * The component name help to identify the component in the list of scene components.
  44765. */
  44766. readonly name: string;
  44767. /**
  44768. * The scene the component belongs to.
  44769. */
  44770. scene: Scene;
  44771. /**
  44772. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44773. */
  44774. readonly checksIsEnabled: boolean;
  44775. /**
  44776. * Creates a new instance of the component for the given scene
  44777. * @param scene Defines the scene to register the component in
  44778. */
  44779. constructor(scene: Scene);
  44780. /**
  44781. * Registers the component in a given scene
  44782. */
  44783. register(): void;
  44784. /**
  44785. * Return the list of active meshes
  44786. * @returns the list of active meshes
  44787. */
  44788. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44789. /**
  44790. * Return the list of active sub meshes
  44791. * @param mesh The mesh to get the candidates sub meshes from
  44792. * @returns the list of active sub meshes
  44793. */
  44794. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44795. private _tempRay;
  44796. /**
  44797. * Return the list of sub meshes intersecting with a given local ray
  44798. * @param mesh defines the mesh to find the submesh for
  44799. * @param localRay defines the ray in local space
  44800. * @returns the list of intersecting sub meshes
  44801. */
  44802. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44803. /**
  44804. * Return the list of sub meshes colliding with a collider
  44805. * @param mesh defines the mesh to find the submesh for
  44806. * @param collider defines the collider to evaluate the collision against
  44807. * @returns the list of colliding sub meshes
  44808. */
  44809. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44810. /**
  44811. * Rebuilds the elements related to this component in case of
  44812. * context lost for instance.
  44813. */
  44814. rebuild(): void;
  44815. /**
  44816. * Disposes the component and the associated ressources.
  44817. */
  44818. dispose(): void;
  44819. }
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * Renders a layer on top of an existing scene
  44824. */
  44825. export class UtilityLayerRenderer implements IDisposable {
  44826. /** the original scene that will be rendered on top of */
  44827. originalScene: Scene;
  44828. private _pointerCaptures;
  44829. private _lastPointerEvents;
  44830. private static _DefaultUtilityLayer;
  44831. private static _DefaultKeepDepthUtilityLayer;
  44832. private _sharedGizmoLight;
  44833. private _renderCamera;
  44834. /**
  44835. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44836. * @returns the camera that is used when rendering the utility layer
  44837. */
  44838. getRenderCamera(): Nullable<Camera>;
  44839. /**
  44840. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44841. * @param cam the camera that should be used when rendering the utility layer
  44842. */
  44843. setRenderCamera(cam: Nullable<Camera>): void;
  44844. /**
  44845. * @hidden
  44846. * Light which used by gizmos to get light shading
  44847. */
  44848. _getSharedGizmoLight(): HemisphericLight;
  44849. /**
  44850. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44851. */
  44852. pickUtilitySceneFirst: boolean;
  44853. /**
  44854. * 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)
  44855. */
  44856. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44857. /**
  44858. * 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)
  44859. */
  44860. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44861. /**
  44862. * The scene that is rendered on top of the original scene
  44863. */
  44864. utilityLayerScene: Scene;
  44865. /**
  44866. * If the utility layer should automatically be rendered on top of existing scene
  44867. */
  44868. shouldRender: boolean;
  44869. /**
  44870. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44871. */
  44872. onlyCheckPointerDownEvents: boolean;
  44873. /**
  44874. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44875. */
  44876. processAllEvents: boolean;
  44877. /**
  44878. * Observable raised when the pointer move from the utility layer scene to the main scene
  44879. */
  44880. onPointerOutObservable: Observable<number>;
  44881. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44882. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44883. private _afterRenderObserver;
  44884. private _sceneDisposeObserver;
  44885. private _originalPointerObserver;
  44886. /**
  44887. * Instantiates a UtilityLayerRenderer
  44888. * @param originalScene the original scene that will be rendered on top of
  44889. * @param handleEvents boolean indicating if the utility layer should handle events
  44890. */
  44891. constructor(
  44892. /** the original scene that will be rendered on top of */
  44893. originalScene: Scene, handleEvents?: boolean);
  44894. private _notifyObservers;
  44895. /**
  44896. * Renders the utility layers scene on top of the original scene
  44897. */
  44898. render(): void;
  44899. /**
  44900. * Disposes of the renderer
  44901. */
  44902. dispose(): void;
  44903. private _updateCamera;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /**
  44908. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44909. */
  44910. export class Gizmo implements IDisposable {
  44911. /** The utility layer the gizmo will be added to */
  44912. gizmoLayer: UtilityLayerRenderer;
  44913. /**
  44914. * The root mesh of the gizmo
  44915. */
  44916. _rootMesh: Mesh;
  44917. private _attachedMesh;
  44918. /**
  44919. * Ratio for the scale of the gizmo (Default: 1)
  44920. */
  44921. scaleRatio: number;
  44922. /**
  44923. * If a custom mesh has been set (Default: false)
  44924. */
  44925. protected _customMeshSet: boolean;
  44926. /**
  44927. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44928. * * When set, interactions will be enabled
  44929. */
  44930. get attachedMesh(): Nullable<AbstractMesh>;
  44931. set attachedMesh(value: Nullable<AbstractMesh>);
  44932. /**
  44933. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44934. * @param mesh The mesh to replace the default mesh of the gizmo
  44935. */
  44936. setCustomMesh(mesh: Mesh): void;
  44937. /**
  44938. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44939. */
  44940. updateGizmoRotationToMatchAttachedMesh: boolean;
  44941. /**
  44942. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44943. */
  44944. updateGizmoPositionToMatchAttachedMesh: boolean;
  44945. /**
  44946. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44947. */
  44948. updateScale: boolean;
  44949. protected _interactionsEnabled: boolean;
  44950. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44951. private _beforeRenderObserver;
  44952. private _tempVector;
  44953. /**
  44954. * Creates a gizmo
  44955. * @param gizmoLayer The utility layer the gizmo will be added to
  44956. */
  44957. constructor(
  44958. /** The utility layer the gizmo will be added to */
  44959. gizmoLayer?: UtilityLayerRenderer);
  44960. /**
  44961. * Updates the gizmo to match the attached mesh's position/rotation
  44962. */
  44963. protected _update(): void;
  44964. /**
  44965. * Disposes of the gizmo
  44966. */
  44967. dispose(): void;
  44968. }
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * Single plane drag gizmo
  44973. */
  44974. export class PlaneDragGizmo extends Gizmo {
  44975. /**
  44976. * Drag behavior responsible for the gizmos dragging interactions
  44977. */
  44978. dragBehavior: PointerDragBehavior;
  44979. private _pointerObserver;
  44980. /**
  44981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44982. */
  44983. snapDistance: number;
  44984. /**
  44985. * Event that fires each time the gizmo snaps to a new location.
  44986. * * snapDistance is the the change in distance
  44987. */
  44988. onSnapObservable: Observable<{
  44989. snapDistance: number;
  44990. }>;
  44991. private _plane;
  44992. private _coloredMaterial;
  44993. private _hoverMaterial;
  44994. private _isEnabled;
  44995. private _parent;
  44996. /** @hidden */
  44997. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44998. /** @hidden */
  44999. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45000. /**
  45001. * Creates a PlaneDragGizmo
  45002. * @param gizmoLayer The utility layer the gizmo will be added to
  45003. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45004. * @param color The color of the gizmo
  45005. */
  45006. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45007. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45008. /**
  45009. * If the gizmo is enabled
  45010. */
  45011. set isEnabled(value: boolean);
  45012. get isEnabled(): boolean;
  45013. /**
  45014. * Disposes of the gizmo
  45015. */
  45016. dispose(): void;
  45017. }
  45018. }
  45019. declare module BABYLON {
  45020. /**
  45021. * Gizmo that enables dragging a mesh along 3 axis
  45022. */
  45023. export class PositionGizmo extends Gizmo {
  45024. /**
  45025. * Internal gizmo used for interactions on the x axis
  45026. */
  45027. xGizmo: AxisDragGizmo;
  45028. /**
  45029. * Internal gizmo used for interactions on the y axis
  45030. */
  45031. yGizmo: AxisDragGizmo;
  45032. /**
  45033. * Internal gizmo used for interactions on the z axis
  45034. */
  45035. zGizmo: AxisDragGizmo;
  45036. /**
  45037. * Internal gizmo used for interactions on the yz plane
  45038. */
  45039. xPlaneGizmo: PlaneDragGizmo;
  45040. /**
  45041. * Internal gizmo used for interactions on the xz plane
  45042. */
  45043. yPlaneGizmo: PlaneDragGizmo;
  45044. /**
  45045. * Internal gizmo used for interactions on the xy plane
  45046. */
  45047. zPlaneGizmo: PlaneDragGizmo;
  45048. /**
  45049. * private variables
  45050. */
  45051. private _meshAttached;
  45052. private _updateGizmoRotationToMatchAttachedMesh;
  45053. private _snapDistance;
  45054. private _scaleRatio;
  45055. /** Fires an event when any of it's sub gizmos are dragged */
  45056. onDragStartObservable: Observable<unknown>;
  45057. /** Fires an event when any of it's sub gizmos are released from dragging */
  45058. onDragEndObservable: Observable<unknown>;
  45059. /**
  45060. * If set to true, planar drag is enabled
  45061. */
  45062. private _planarGizmoEnabled;
  45063. get attachedMesh(): Nullable<AbstractMesh>;
  45064. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45065. /**
  45066. * Creates a PositionGizmo
  45067. * @param gizmoLayer The utility layer the gizmo will be added to
  45068. */
  45069. constructor(gizmoLayer?: UtilityLayerRenderer);
  45070. /**
  45071. * If the planar drag gizmo is enabled
  45072. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45073. */
  45074. set planarGizmoEnabled(value: boolean);
  45075. get planarGizmoEnabled(): boolean;
  45076. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45077. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45078. /**
  45079. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45080. */
  45081. set snapDistance(value: number);
  45082. get snapDistance(): number;
  45083. /**
  45084. * Ratio for the scale of the gizmo (Default: 1)
  45085. */
  45086. set scaleRatio(value: number);
  45087. get scaleRatio(): number;
  45088. /**
  45089. * Disposes of the gizmo
  45090. */
  45091. dispose(): void;
  45092. /**
  45093. * CustomMeshes are not supported by this gizmo
  45094. * @param mesh The mesh to replace the default mesh of the gizmo
  45095. */
  45096. setCustomMesh(mesh: Mesh): void;
  45097. }
  45098. }
  45099. declare module BABYLON {
  45100. /**
  45101. * Single axis drag gizmo
  45102. */
  45103. export class AxisDragGizmo extends Gizmo {
  45104. /**
  45105. * Drag behavior responsible for the gizmos dragging interactions
  45106. */
  45107. dragBehavior: PointerDragBehavior;
  45108. private _pointerObserver;
  45109. /**
  45110. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45111. */
  45112. snapDistance: number;
  45113. /**
  45114. * Event that fires each time the gizmo snaps to a new location.
  45115. * * snapDistance is the the change in distance
  45116. */
  45117. onSnapObservable: Observable<{
  45118. snapDistance: number;
  45119. }>;
  45120. private _isEnabled;
  45121. private _parent;
  45122. private _arrow;
  45123. private _coloredMaterial;
  45124. private _hoverMaterial;
  45125. /** @hidden */
  45126. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45127. /** @hidden */
  45128. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45129. /**
  45130. * Creates an AxisDragGizmo
  45131. * @param gizmoLayer The utility layer the gizmo will be added to
  45132. * @param dragAxis The axis which the gizmo will be able to drag on
  45133. * @param color The color of the gizmo
  45134. */
  45135. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45136. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45137. /**
  45138. * If the gizmo is enabled
  45139. */
  45140. set isEnabled(value: boolean);
  45141. get isEnabled(): boolean;
  45142. /**
  45143. * Disposes of the gizmo
  45144. */
  45145. dispose(): void;
  45146. }
  45147. }
  45148. declare module BABYLON.Debug {
  45149. /**
  45150. * The Axes viewer will show 3 axes in a specific point in space
  45151. */
  45152. export class AxesViewer {
  45153. private _xAxis;
  45154. private _yAxis;
  45155. private _zAxis;
  45156. private _scaleLinesFactor;
  45157. private _instanced;
  45158. /**
  45159. * Gets the hosting scene
  45160. */
  45161. scene: Scene;
  45162. /**
  45163. * Gets or sets a number used to scale line length
  45164. */
  45165. scaleLines: number;
  45166. /** Gets the node hierarchy used to render x-axis */
  45167. get xAxis(): TransformNode;
  45168. /** Gets the node hierarchy used to render y-axis */
  45169. get yAxis(): TransformNode;
  45170. /** Gets the node hierarchy used to render z-axis */
  45171. get zAxis(): TransformNode;
  45172. /**
  45173. * Creates a new AxesViewer
  45174. * @param scene defines the hosting scene
  45175. * @param scaleLines defines a number used to scale line length (1 by default)
  45176. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45177. * @param xAxis defines the node hierarchy used to render the x-axis
  45178. * @param yAxis defines the node hierarchy used to render the y-axis
  45179. * @param zAxis defines the node hierarchy used to render the z-axis
  45180. */
  45181. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45182. /**
  45183. * Force the viewer to update
  45184. * @param position defines the position of the viewer
  45185. * @param xaxis defines the x axis of the viewer
  45186. * @param yaxis defines the y axis of the viewer
  45187. * @param zaxis defines the z axis of the viewer
  45188. */
  45189. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45190. /**
  45191. * Creates an instance of this axes viewer.
  45192. * @returns a new axes viewer with instanced meshes
  45193. */
  45194. createInstance(): AxesViewer;
  45195. /** Releases resources */
  45196. dispose(): void;
  45197. private static _SetRenderingGroupId;
  45198. }
  45199. }
  45200. declare module BABYLON.Debug {
  45201. /**
  45202. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45203. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45204. */
  45205. export class BoneAxesViewer extends AxesViewer {
  45206. /**
  45207. * Gets or sets the target mesh where to display the axes viewer
  45208. */
  45209. mesh: Nullable<Mesh>;
  45210. /**
  45211. * Gets or sets the target bone where to display the axes viewer
  45212. */
  45213. bone: Nullable<Bone>;
  45214. /** Gets current position */
  45215. pos: Vector3;
  45216. /** Gets direction of X axis */
  45217. xaxis: Vector3;
  45218. /** Gets direction of Y axis */
  45219. yaxis: Vector3;
  45220. /** Gets direction of Z axis */
  45221. zaxis: Vector3;
  45222. /**
  45223. * Creates a new BoneAxesViewer
  45224. * @param scene defines the hosting scene
  45225. * @param bone defines the target bone
  45226. * @param mesh defines the target mesh
  45227. * @param scaleLines defines a scaling factor for line length (1 by default)
  45228. */
  45229. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45230. /**
  45231. * Force the viewer to update
  45232. */
  45233. update(): void;
  45234. /** Releases resources */
  45235. dispose(): void;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * Interface used to define scene explorer extensibility option
  45241. */
  45242. export interface IExplorerExtensibilityOption {
  45243. /**
  45244. * Define the option label
  45245. */
  45246. label: string;
  45247. /**
  45248. * Defines the action to execute on click
  45249. */
  45250. action: (entity: any) => void;
  45251. }
  45252. /**
  45253. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45254. */
  45255. export interface IExplorerExtensibilityGroup {
  45256. /**
  45257. * Defines a predicate to test if a given type mut be extended
  45258. */
  45259. predicate: (entity: any) => boolean;
  45260. /**
  45261. * Gets the list of options added to a type
  45262. */
  45263. entries: IExplorerExtensibilityOption[];
  45264. }
  45265. /**
  45266. * Interface used to define the options to use to create the Inspector
  45267. */
  45268. export interface IInspectorOptions {
  45269. /**
  45270. * Display in overlay mode (default: false)
  45271. */
  45272. overlay?: boolean;
  45273. /**
  45274. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45275. */
  45276. globalRoot?: HTMLElement;
  45277. /**
  45278. * Display the Scene explorer
  45279. */
  45280. showExplorer?: boolean;
  45281. /**
  45282. * Display the property inspector
  45283. */
  45284. showInspector?: boolean;
  45285. /**
  45286. * Display in embed mode (both panes on the right)
  45287. */
  45288. embedMode?: boolean;
  45289. /**
  45290. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45291. */
  45292. handleResize?: boolean;
  45293. /**
  45294. * Allow the panes to popup (default: true)
  45295. */
  45296. enablePopup?: boolean;
  45297. /**
  45298. * Allow the panes to be closed by users (default: true)
  45299. */
  45300. enableClose?: boolean;
  45301. /**
  45302. * Optional list of extensibility entries
  45303. */
  45304. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45305. /**
  45306. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45307. */
  45308. inspectorURL?: string;
  45309. /**
  45310. * Optional initial tab (default to DebugLayerTab.Properties)
  45311. */
  45312. initialTab?: DebugLayerTab;
  45313. }
  45314. interface Scene {
  45315. /**
  45316. * @hidden
  45317. * Backing field
  45318. */
  45319. _debugLayer: DebugLayer;
  45320. /**
  45321. * Gets the debug layer (aka Inspector) associated with the scene
  45322. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45323. */
  45324. debugLayer: DebugLayer;
  45325. }
  45326. /**
  45327. * Enum of inspector action tab
  45328. */
  45329. export enum DebugLayerTab {
  45330. /**
  45331. * Properties tag (default)
  45332. */
  45333. Properties = 0,
  45334. /**
  45335. * Debug tab
  45336. */
  45337. Debug = 1,
  45338. /**
  45339. * Statistics tab
  45340. */
  45341. Statistics = 2,
  45342. /**
  45343. * Tools tab
  45344. */
  45345. Tools = 3,
  45346. /**
  45347. * Settings tab
  45348. */
  45349. Settings = 4
  45350. }
  45351. /**
  45352. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45353. * what is happening in your scene
  45354. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45355. */
  45356. export class DebugLayer {
  45357. /**
  45358. * Define the url to get the inspector script from.
  45359. * By default it uses the babylonjs CDN.
  45360. * @ignoreNaming
  45361. */
  45362. static InspectorURL: string;
  45363. private _scene;
  45364. private BJSINSPECTOR;
  45365. private _onPropertyChangedObservable?;
  45366. /**
  45367. * Observable triggered when a property is changed through the inspector.
  45368. */
  45369. get onPropertyChangedObservable(): any;
  45370. /**
  45371. * Instantiates a new debug layer.
  45372. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45373. * what is happening in your scene
  45374. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45375. * @param scene Defines the scene to inspect
  45376. */
  45377. constructor(scene: Scene);
  45378. /** Creates the inspector window. */
  45379. private _createInspector;
  45380. /**
  45381. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45382. * @param entity defines the entity to select
  45383. * @param lineContainerTitle defines the specific block to highlight
  45384. */
  45385. select(entity: any, lineContainerTitle?: string): void;
  45386. /** Get the inspector from bundle or global */
  45387. private _getGlobalInspector;
  45388. /**
  45389. * Get if the inspector is visible or not.
  45390. * @returns true if visible otherwise, false
  45391. */
  45392. isVisible(): boolean;
  45393. /**
  45394. * Hide the inspector and close its window.
  45395. */
  45396. hide(): void;
  45397. /**
  45398. * Launch the debugLayer.
  45399. * @param config Define the configuration of the inspector
  45400. * @return a promise fulfilled when the debug layer is visible
  45401. */
  45402. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45403. }
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * Class containing static functions to help procedurally build meshes
  45408. */
  45409. export class BoxBuilder {
  45410. /**
  45411. * Creates a box mesh
  45412. * * The parameter `size` sets the size (float) of each box side (default 1)
  45413. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45414. * * 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)
  45415. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45417. * * 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
  45418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45419. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45420. * @param name defines the name of the mesh
  45421. * @param options defines the options used to create the mesh
  45422. * @param scene defines the hosting scene
  45423. * @returns the box mesh
  45424. */
  45425. static CreateBox(name: string, options: {
  45426. size?: number;
  45427. width?: number;
  45428. height?: number;
  45429. depth?: number;
  45430. faceUV?: Vector4[];
  45431. faceColors?: Color4[];
  45432. sideOrientation?: number;
  45433. frontUVs?: Vector4;
  45434. backUVs?: Vector4;
  45435. wrap?: boolean;
  45436. topBaseAt?: number;
  45437. bottomBaseAt?: number;
  45438. updatable?: boolean;
  45439. }, scene?: Nullable<Scene>): Mesh;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * Class containing static functions to help procedurally build meshes
  45445. */
  45446. export class SphereBuilder {
  45447. /**
  45448. * Creates a sphere mesh
  45449. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45450. * * 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`)
  45451. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45452. * * 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
  45453. * * 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)
  45454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45455. * * 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
  45456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45457. * @param name defines the name of the mesh
  45458. * @param options defines the options used to create the mesh
  45459. * @param scene defines the hosting scene
  45460. * @returns the sphere mesh
  45461. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45462. */
  45463. static CreateSphere(name: string, options: {
  45464. segments?: number;
  45465. diameter?: number;
  45466. diameterX?: number;
  45467. diameterY?: number;
  45468. diameterZ?: number;
  45469. arc?: number;
  45470. slice?: number;
  45471. sideOrientation?: number;
  45472. frontUVs?: Vector4;
  45473. backUVs?: Vector4;
  45474. updatable?: boolean;
  45475. }, scene?: Nullable<Scene>): Mesh;
  45476. }
  45477. }
  45478. declare module BABYLON.Debug {
  45479. /**
  45480. * Used to show the physics impostor around the specific mesh
  45481. */
  45482. export class PhysicsViewer {
  45483. /** @hidden */
  45484. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45485. /** @hidden */
  45486. protected _meshes: Array<Nullable<AbstractMesh>>;
  45487. /** @hidden */
  45488. protected _scene: Nullable<Scene>;
  45489. /** @hidden */
  45490. protected _numMeshes: number;
  45491. /** @hidden */
  45492. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45493. private _renderFunction;
  45494. private _utilityLayer;
  45495. private _debugBoxMesh;
  45496. private _debugSphereMesh;
  45497. private _debugCylinderMesh;
  45498. private _debugMaterial;
  45499. private _debugMeshMeshes;
  45500. /**
  45501. * Creates a new PhysicsViewer
  45502. * @param scene defines the hosting scene
  45503. */
  45504. constructor(scene: Scene);
  45505. /** @hidden */
  45506. protected _updateDebugMeshes(): void;
  45507. /**
  45508. * Renders a specified physic impostor
  45509. * @param impostor defines the impostor to render
  45510. * @param targetMesh defines the mesh represented by the impostor
  45511. * @returns the new debug mesh used to render the impostor
  45512. */
  45513. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45514. /**
  45515. * Hides a specified physic impostor
  45516. * @param impostor defines the impostor to hide
  45517. */
  45518. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45519. private _getDebugMaterial;
  45520. private _getDebugBoxMesh;
  45521. private _getDebugSphereMesh;
  45522. private _getDebugCylinderMesh;
  45523. private _getDebugMeshMesh;
  45524. private _getDebugMesh;
  45525. /** Releases all resources */
  45526. dispose(): void;
  45527. }
  45528. }
  45529. declare module BABYLON {
  45530. /**
  45531. * Class containing static functions to help procedurally build meshes
  45532. */
  45533. export class LinesBuilder {
  45534. /**
  45535. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45536. * * 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
  45537. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45538. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45539. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45540. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45541. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45542. * * 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
  45543. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45546. * @param name defines the name of the new line system
  45547. * @param options defines the options used to create the line system
  45548. * @param scene defines the hosting scene
  45549. * @returns a new line system mesh
  45550. */
  45551. static CreateLineSystem(name: string, options: {
  45552. lines: Vector3[][];
  45553. updatable?: boolean;
  45554. instance?: Nullable<LinesMesh>;
  45555. colors?: Nullable<Color4[][]>;
  45556. useVertexAlpha?: boolean;
  45557. }, scene: Nullable<Scene>): LinesMesh;
  45558. /**
  45559. * Creates a line mesh
  45560. * 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
  45561. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45562. * * The parameter `points` is an array successive Vector3
  45563. * * 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
  45564. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45565. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45566. * * When updating an instance, remember that only point positions can change, not the number of points
  45567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45569. * @param name defines the name of the new line system
  45570. * @param options defines the options used to create the line system
  45571. * @param scene defines the hosting scene
  45572. * @returns a new line mesh
  45573. */
  45574. static CreateLines(name: string, options: {
  45575. points: Vector3[];
  45576. updatable?: boolean;
  45577. instance?: Nullable<LinesMesh>;
  45578. colors?: Color4[];
  45579. useVertexAlpha?: boolean;
  45580. }, scene?: Nullable<Scene>): LinesMesh;
  45581. /**
  45582. * Creates a dashed line mesh
  45583. * * 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
  45584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45585. * * The parameter `points` is an array successive Vector3
  45586. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45587. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45588. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45589. * * 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
  45590. * * When updating an instance, remember that only point positions can change, not the number of points
  45591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45592. * @param name defines the name of the mesh
  45593. * @param options defines the options used to create the mesh
  45594. * @param scene defines the hosting scene
  45595. * @returns the dashed line mesh
  45596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45597. */
  45598. static CreateDashedLines(name: string, options: {
  45599. points: Vector3[];
  45600. dashSize?: number;
  45601. gapSize?: number;
  45602. dashNb?: number;
  45603. updatable?: boolean;
  45604. instance?: LinesMesh;
  45605. }, scene?: Nullable<Scene>): LinesMesh;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45611. * in order to better appreciate the issue one might have.
  45612. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45613. */
  45614. export class RayHelper {
  45615. /**
  45616. * Defines the ray we are currently tryin to visualize.
  45617. */
  45618. ray: Nullable<Ray>;
  45619. private _renderPoints;
  45620. private _renderLine;
  45621. private _renderFunction;
  45622. private _scene;
  45623. private _updateToMeshFunction;
  45624. private _attachedToMesh;
  45625. private _meshSpaceDirection;
  45626. private _meshSpaceOrigin;
  45627. /**
  45628. * Helper function to create a colored helper in a scene in one line.
  45629. * @param ray Defines the ray we are currently tryin to visualize
  45630. * @param scene Defines the scene the ray is used in
  45631. * @param color Defines the color we want to see the ray in
  45632. * @returns The newly created ray helper.
  45633. */
  45634. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45635. /**
  45636. * Instantiate a new ray helper.
  45637. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45638. * in order to better appreciate the issue one might have.
  45639. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45640. * @param ray Defines the ray we are currently tryin to visualize
  45641. */
  45642. constructor(ray: Ray);
  45643. /**
  45644. * Shows the ray we are willing to debug.
  45645. * @param scene Defines the scene the ray needs to be rendered in
  45646. * @param color Defines the color the ray needs to be rendered in
  45647. */
  45648. show(scene: Scene, color?: Color3): void;
  45649. /**
  45650. * Hides the ray we are debugging.
  45651. */
  45652. hide(): void;
  45653. private _render;
  45654. /**
  45655. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45656. * @param mesh Defines the mesh we want the helper attached to
  45657. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45658. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45659. * @param length Defines the length of the ray
  45660. */
  45661. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45662. /**
  45663. * Detach the ray helper from the mesh it has previously been attached to.
  45664. */
  45665. detachFromMesh(): void;
  45666. private _updateToMesh;
  45667. /**
  45668. * Dispose the helper and release its associated resources.
  45669. */
  45670. dispose(): void;
  45671. }
  45672. }
  45673. declare module BABYLON.Debug {
  45674. /**
  45675. * Class used to render a debug view of a given skeleton
  45676. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45677. */
  45678. export class SkeletonViewer {
  45679. /** defines the skeleton to render */
  45680. skeleton: Skeleton;
  45681. /** defines the mesh attached to the skeleton */
  45682. mesh: AbstractMesh;
  45683. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45684. autoUpdateBonesMatrices: boolean;
  45685. /** defines the rendering group id to use with the viewer */
  45686. renderingGroupId: number;
  45687. /** Gets or sets the color used to render the skeleton */
  45688. color: Color3;
  45689. private _scene;
  45690. private _debugLines;
  45691. private _debugMesh;
  45692. private _isEnabled;
  45693. private _renderFunction;
  45694. private _utilityLayer;
  45695. /**
  45696. * Returns the mesh used to render the bones
  45697. */
  45698. get debugMesh(): Nullable<LinesMesh>;
  45699. /**
  45700. * Creates a new SkeletonViewer
  45701. * @param skeleton defines the skeleton to render
  45702. * @param mesh defines the mesh attached to the skeleton
  45703. * @param scene defines the hosting scene
  45704. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45705. * @param renderingGroupId defines the rendering group id to use with the viewer
  45706. */
  45707. constructor(
  45708. /** defines the skeleton to render */
  45709. skeleton: Skeleton,
  45710. /** defines the mesh attached to the skeleton */
  45711. mesh: AbstractMesh, scene: Scene,
  45712. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45713. autoUpdateBonesMatrices?: boolean,
  45714. /** defines the rendering group id to use with the viewer */
  45715. renderingGroupId?: number);
  45716. /** Gets or sets a boolean indicating if the viewer is enabled */
  45717. set isEnabled(value: boolean);
  45718. get isEnabled(): boolean;
  45719. private _getBonePosition;
  45720. private _getLinesForBonesWithLength;
  45721. private _getLinesForBonesNoLength;
  45722. /** Update the viewer to sync with current skeleton state */
  45723. update(): void;
  45724. /** Release associated resources */
  45725. dispose(): void;
  45726. }
  45727. }
  45728. declare module BABYLON {
  45729. /**
  45730. * Options to create the null engine
  45731. */
  45732. export class NullEngineOptions {
  45733. /**
  45734. * Render width (Default: 512)
  45735. */
  45736. renderWidth: number;
  45737. /**
  45738. * Render height (Default: 256)
  45739. */
  45740. renderHeight: number;
  45741. /**
  45742. * Texture size (Default: 512)
  45743. */
  45744. textureSize: number;
  45745. /**
  45746. * If delta time between frames should be constant
  45747. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45748. */
  45749. deterministicLockstep: boolean;
  45750. /**
  45751. * Maximum about of steps between frames (Default: 4)
  45752. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45753. */
  45754. lockstepMaxSteps: number;
  45755. }
  45756. /**
  45757. * The null engine class provides support for headless version of babylon.js.
  45758. * This can be used in server side scenario or for testing purposes
  45759. */
  45760. export class NullEngine extends Engine {
  45761. private _options;
  45762. /**
  45763. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45765. * @returns true if engine is in deterministic lock step mode
  45766. */
  45767. isDeterministicLockStep(): boolean;
  45768. /**
  45769. * Gets the max steps when engine is running in deterministic lock step
  45770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45771. * @returns the max steps
  45772. */
  45773. getLockstepMaxSteps(): number;
  45774. /**
  45775. * Gets the current hardware scaling level.
  45776. * By default the hardware scaling level is computed from the window device ratio.
  45777. * 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.
  45778. * @returns a number indicating the current hardware scaling level
  45779. */
  45780. getHardwareScalingLevel(): number;
  45781. constructor(options?: NullEngineOptions);
  45782. /**
  45783. * Creates a vertex buffer
  45784. * @param vertices the data for the vertex buffer
  45785. * @returns the new WebGL static buffer
  45786. */
  45787. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45788. /**
  45789. * Creates a new index buffer
  45790. * @param indices defines the content of the index buffer
  45791. * @param updatable defines if the index buffer must be updatable
  45792. * @returns a new webGL buffer
  45793. */
  45794. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45795. /**
  45796. * Clear the current render buffer or the current render target (if any is set up)
  45797. * @param color defines the color to use
  45798. * @param backBuffer defines if the back buffer must be cleared
  45799. * @param depth defines if the depth buffer must be cleared
  45800. * @param stencil defines if the stencil buffer must be cleared
  45801. */
  45802. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45803. /**
  45804. * Gets the current render width
  45805. * @param useScreen defines if screen size must be used (or the current render target if any)
  45806. * @returns a number defining the current render width
  45807. */
  45808. getRenderWidth(useScreen?: boolean): number;
  45809. /**
  45810. * Gets the current render height
  45811. * @param useScreen defines if screen size must be used (or the current render target if any)
  45812. * @returns a number defining the current render height
  45813. */
  45814. getRenderHeight(useScreen?: boolean): number;
  45815. /**
  45816. * Set the WebGL's viewport
  45817. * @param viewport defines the viewport element to be used
  45818. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45819. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45820. */
  45821. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45822. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45823. /**
  45824. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45825. * @param pipelineContext defines the pipeline context to use
  45826. * @param uniformsNames defines the list of uniform names
  45827. * @returns an array of webGL uniform locations
  45828. */
  45829. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45830. /**
  45831. * Gets the lsit of active attributes for a given webGL program
  45832. * @param pipelineContext defines the pipeline context to use
  45833. * @param attributesNames defines the list of attribute names to get
  45834. * @returns an array of indices indicating the offset of each attribute
  45835. */
  45836. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45837. /**
  45838. * Binds an effect to the webGL context
  45839. * @param effect defines the effect to bind
  45840. */
  45841. bindSamplers(effect: Effect): void;
  45842. /**
  45843. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45844. * @param effect defines the effect to activate
  45845. */
  45846. enableEffect(effect: Effect): void;
  45847. /**
  45848. * Set various states to the webGL context
  45849. * @param culling defines backface culling state
  45850. * @param zOffset defines the value to apply to zOffset (0 by default)
  45851. * @param force defines if states must be applied even if cache is up to date
  45852. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45853. */
  45854. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45855. /**
  45856. * Set the value of an uniform to an array of int32
  45857. * @param uniform defines the webGL uniform location where to store the value
  45858. * @param array defines the array of int32 to store
  45859. */
  45860. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45861. /**
  45862. * Set the value of an uniform to an array of int32 (stored as vec2)
  45863. * @param uniform defines the webGL uniform location where to store the value
  45864. * @param array defines the array of int32 to store
  45865. */
  45866. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45867. /**
  45868. * Set the value of an uniform to an array of int32 (stored as vec3)
  45869. * @param uniform defines the webGL uniform location where to store the value
  45870. * @param array defines the array of int32 to store
  45871. */
  45872. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45873. /**
  45874. * Set the value of an uniform to an array of int32 (stored as vec4)
  45875. * @param uniform defines the webGL uniform location where to store the value
  45876. * @param array defines the array of int32 to store
  45877. */
  45878. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45879. /**
  45880. * Set the value of an uniform to an array of float32
  45881. * @param uniform defines the webGL uniform location where to store the value
  45882. * @param array defines the array of float32 to store
  45883. */
  45884. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45885. /**
  45886. * Set the value of an uniform to an array of float32 (stored as vec2)
  45887. * @param uniform defines the webGL uniform location where to store the value
  45888. * @param array defines the array of float32 to store
  45889. */
  45890. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45891. /**
  45892. * Set the value of an uniform to an array of float32 (stored as vec3)
  45893. * @param uniform defines the webGL uniform location where to store the value
  45894. * @param array defines the array of float32 to store
  45895. */
  45896. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45897. /**
  45898. * Set the value of an uniform to an array of float32 (stored as vec4)
  45899. * @param uniform defines the webGL uniform location where to store the value
  45900. * @param array defines the array of float32 to store
  45901. */
  45902. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45903. /**
  45904. * Set the value of an uniform to an array of number
  45905. * @param uniform defines the webGL uniform location where to store the value
  45906. * @param array defines the array of number to store
  45907. */
  45908. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45909. /**
  45910. * Set the value of an uniform to an array of number (stored as vec2)
  45911. * @param uniform defines the webGL uniform location where to store the value
  45912. * @param array defines the array of number to store
  45913. */
  45914. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45915. /**
  45916. * Set the value of an uniform to an array of number (stored as vec3)
  45917. * @param uniform defines the webGL uniform location where to store the value
  45918. * @param array defines the array of number to store
  45919. */
  45920. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45921. /**
  45922. * Set the value of an uniform to an array of number (stored as vec4)
  45923. * @param uniform defines the webGL uniform location where to store the value
  45924. * @param array defines the array of number to store
  45925. */
  45926. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45927. /**
  45928. * Set the value of an uniform to an array of float32 (stored as matrices)
  45929. * @param uniform defines the webGL uniform location where to store the value
  45930. * @param matrices defines the array of float32 to store
  45931. */
  45932. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45933. /**
  45934. * Set the value of an uniform to a matrix (3x3)
  45935. * @param uniform defines the webGL uniform location where to store the value
  45936. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45937. */
  45938. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45939. /**
  45940. * Set the value of an uniform to a matrix (2x2)
  45941. * @param uniform defines the webGL uniform location where to store the value
  45942. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45943. */
  45944. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45945. /**
  45946. * Set the value of an uniform to a number (float)
  45947. * @param uniform defines the webGL uniform location where to store the value
  45948. * @param value defines the float number to store
  45949. */
  45950. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45951. /**
  45952. * Set the value of an uniform to a vec2
  45953. * @param uniform defines the webGL uniform location where to store the value
  45954. * @param x defines the 1st component of the value
  45955. * @param y defines the 2nd component of the value
  45956. */
  45957. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45958. /**
  45959. * Set the value of an uniform to a vec3
  45960. * @param uniform defines the webGL uniform location where to store the value
  45961. * @param x defines the 1st component of the value
  45962. * @param y defines the 2nd component of the value
  45963. * @param z defines the 3rd component of the value
  45964. */
  45965. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45966. /**
  45967. * Set the value of an uniform to a boolean
  45968. * @param uniform defines the webGL uniform location where to store the value
  45969. * @param bool defines the boolean to store
  45970. */
  45971. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45972. /**
  45973. * Set the value of an uniform to a vec4
  45974. * @param uniform defines the webGL uniform location where to store the value
  45975. * @param x defines the 1st component of the value
  45976. * @param y defines the 2nd component of the value
  45977. * @param z defines the 3rd component of the value
  45978. * @param w defines the 4th component of the value
  45979. */
  45980. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45981. /**
  45982. * Sets the current alpha mode
  45983. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45984. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45985. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45986. */
  45987. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45988. /**
  45989. * Bind webGl buffers directly to the webGL context
  45990. * @param vertexBuffers defines the vertex buffer to bind
  45991. * @param indexBuffer defines the index buffer to bind
  45992. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45993. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45994. * @param effect defines the effect associated with the vertex buffer
  45995. */
  45996. bindBuffers(vertexBuffers: {
  45997. [key: string]: VertexBuffer;
  45998. }, indexBuffer: DataBuffer, effect: Effect): void;
  45999. /**
  46000. * Force the entire cache to be cleared
  46001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46003. */
  46004. wipeCaches(bruteForce?: boolean): void;
  46005. /**
  46006. * Send a draw order
  46007. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46008. * @param indexStart defines the starting index
  46009. * @param indexCount defines the number of index to draw
  46010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46011. */
  46012. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46013. /**
  46014. * Draw a list of indexed primitives
  46015. * @param fillMode defines the primitive to use
  46016. * @param indexStart defines the starting index
  46017. * @param indexCount defines the number of index to draw
  46018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46019. */
  46020. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46021. /**
  46022. * Draw a list of unindexed primitives
  46023. * @param fillMode defines the primitive to use
  46024. * @param verticesStart defines the index of first vertex to draw
  46025. * @param verticesCount defines the count of vertices to draw
  46026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46027. */
  46028. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46029. /** @hidden */
  46030. _createTexture(): WebGLTexture;
  46031. /** @hidden */
  46032. _releaseTexture(texture: InternalTexture): void;
  46033. /**
  46034. * Usually called from Texture.ts.
  46035. * Passed information to create a WebGLTexture
  46036. * @param urlArg defines a value which contains one of the following:
  46037. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46038. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46039. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46041. * @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)
  46042. * @param scene needed for loading to the correct scene
  46043. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46044. * @param onLoad optional callback to be called upon successful completion
  46045. * @param onError optional callback to be called upon failure
  46046. * @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
  46047. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46048. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46049. * @param forcedExtension defines the extension to use to pick the right loader
  46050. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46052. */
  46053. 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;
  46054. /**
  46055. * Creates a new render target texture
  46056. * @param size defines the size of the texture
  46057. * @param options defines the options used to create the texture
  46058. * @returns a new render target texture stored in an InternalTexture
  46059. */
  46060. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46061. /**
  46062. * Update the sampling mode of a given texture
  46063. * @param samplingMode defines the required sampling mode
  46064. * @param texture defines the texture to update
  46065. */
  46066. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46067. /**
  46068. * Binds the frame buffer to the specified texture.
  46069. * @param texture The texture to render to or null for the default canvas
  46070. * @param faceIndex The face of the texture to render to in case of cube texture
  46071. * @param requiredWidth The width of the target to render to
  46072. * @param requiredHeight The height of the target to render to
  46073. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46074. * @param depthStencilTexture The depth stencil texture to use to render
  46075. * @param lodLevel defines le lod level to bind to the frame buffer
  46076. */
  46077. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46078. /**
  46079. * Unbind the current render target texture from the webGL context
  46080. * @param texture defines the render target texture to unbind
  46081. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46082. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46083. */
  46084. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46085. /**
  46086. * Creates a dynamic vertex buffer
  46087. * @param vertices the data for the dynamic vertex buffer
  46088. * @returns the new WebGL dynamic buffer
  46089. */
  46090. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46091. /**
  46092. * Update the content of a dynamic texture
  46093. * @param texture defines the texture to update
  46094. * @param canvas defines the canvas containing the source
  46095. * @param invertY defines if data must be stored with Y axis inverted
  46096. * @param premulAlpha defines if alpha is stored as premultiplied
  46097. * @param format defines the format of the data
  46098. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46099. */
  46100. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46101. /**
  46102. * Gets a boolean indicating if all created effects are ready
  46103. * @returns true if all effects are ready
  46104. */
  46105. areAllEffectsReady(): boolean;
  46106. /**
  46107. * @hidden
  46108. * Get the current error code of the webGL context
  46109. * @returns the error code
  46110. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46111. */
  46112. getError(): number;
  46113. /** @hidden */
  46114. _getUnpackAlignement(): number;
  46115. /** @hidden */
  46116. _unpackFlipY(value: boolean): void;
  46117. /**
  46118. * Update a dynamic index buffer
  46119. * @param indexBuffer defines the target index buffer
  46120. * @param indices defines the data to update
  46121. * @param offset defines the offset in the target index buffer where update should start
  46122. */
  46123. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46124. /**
  46125. * Updates a dynamic vertex buffer.
  46126. * @param vertexBuffer the vertex buffer to update
  46127. * @param vertices the data used to update the vertex buffer
  46128. * @param byteOffset the byte offset of the data (optional)
  46129. * @param byteLength the byte length of the data (optional)
  46130. */
  46131. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46132. /** @hidden */
  46133. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46134. /** @hidden */
  46135. _bindTexture(channel: number, texture: InternalTexture): void;
  46136. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46137. /**
  46138. * 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
  46139. */
  46140. releaseEffects(): void;
  46141. displayLoadingUI(): void;
  46142. hideLoadingUI(): void;
  46143. /** @hidden */
  46144. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46145. /** @hidden */
  46146. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46147. /** @hidden */
  46148. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46149. /** @hidden */
  46150. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46151. }
  46152. }
  46153. declare module BABYLON {
  46154. /** @hidden */
  46155. export class _OcclusionDataStorage {
  46156. /** @hidden */
  46157. occlusionInternalRetryCounter: number;
  46158. /** @hidden */
  46159. isOcclusionQueryInProgress: boolean;
  46160. /** @hidden */
  46161. isOccluded: boolean;
  46162. /** @hidden */
  46163. occlusionRetryCount: number;
  46164. /** @hidden */
  46165. occlusionType: number;
  46166. /** @hidden */
  46167. occlusionQueryAlgorithmType: number;
  46168. }
  46169. interface Engine {
  46170. /**
  46171. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46172. * @return the new query
  46173. */
  46174. createQuery(): WebGLQuery;
  46175. /**
  46176. * Delete and release a webGL query
  46177. * @param query defines the query to delete
  46178. * @return the current engine
  46179. */
  46180. deleteQuery(query: WebGLQuery): Engine;
  46181. /**
  46182. * Check if a given query has resolved and got its value
  46183. * @param query defines the query to check
  46184. * @returns true if the query got its value
  46185. */
  46186. isQueryResultAvailable(query: WebGLQuery): boolean;
  46187. /**
  46188. * Gets the value of a given query
  46189. * @param query defines the query to check
  46190. * @returns the value of the query
  46191. */
  46192. getQueryResult(query: WebGLQuery): number;
  46193. /**
  46194. * Initiates an occlusion query
  46195. * @param algorithmType defines the algorithm to use
  46196. * @param query defines the query to use
  46197. * @returns the current engine
  46198. * @see http://doc.babylonjs.com/features/occlusionquery
  46199. */
  46200. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46201. /**
  46202. * Ends an occlusion query
  46203. * @see http://doc.babylonjs.com/features/occlusionquery
  46204. * @param algorithmType defines the algorithm to use
  46205. * @returns the current engine
  46206. */
  46207. endOcclusionQuery(algorithmType: number): Engine;
  46208. /**
  46209. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46210. * Please note that only one query can be issued at a time
  46211. * @returns a time token used to track the time span
  46212. */
  46213. startTimeQuery(): Nullable<_TimeToken>;
  46214. /**
  46215. * Ends a time query
  46216. * @param token defines the token used to measure the time span
  46217. * @returns the time spent (in ns)
  46218. */
  46219. endTimeQuery(token: _TimeToken): int;
  46220. /** @hidden */
  46221. _currentNonTimestampToken: Nullable<_TimeToken>;
  46222. /** @hidden */
  46223. _createTimeQuery(): WebGLQuery;
  46224. /** @hidden */
  46225. _deleteTimeQuery(query: WebGLQuery): void;
  46226. /** @hidden */
  46227. _getGlAlgorithmType(algorithmType: number): number;
  46228. /** @hidden */
  46229. _getTimeQueryResult(query: WebGLQuery): any;
  46230. /** @hidden */
  46231. _getTimeQueryAvailability(query: WebGLQuery): any;
  46232. }
  46233. interface AbstractMesh {
  46234. /**
  46235. * Backing filed
  46236. * @hidden
  46237. */
  46238. __occlusionDataStorage: _OcclusionDataStorage;
  46239. /**
  46240. * Access property
  46241. * @hidden
  46242. */
  46243. _occlusionDataStorage: _OcclusionDataStorage;
  46244. /**
  46245. * 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.
  46246. * The default value is -1 which means don't break the query and wait till the result
  46247. * @see http://doc.babylonjs.com/features/occlusionquery
  46248. */
  46249. occlusionRetryCount: number;
  46250. /**
  46251. * 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:
  46252. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46253. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46254. * * 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.
  46255. * @see http://doc.babylonjs.com/features/occlusionquery
  46256. */
  46257. occlusionType: number;
  46258. /**
  46259. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46260. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46261. * * 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.
  46262. * @see http://doc.babylonjs.com/features/occlusionquery
  46263. */
  46264. occlusionQueryAlgorithmType: number;
  46265. /**
  46266. * 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
  46267. * @see http://doc.babylonjs.com/features/occlusionquery
  46268. */
  46269. isOccluded: boolean;
  46270. /**
  46271. * Flag to check the progress status of the query
  46272. * @see http://doc.babylonjs.com/features/occlusionquery
  46273. */
  46274. isOcclusionQueryInProgress: boolean;
  46275. }
  46276. }
  46277. declare module BABYLON {
  46278. /** @hidden */
  46279. export var _forceTransformFeedbackToBundle: boolean;
  46280. interface Engine {
  46281. /**
  46282. * Creates a webGL transform feedback object
  46283. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46284. * @returns the webGL transform feedback object
  46285. */
  46286. createTransformFeedback(): WebGLTransformFeedback;
  46287. /**
  46288. * Delete a webGL transform feedback object
  46289. * @param value defines the webGL transform feedback object to delete
  46290. */
  46291. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46292. /**
  46293. * Bind a webGL transform feedback object to the webgl context
  46294. * @param value defines the webGL transform feedback object to bind
  46295. */
  46296. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46297. /**
  46298. * Begins a transform feedback operation
  46299. * @param usePoints defines if points or triangles must be used
  46300. */
  46301. beginTransformFeedback(usePoints: boolean): void;
  46302. /**
  46303. * Ends a transform feedback operation
  46304. */
  46305. endTransformFeedback(): void;
  46306. /**
  46307. * Specify the varyings to use with transform feedback
  46308. * @param program defines the associated webGL program
  46309. * @param value defines the list of strings representing the varying names
  46310. */
  46311. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46312. /**
  46313. * Bind a webGL buffer for a transform feedback operation
  46314. * @param value defines the webGL buffer to bind
  46315. */
  46316. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46317. }
  46318. }
  46319. declare module BABYLON {
  46320. /**
  46321. * Creation options of the multi render target texture.
  46322. */
  46323. export interface IMultiRenderTargetOptions {
  46324. /**
  46325. * Define if the texture needs to create mip maps after render.
  46326. */
  46327. generateMipMaps?: boolean;
  46328. /**
  46329. * Define the types of all the draw buffers we want to create
  46330. */
  46331. types?: number[];
  46332. /**
  46333. * Define the sampling modes of all the draw buffers we want to create
  46334. */
  46335. samplingModes?: number[];
  46336. /**
  46337. * Define if a depth buffer is required
  46338. */
  46339. generateDepthBuffer?: boolean;
  46340. /**
  46341. * Define if a stencil buffer is required
  46342. */
  46343. generateStencilBuffer?: boolean;
  46344. /**
  46345. * Define if a depth texture is required instead of a depth buffer
  46346. */
  46347. generateDepthTexture?: boolean;
  46348. /**
  46349. * Define the number of desired draw buffers
  46350. */
  46351. textureCount?: number;
  46352. /**
  46353. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46354. */
  46355. doNotChangeAspectRatio?: boolean;
  46356. /**
  46357. * Define the default type of the buffers we are creating
  46358. */
  46359. defaultType?: number;
  46360. }
  46361. /**
  46362. * A multi render target, like a render target provides the ability to render to a texture.
  46363. * Unlike the render target, it can render to several draw buffers in one draw.
  46364. * This is specially interesting in deferred rendering or for any effects requiring more than
  46365. * just one color from a single pass.
  46366. */
  46367. export class MultiRenderTarget extends RenderTargetTexture {
  46368. private _internalTextures;
  46369. private _textures;
  46370. private _multiRenderTargetOptions;
  46371. /**
  46372. * Get if draw buffers are currently supported by the used hardware and browser.
  46373. */
  46374. get isSupported(): boolean;
  46375. /**
  46376. * Get the list of textures generated by the multi render target.
  46377. */
  46378. get textures(): Texture[];
  46379. /**
  46380. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46381. */
  46382. get depthTexture(): Texture;
  46383. /**
  46384. * Set the wrapping mode on U of all the textures we are rendering to.
  46385. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46386. */
  46387. set wrapU(wrap: number);
  46388. /**
  46389. * Set the wrapping mode on V of all the textures we are rendering to.
  46390. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46391. */
  46392. set wrapV(wrap: number);
  46393. /**
  46394. * Instantiate a new multi render target texture.
  46395. * A multi render target, like a render target provides the ability to render to a texture.
  46396. * Unlike the render target, it can render to several draw buffers in one draw.
  46397. * This is specially interesting in deferred rendering or for any effects requiring more than
  46398. * just one color from a single pass.
  46399. * @param name Define the name of the texture
  46400. * @param size Define the size of the buffers to render to
  46401. * @param count Define the number of target we are rendering into
  46402. * @param scene Define the scene the texture belongs to
  46403. * @param options Define the options used to create the multi render target
  46404. */
  46405. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46406. /** @hidden */
  46407. _rebuild(): void;
  46408. private _createInternalTextures;
  46409. private _createTextures;
  46410. /**
  46411. * Define the number of samples used if MSAA is enabled.
  46412. */
  46413. get samples(): number;
  46414. set samples(value: number);
  46415. /**
  46416. * Resize all the textures in the multi render target.
  46417. * Be carrefull as it will recreate all the data in the new texture.
  46418. * @param size Define the new size
  46419. */
  46420. resize(size: any): void;
  46421. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46422. /**
  46423. * Dispose the render targets and their associated resources
  46424. */
  46425. dispose(): void;
  46426. /**
  46427. * Release all the underlying texture used as draw buffers.
  46428. */
  46429. releaseInternalTextures(): void;
  46430. }
  46431. }
  46432. declare module BABYLON {
  46433. interface ThinEngine {
  46434. /**
  46435. * Unbind a list of render target textures from the webGL context
  46436. * This is used only when drawBuffer extension or webGL2 are active
  46437. * @param textures defines the render target textures to unbind
  46438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46440. */
  46441. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46442. /**
  46443. * Create a multi render target texture
  46444. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46445. * @param size defines the size of the texture
  46446. * @param options defines the creation options
  46447. * @returns the cube texture as an InternalTexture
  46448. */
  46449. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46450. /**
  46451. * Update the sample count for a given multiple render target texture
  46452. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46453. * @param textures defines the textures to update
  46454. * @param samples defines the sample count to set
  46455. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46456. */
  46457. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46458. }
  46459. }
  46460. declare module BABYLON {
  46461. /**
  46462. * Class used to define an additional view for the engine
  46463. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46464. */
  46465. export class EngineView {
  46466. /** Defines the canvas where to render the view */
  46467. target: HTMLCanvasElement;
  46468. /** Defines an optional camera used to render the view (will use active camera else) */
  46469. camera?: Camera;
  46470. }
  46471. interface Engine {
  46472. /**
  46473. * Gets or sets the HTML element to use for attaching events
  46474. */
  46475. inputElement: Nullable<HTMLElement>;
  46476. /**
  46477. * Gets the current engine view
  46478. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46479. */
  46480. activeView: Nullable<EngineView>;
  46481. /** Gets or sets the list of views */
  46482. views: EngineView[];
  46483. /**
  46484. * Register a new child canvas
  46485. * @param canvas defines the canvas to register
  46486. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46487. * @returns the associated view
  46488. */
  46489. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46490. /**
  46491. * Remove a registered child canvas
  46492. * @param canvas defines the canvas to remove
  46493. * @returns the current engine
  46494. */
  46495. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46496. }
  46497. }
  46498. declare module BABYLON {
  46499. /**
  46500. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46501. */
  46502. export interface CubeMapInfo {
  46503. /**
  46504. * The pixel array for the front face.
  46505. * This is stored in format, left to right, up to down format.
  46506. */
  46507. front: Nullable<ArrayBufferView>;
  46508. /**
  46509. * The pixel array for the back face.
  46510. * This is stored in format, left to right, up to down format.
  46511. */
  46512. back: Nullable<ArrayBufferView>;
  46513. /**
  46514. * The pixel array for the left face.
  46515. * This is stored in format, left to right, up to down format.
  46516. */
  46517. left: Nullable<ArrayBufferView>;
  46518. /**
  46519. * The pixel array for the right face.
  46520. * This is stored in format, left to right, up to down format.
  46521. */
  46522. right: Nullable<ArrayBufferView>;
  46523. /**
  46524. * The pixel array for the up face.
  46525. * This is stored in format, left to right, up to down format.
  46526. */
  46527. up: Nullable<ArrayBufferView>;
  46528. /**
  46529. * The pixel array for the down face.
  46530. * This is stored in format, left to right, up to down format.
  46531. */
  46532. down: Nullable<ArrayBufferView>;
  46533. /**
  46534. * The size of the cubemap stored.
  46535. *
  46536. * Each faces will be size * size pixels.
  46537. */
  46538. size: number;
  46539. /**
  46540. * The format of the texture.
  46541. *
  46542. * RGBA, RGB.
  46543. */
  46544. format: number;
  46545. /**
  46546. * The type of the texture data.
  46547. *
  46548. * UNSIGNED_INT, FLOAT.
  46549. */
  46550. type: number;
  46551. /**
  46552. * Specifies whether the texture is in gamma space.
  46553. */
  46554. gammaSpace: boolean;
  46555. }
  46556. /**
  46557. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46558. */
  46559. export class PanoramaToCubeMapTools {
  46560. private static FACE_FRONT;
  46561. private static FACE_BACK;
  46562. private static FACE_RIGHT;
  46563. private static FACE_LEFT;
  46564. private static FACE_DOWN;
  46565. private static FACE_UP;
  46566. /**
  46567. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46568. *
  46569. * @param float32Array The source data.
  46570. * @param inputWidth The width of the input panorama.
  46571. * @param inputHeight The height of the input panorama.
  46572. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46573. * @return The cubemap data
  46574. */
  46575. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46576. private static CreateCubemapTexture;
  46577. private static CalcProjectionSpherical;
  46578. }
  46579. }
  46580. declare module BABYLON {
  46581. /**
  46582. * Helper class dealing with the extraction of spherical polynomial dataArray
  46583. * from a cube map.
  46584. */
  46585. export class CubeMapToSphericalPolynomialTools {
  46586. private static FileFaces;
  46587. /**
  46588. * Converts a texture to the according Spherical Polynomial data.
  46589. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46590. *
  46591. * @param texture The texture to extract the information from.
  46592. * @return The Spherical Polynomial data.
  46593. */
  46594. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46595. /**
  46596. * Converts a cubemap to the according Spherical Polynomial data.
  46597. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46598. *
  46599. * @param cubeInfo The Cube map to extract the information from.
  46600. * @return The Spherical Polynomial data.
  46601. */
  46602. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46603. }
  46604. }
  46605. declare module BABYLON {
  46606. interface BaseTexture {
  46607. /**
  46608. * Get the polynomial representation of the texture data.
  46609. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46610. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46611. */
  46612. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46613. }
  46614. }
  46615. declare module BABYLON {
  46616. /** @hidden */
  46617. export var rgbdEncodePixelShader: {
  46618. name: string;
  46619. shader: string;
  46620. };
  46621. }
  46622. declare module BABYLON {
  46623. /** @hidden */
  46624. export var rgbdDecodePixelShader: {
  46625. name: string;
  46626. shader: string;
  46627. };
  46628. }
  46629. declare module BABYLON {
  46630. /**
  46631. * Raw texture data and descriptor sufficient for WebGL texture upload
  46632. */
  46633. export interface EnvironmentTextureInfo {
  46634. /**
  46635. * Version of the environment map
  46636. */
  46637. version: number;
  46638. /**
  46639. * Width of image
  46640. */
  46641. width: number;
  46642. /**
  46643. * Irradiance information stored in the file.
  46644. */
  46645. irradiance: any;
  46646. /**
  46647. * Specular information stored in the file.
  46648. */
  46649. specular: any;
  46650. }
  46651. /**
  46652. * Defines One Image in the file. It requires only the position in the file
  46653. * as well as the length.
  46654. */
  46655. interface BufferImageData {
  46656. /**
  46657. * Length of the image data.
  46658. */
  46659. length: number;
  46660. /**
  46661. * Position of the data from the null terminator delimiting the end of the JSON.
  46662. */
  46663. position: number;
  46664. }
  46665. /**
  46666. * Defines the specular data enclosed in the file.
  46667. * This corresponds to the version 1 of the data.
  46668. */
  46669. export interface EnvironmentTextureSpecularInfoV1 {
  46670. /**
  46671. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46672. */
  46673. specularDataPosition?: number;
  46674. /**
  46675. * This contains all the images data needed to reconstruct the cubemap.
  46676. */
  46677. mipmaps: Array<BufferImageData>;
  46678. /**
  46679. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46680. */
  46681. lodGenerationScale: number;
  46682. }
  46683. /**
  46684. * Sets of helpers addressing the serialization and deserialization of environment texture
  46685. * stored in a BabylonJS env file.
  46686. * Those files are usually stored as .env files.
  46687. */
  46688. export class EnvironmentTextureTools {
  46689. /**
  46690. * Magic number identifying the env file.
  46691. */
  46692. private static _MagicBytes;
  46693. /**
  46694. * Gets the environment info from an env file.
  46695. * @param data The array buffer containing the .env bytes.
  46696. * @returns the environment file info (the json header) if successfully parsed.
  46697. */
  46698. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46699. /**
  46700. * Creates an environment texture from a loaded cube texture.
  46701. * @param texture defines the cube texture to convert in env file
  46702. * @return a promise containing the environment data if succesfull.
  46703. */
  46704. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46705. /**
  46706. * Creates a JSON representation of the spherical data.
  46707. * @param texture defines the texture containing the polynomials
  46708. * @return the JSON representation of the spherical info
  46709. */
  46710. private static _CreateEnvTextureIrradiance;
  46711. /**
  46712. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46713. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46714. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46715. * @return the views described by info providing access to the underlying buffer
  46716. */
  46717. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46718. /**
  46719. * Uploads the texture info contained in the env file to the GPU.
  46720. * @param texture defines the internal texture to upload to
  46721. * @param arrayBuffer defines the buffer cotaining the data to load
  46722. * @param info defines the texture info retrieved through the GetEnvInfo method
  46723. * @returns a promise
  46724. */
  46725. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46726. private static _OnImageReadyAsync;
  46727. /**
  46728. * Uploads the levels of image data to the GPU.
  46729. * @param texture defines the internal texture to upload to
  46730. * @param imageData defines the array buffer views of image data [mipmap][face]
  46731. * @returns a promise
  46732. */
  46733. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46734. /**
  46735. * Uploads spherical polynomials information to the texture.
  46736. * @param texture defines the texture we are trying to upload the information to
  46737. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46738. */
  46739. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46740. /** @hidden */
  46741. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46742. }
  46743. }
  46744. declare module BABYLON {
  46745. /**
  46746. * Contains position and normal vectors for a vertex
  46747. */
  46748. export class PositionNormalVertex {
  46749. /** the position of the vertex (defaut: 0,0,0) */
  46750. position: Vector3;
  46751. /** the normal of the vertex (defaut: 0,1,0) */
  46752. normal: Vector3;
  46753. /**
  46754. * Creates a PositionNormalVertex
  46755. * @param position the position of the vertex (defaut: 0,0,0)
  46756. * @param normal the normal of the vertex (defaut: 0,1,0)
  46757. */
  46758. constructor(
  46759. /** the position of the vertex (defaut: 0,0,0) */
  46760. position?: Vector3,
  46761. /** the normal of the vertex (defaut: 0,1,0) */
  46762. normal?: Vector3);
  46763. /**
  46764. * Clones the PositionNormalVertex
  46765. * @returns the cloned PositionNormalVertex
  46766. */
  46767. clone(): PositionNormalVertex;
  46768. }
  46769. /**
  46770. * Contains position, normal and uv vectors for a vertex
  46771. */
  46772. export class PositionNormalTextureVertex {
  46773. /** the position of the vertex (defaut: 0,0,0) */
  46774. position: Vector3;
  46775. /** the normal of the vertex (defaut: 0,1,0) */
  46776. normal: Vector3;
  46777. /** the uv of the vertex (default: 0,0) */
  46778. uv: Vector2;
  46779. /**
  46780. * Creates a PositionNormalTextureVertex
  46781. * @param position the position of the vertex (defaut: 0,0,0)
  46782. * @param normal the normal of the vertex (defaut: 0,1,0)
  46783. * @param uv the uv of the vertex (default: 0,0)
  46784. */
  46785. constructor(
  46786. /** the position of the vertex (defaut: 0,0,0) */
  46787. position?: Vector3,
  46788. /** the normal of the vertex (defaut: 0,1,0) */
  46789. normal?: Vector3,
  46790. /** the uv of the vertex (default: 0,0) */
  46791. uv?: Vector2);
  46792. /**
  46793. * Clones the PositionNormalTextureVertex
  46794. * @returns the cloned PositionNormalTextureVertex
  46795. */
  46796. clone(): PositionNormalTextureVertex;
  46797. }
  46798. }
  46799. declare module BABYLON {
  46800. /** @hidden */
  46801. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46802. private _genericAttributeLocation;
  46803. private _varyingLocationCount;
  46804. private _varyingLocationMap;
  46805. private _replacements;
  46806. private _textureCount;
  46807. private _uniforms;
  46808. lineProcessor(line: string): string;
  46809. attributeProcessor(attribute: string): string;
  46810. varyingProcessor(varying: string, isFragment: boolean): string;
  46811. uniformProcessor(uniform: string): string;
  46812. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46813. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46814. }
  46815. }
  46816. declare module BABYLON {
  46817. /**
  46818. * Container for accessors for natively-stored mesh data buffers.
  46819. */
  46820. class NativeDataBuffer extends DataBuffer {
  46821. /**
  46822. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46823. */
  46824. nativeIndexBuffer?: any;
  46825. /**
  46826. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46827. */
  46828. nativeVertexBuffer?: any;
  46829. }
  46830. /** @hidden */
  46831. class NativeTexture extends InternalTexture {
  46832. getInternalTexture(): InternalTexture;
  46833. getViewCount(): number;
  46834. }
  46835. /** @hidden */
  46836. export class NativeEngine extends Engine {
  46837. private readonly _native;
  46838. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46839. private readonly INVALID_HANDLE;
  46840. getHardwareScalingLevel(): number;
  46841. constructor();
  46842. /**
  46843. * Can be used to override the current requestAnimationFrame requester.
  46844. * @hidden
  46845. */
  46846. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46847. /**
  46848. * Override default engine behavior.
  46849. * @param color
  46850. * @param backBuffer
  46851. * @param depth
  46852. * @param stencil
  46853. */
  46854. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46855. /**
  46856. * Gets host document
  46857. * @returns the host document object
  46858. */
  46859. getHostDocument(): Nullable<Document>;
  46860. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46861. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46862. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46863. recordVertexArrayObject(vertexBuffers: {
  46864. [key: string]: VertexBuffer;
  46865. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46866. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46867. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46868. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46869. /**
  46870. * Draw a list of indexed primitives
  46871. * @param fillMode defines the primitive to use
  46872. * @param indexStart defines the starting index
  46873. * @param indexCount defines the number of index to draw
  46874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46875. */
  46876. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46877. /**
  46878. * Draw a list of unindexed primitives
  46879. * @param fillMode defines the primitive to use
  46880. * @param verticesStart defines the index of first vertex to draw
  46881. * @param verticesCount defines the count of vertices to draw
  46882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46883. */
  46884. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46885. createPipelineContext(): IPipelineContext;
  46886. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46887. /** @hidden */
  46888. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46889. /** @hidden */
  46890. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46891. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46892. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46893. protected _setProgram(program: WebGLProgram): void;
  46894. _releaseEffect(effect: Effect): void;
  46895. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46896. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46897. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46898. bindSamplers(effect: Effect): void;
  46899. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46900. getRenderWidth(useScreen?: boolean): number;
  46901. getRenderHeight(useScreen?: boolean): number;
  46902. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46903. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46904. /**
  46905. * Set the z offset to apply to current rendering
  46906. * @param value defines the offset to apply
  46907. */
  46908. setZOffset(value: number): void;
  46909. /**
  46910. * Gets the current value of the zOffset
  46911. * @returns the current zOffset state
  46912. */
  46913. getZOffset(): number;
  46914. /**
  46915. * Enable or disable depth buffering
  46916. * @param enable defines the state to set
  46917. */
  46918. setDepthBuffer(enable: boolean): void;
  46919. /**
  46920. * Gets a boolean indicating if depth writing is enabled
  46921. * @returns the current depth writing state
  46922. */
  46923. getDepthWrite(): boolean;
  46924. /**
  46925. * Enable or disable depth writing
  46926. * @param enable defines the state to set
  46927. */
  46928. setDepthWrite(enable: boolean): void;
  46929. /**
  46930. * Enable or disable color writing
  46931. * @param enable defines the state to set
  46932. */
  46933. setColorWrite(enable: boolean): void;
  46934. /**
  46935. * Gets a boolean indicating if color writing is enabled
  46936. * @returns the current color writing state
  46937. */
  46938. getColorWrite(): boolean;
  46939. /**
  46940. * Sets alpha constants used by some alpha blending modes
  46941. * @param r defines the red component
  46942. * @param g defines the green component
  46943. * @param b defines the blue component
  46944. * @param a defines the alpha component
  46945. */
  46946. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46947. /**
  46948. * Sets the current alpha mode
  46949. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46950. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46952. */
  46953. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46954. /**
  46955. * Gets the current alpha mode
  46956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46957. * @returns the current alpha mode
  46958. */
  46959. getAlphaMode(): number;
  46960. setInt(uniform: WebGLUniformLocation, int: number): void;
  46961. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46962. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46963. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46964. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46965. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46966. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46967. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46968. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46969. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46970. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46971. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46972. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46973. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46974. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46975. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46976. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46977. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46978. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46979. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46980. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46981. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46982. wipeCaches(bruteForce?: boolean): void;
  46983. _createTexture(): WebGLTexture;
  46984. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46985. /**
  46986. * Usually called from BABYLON.Texture.ts.
  46987. * Passed information to create a WebGLTexture
  46988. * @param urlArg defines a value which contains one of the following:
  46989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46993. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46994. * @param scene needed for loading to the correct scene
  46995. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46996. * @param onLoad optional callback to be called upon successful completion
  46997. * @param onError optional callback to be called upon failure
  46998. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47001. * @param forcedExtension defines the extension to use to pick the right loader
  47002. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47003. */
  47004. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47005. /**
  47006. * Creates a cube texture
  47007. * @param rootUrl defines the url where the files to load is located
  47008. * @param scene defines the current scene
  47009. * @param files defines the list of files to load (1 per face)
  47010. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47011. * @param onLoad defines an optional callback raised when the texture is loaded
  47012. * @param onError defines an optional callback raised if there is an issue to load the texture
  47013. * @param format defines the format of the data
  47014. * @param forcedExtension defines the extension to use to pick the right loader
  47015. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47016. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47017. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47018. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47019. * @returns the cube texture as an InternalTexture
  47020. */
  47021. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47022. private _getSamplingFilter;
  47023. private static _GetNativeTextureFormat;
  47024. createRenderTargetTexture(size: number | {
  47025. width: number;
  47026. height: number;
  47027. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47028. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47029. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47030. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47031. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47032. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47033. /**
  47034. * Updates a dynamic vertex buffer.
  47035. * @param vertexBuffer the vertex buffer to update
  47036. * @param data the data used to update the vertex buffer
  47037. * @param byteOffset the byte offset of the data (optional)
  47038. * @param byteLength the byte length of the data (optional)
  47039. */
  47040. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47041. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47042. private _updateAnisotropicLevel;
  47043. private _getAddressMode;
  47044. /** @hidden */
  47045. _bindTexture(channel: number, texture: InternalTexture): void;
  47046. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47047. releaseEffects(): void;
  47048. /** @hidden */
  47049. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47050. /** @hidden */
  47051. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47052. /** @hidden */
  47053. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47054. /** @hidden */
  47055. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47056. }
  47057. }
  47058. declare module BABYLON {
  47059. /**
  47060. * Gather the list of clipboard event types as constants.
  47061. */
  47062. export class ClipboardEventTypes {
  47063. /**
  47064. * The clipboard event is fired when a copy command is active (pressed).
  47065. */
  47066. static readonly COPY: number;
  47067. /**
  47068. * The clipboard event is fired when a cut command is active (pressed).
  47069. */
  47070. static readonly CUT: number;
  47071. /**
  47072. * The clipboard event is fired when a paste command is active (pressed).
  47073. */
  47074. static readonly PASTE: number;
  47075. }
  47076. /**
  47077. * This class is used to store clipboard related info for the onClipboardObservable event.
  47078. */
  47079. export class ClipboardInfo {
  47080. /**
  47081. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47082. */
  47083. type: number;
  47084. /**
  47085. * Defines the related dom event
  47086. */
  47087. event: ClipboardEvent;
  47088. /**
  47089. *Creates an instance of ClipboardInfo.
  47090. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47091. * @param event Defines the related dom event
  47092. */
  47093. constructor(
  47094. /**
  47095. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47096. */
  47097. type: number,
  47098. /**
  47099. * Defines the related dom event
  47100. */
  47101. event: ClipboardEvent);
  47102. /**
  47103. * Get the clipboard event's type from the keycode.
  47104. * @param keyCode Defines the keyCode for the current keyboard event.
  47105. * @return {number}
  47106. */
  47107. static GetTypeFromCharacter(keyCode: number): number;
  47108. }
  47109. }
  47110. declare module BABYLON {
  47111. /**
  47112. * Google Daydream controller
  47113. */
  47114. export class DaydreamController extends WebVRController {
  47115. /**
  47116. * Base Url for the controller model.
  47117. */
  47118. static MODEL_BASE_URL: string;
  47119. /**
  47120. * File name for the controller model.
  47121. */
  47122. static MODEL_FILENAME: string;
  47123. /**
  47124. * Gamepad Id prefix used to identify Daydream Controller.
  47125. */
  47126. static readonly GAMEPAD_ID_PREFIX: string;
  47127. /**
  47128. * Creates a new DaydreamController from a gamepad
  47129. * @param vrGamepad the gamepad that the controller should be created from
  47130. */
  47131. constructor(vrGamepad: any);
  47132. /**
  47133. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47134. * @param scene scene in which to add meshes
  47135. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47136. */
  47137. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47138. /**
  47139. * Called once for each button that changed state since the last frame
  47140. * @param buttonIdx Which button index changed
  47141. * @param state New state of the button
  47142. * @param changes Which properties on the state changed since last frame
  47143. */
  47144. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47145. }
  47146. }
  47147. declare module BABYLON {
  47148. /**
  47149. * Gear VR Controller
  47150. */
  47151. export class GearVRController extends WebVRController {
  47152. /**
  47153. * Base Url for the controller model.
  47154. */
  47155. static MODEL_BASE_URL: string;
  47156. /**
  47157. * File name for the controller model.
  47158. */
  47159. static MODEL_FILENAME: string;
  47160. /**
  47161. * Gamepad Id prefix used to identify this controller.
  47162. */
  47163. static readonly GAMEPAD_ID_PREFIX: string;
  47164. private readonly _buttonIndexToObservableNameMap;
  47165. /**
  47166. * Creates a new GearVRController from a gamepad
  47167. * @param vrGamepad the gamepad that the controller should be created from
  47168. */
  47169. constructor(vrGamepad: any);
  47170. /**
  47171. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47172. * @param scene scene in which to add meshes
  47173. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47174. */
  47175. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47176. /**
  47177. * Called once for each button that changed state since the last frame
  47178. * @param buttonIdx Which button index changed
  47179. * @param state New state of the button
  47180. * @param changes Which properties on the state changed since last frame
  47181. */
  47182. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47183. }
  47184. }
  47185. declare module BABYLON {
  47186. /**
  47187. * Class containing static functions to help procedurally build meshes
  47188. */
  47189. export class PolyhedronBuilder {
  47190. /**
  47191. * Creates a polyhedron mesh
  47192. * * 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
  47193. * * The parameter `size` (positive float, default 1) sets the polygon size
  47194. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47195. * * 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`
  47196. * * 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
  47197. * * 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)`)
  47198. * * 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
  47199. * * 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
  47200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47201. * * 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
  47202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47203. * @param name defines the name of the mesh
  47204. * @param options defines the options used to create the mesh
  47205. * @param scene defines the hosting scene
  47206. * @returns the polyhedron mesh
  47207. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47208. */
  47209. static CreatePolyhedron(name: string, options: {
  47210. type?: number;
  47211. size?: number;
  47212. sizeX?: number;
  47213. sizeY?: number;
  47214. sizeZ?: number;
  47215. custom?: any;
  47216. faceUV?: Vector4[];
  47217. faceColors?: Color4[];
  47218. flat?: boolean;
  47219. updatable?: boolean;
  47220. sideOrientation?: number;
  47221. frontUVs?: Vector4;
  47222. backUVs?: Vector4;
  47223. }, scene?: Nullable<Scene>): Mesh;
  47224. }
  47225. }
  47226. declare module BABYLON {
  47227. /**
  47228. * Gizmo that enables scaling a mesh along 3 axis
  47229. */
  47230. export class ScaleGizmo extends Gizmo {
  47231. /**
  47232. * Internal gizmo used for interactions on the x axis
  47233. */
  47234. xGizmo: AxisScaleGizmo;
  47235. /**
  47236. * Internal gizmo used for interactions on the y axis
  47237. */
  47238. yGizmo: AxisScaleGizmo;
  47239. /**
  47240. * Internal gizmo used for interactions on the z axis
  47241. */
  47242. zGizmo: AxisScaleGizmo;
  47243. /**
  47244. * Internal gizmo used to scale all axis equally
  47245. */
  47246. uniformScaleGizmo: AxisScaleGizmo;
  47247. private _meshAttached;
  47248. private _updateGizmoRotationToMatchAttachedMesh;
  47249. private _snapDistance;
  47250. private _scaleRatio;
  47251. private _uniformScalingMesh;
  47252. private _octahedron;
  47253. private _sensitivity;
  47254. /** Fires an event when any of it's sub gizmos are dragged */
  47255. onDragStartObservable: Observable<unknown>;
  47256. /** Fires an event when any of it's sub gizmos are released from dragging */
  47257. onDragEndObservable: Observable<unknown>;
  47258. get attachedMesh(): Nullable<AbstractMesh>;
  47259. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47260. /**
  47261. * Creates a ScaleGizmo
  47262. * @param gizmoLayer The utility layer the gizmo will be added to
  47263. */
  47264. constructor(gizmoLayer?: UtilityLayerRenderer);
  47265. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47266. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47267. /**
  47268. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47269. */
  47270. set snapDistance(value: number);
  47271. get snapDistance(): number;
  47272. /**
  47273. * Ratio for the scale of the gizmo (Default: 1)
  47274. */
  47275. set scaleRatio(value: number);
  47276. get scaleRatio(): number;
  47277. /**
  47278. * Sensitivity factor for dragging (Default: 1)
  47279. */
  47280. set sensitivity(value: number);
  47281. get sensitivity(): number;
  47282. /**
  47283. * Disposes of the gizmo
  47284. */
  47285. dispose(): void;
  47286. }
  47287. }
  47288. declare module BABYLON {
  47289. /**
  47290. * Single axis scale gizmo
  47291. */
  47292. export class AxisScaleGizmo extends Gizmo {
  47293. /**
  47294. * Drag behavior responsible for the gizmos dragging interactions
  47295. */
  47296. dragBehavior: PointerDragBehavior;
  47297. private _pointerObserver;
  47298. /**
  47299. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47300. */
  47301. snapDistance: number;
  47302. /**
  47303. * Event that fires each time the gizmo snaps to a new location.
  47304. * * snapDistance is the the change in distance
  47305. */
  47306. onSnapObservable: Observable<{
  47307. snapDistance: number;
  47308. }>;
  47309. /**
  47310. * If the scaling operation should be done on all axis (default: false)
  47311. */
  47312. uniformScaling: boolean;
  47313. /**
  47314. * Custom sensitivity value for the drag strength
  47315. */
  47316. sensitivity: number;
  47317. private _isEnabled;
  47318. private _parent;
  47319. private _arrow;
  47320. private _coloredMaterial;
  47321. private _hoverMaterial;
  47322. /**
  47323. * Creates an AxisScaleGizmo
  47324. * @param gizmoLayer The utility layer the gizmo will be added to
  47325. * @param dragAxis The axis which the gizmo will be able to scale on
  47326. * @param color The color of the gizmo
  47327. */
  47328. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47329. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47330. /**
  47331. * If the gizmo is enabled
  47332. */
  47333. set isEnabled(value: boolean);
  47334. get isEnabled(): boolean;
  47335. /**
  47336. * Disposes of the gizmo
  47337. */
  47338. dispose(): void;
  47339. /**
  47340. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47341. * @param mesh The mesh to replace the default mesh of the gizmo
  47342. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47343. */
  47344. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47345. }
  47346. }
  47347. declare module BABYLON {
  47348. /**
  47349. * Bounding box gizmo
  47350. */
  47351. export class BoundingBoxGizmo extends Gizmo {
  47352. private _lineBoundingBox;
  47353. private _rotateSpheresParent;
  47354. private _scaleBoxesParent;
  47355. private _boundingDimensions;
  47356. private _renderObserver;
  47357. private _pointerObserver;
  47358. private _scaleDragSpeed;
  47359. private _tmpQuaternion;
  47360. private _tmpVector;
  47361. private _tmpRotationMatrix;
  47362. /**
  47363. * 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)
  47364. */
  47365. ignoreChildren: boolean;
  47366. /**
  47367. * 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)
  47368. */
  47369. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47370. /**
  47371. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47372. */
  47373. rotationSphereSize: number;
  47374. /**
  47375. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47376. */
  47377. scaleBoxSize: number;
  47378. /**
  47379. * 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)
  47380. */
  47381. fixedDragMeshScreenSize: boolean;
  47382. /**
  47383. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47384. */
  47385. fixedDragMeshScreenSizeDistanceFactor: number;
  47386. /**
  47387. * Fired when a rotation sphere or scale box is dragged
  47388. */
  47389. onDragStartObservable: Observable<{}>;
  47390. /**
  47391. * Fired when a scale box is dragged
  47392. */
  47393. onScaleBoxDragObservable: Observable<{}>;
  47394. /**
  47395. * Fired when a scale box drag is ended
  47396. */
  47397. onScaleBoxDragEndObservable: Observable<{}>;
  47398. /**
  47399. * Fired when a rotation sphere is dragged
  47400. */
  47401. onRotationSphereDragObservable: Observable<{}>;
  47402. /**
  47403. * Fired when a rotation sphere drag is ended
  47404. */
  47405. onRotationSphereDragEndObservable: Observable<{}>;
  47406. /**
  47407. * 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)
  47408. */
  47409. scalePivot: Nullable<Vector3>;
  47410. /**
  47411. * Mesh used as a pivot to rotate the attached mesh
  47412. */
  47413. private _anchorMesh;
  47414. private _existingMeshScale;
  47415. private _dragMesh;
  47416. private pointerDragBehavior;
  47417. private coloredMaterial;
  47418. private hoverColoredMaterial;
  47419. /**
  47420. * Sets the color of the bounding box gizmo
  47421. * @param color the color to set
  47422. */
  47423. setColor(color: Color3): void;
  47424. /**
  47425. * Creates an BoundingBoxGizmo
  47426. * @param gizmoLayer The utility layer the gizmo will be added to
  47427. * @param color The color of the gizmo
  47428. */
  47429. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47431. private _selectNode;
  47432. /**
  47433. * Updates the bounding box information for the Gizmo
  47434. */
  47435. updateBoundingBox(): void;
  47436. private _updateRotationSpheres;
  47437. private _updateScaleBoxes;
  47438. /**
  47439. * Enables rotation on the specified axis and disables rotation on the others
  47440. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47441. */
  47442. setEnabledRotationAxis(axis: string): void;
  47443. /**
  47444. * Enables/disables scaling
  47445. * @param enable if scaling should be enabled
  47446. */
  47447. setEnabledScaling(enable: boolean): void;
  47448. private _updateDummy;
  47449. /**
  47450. * Enables a pointer drag behavior on the bounding box of the gizmo
  47451. */
  47452. enableDragBehavior(): void;
  47453. /**
  47454. * Disposes of the gizmo
  47455. */
  47456. dispose(): void;
  47457. /**
  47458. * 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)
  47459. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47460. * @returns the bounding box mesh with the passed in mesh as a child
  47461. */
  47462. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47463. /**
  47464. * CustomMeshes are not supported by this gizmo
  47465. * @param mesh The mesh to replace the default mesh of the gizmo
  47466. */
  47467. setCustomMesh(mesh: Mesh): void;
  47468. }
  47469. }
  47470. declare module BABYLON {
  47471. /**
  47472. * Single plane rotation gizmo
  47473. */
  47474. export class PlaneRotationGizmo extends Gizmo {
  47475. /**
  47476. * Drag behavior responsible for the gizmos dragging interactions
  47477. */
  47478. dragBehavior: PointerDragBehavior;
  47479. private _pointerObserver;
  47480. /**
  47481. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47482. */
  47483. snapDistance: number;
  47484. /**
  47485. * Event that fires each time the gizmo snaps to a new location.
  47486. * * snapDistance is the the change in distance
  47487. */
  47488. onSnapObservable: Observable<{
  47489. snapDistance: number;
  47490. }>;
  47491. private _isEnabled;
  47492. private _parent;
  47493. /**
  47494. * Creates a PlaneRotationGizmo
  47495. * @param gizmoLayer The utility layer the gizmo will be added to
  47496. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47497. * @param color The color of the gizmo
  47498. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47499. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47500. */
  47501. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47502. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47503. /**
  47504. * If the gizmo is enabled
  47505. */
  47506. set isEnabled(value: boolean);
  47507. get isEnabled(): boolean;
  47508. /**
  47509. * Disposes of the gizmo
  47510. */
  47511. dispose(): void;
  47512. }
  47513. }
  47514. declare module BABYLON {
  47515. /**
  47516. * Gizmo that enables rotating a mesh along 3 axis
  47517. */
  47518. export class RotationGizmo extends Gizmo {
  47519. /**
  47520. * Internal gizmo used for interactions on the x axis
  47521. */
  47522. xGizmo: PlaneRotationGizmo;
  47523. /**
  47524. * Internal gizmo used for interactions on the y axis
  47525. */
  47526. yGizmo: PlaneRotationGizmo;
  47527. /**
  47528. * Internal gizmo used for interactions on the z axis
  47529. */
  47530. zGizmo: PlaneRotationGizmo;
  47531. /** Fires an event when any of it's sub gizmos are dragged */
  47532. onDragStartObservable: Observable<unknown>;
  47533. /** Fires an event when any of it's sub gizmos are released from dragging */
  47534. onDragEndObservable: Observable<unknown>;
  47535. private _meshAttached;
  47536. get attachedMesh(): Nullable<AbstractMesh>;
  47537. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47538. /**
  47539. * Creates a RotationGizmo
  47540. * @param gizmoLayer The utility layer the gizmo will be added to
  47541. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47542. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47543. */
  47544. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47545. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47546. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47547. /**
  47548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47549. */
  47550. set snapDistance(value: number);
  47551. get snapDistance(): number;
  47552. /**
  47553. * Ratio for the scale of the gizmo (Default: 1)
  47554. */
  47555. set scaleRatio(value: number);
  47556. get scaleRatio(): number;
  47557. /**
  47558. * Disposes of the gizmo
  47559. */
  47560. dispose(): void;
  47561. /**
  47562. * CustomMeshes are not supported by this gizmo
  47563. * @param mesh The mesh to replace the default mesh of the gizmo
  47564. */
  47565. setCustomMesh(mesh: Mesh): void;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /**
  47570. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47571. */
  47572. export class GizmoManager implements IDisposable {
  47573. private scene;
  47574. /**
  47575. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47576. */
  47577. gizmos: {
  47578. positionGizmo: Nullable<PositionGizmo>;
  47579. rotationGizmo: Nullable<RotationGizmo>;
  47580. scaleGizmo: Nullable<ScaleGizmo>;
  47581. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47582. };
  47583. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47584. clearGizmoOnEmptyPointerEvent: boolean;
  47585. /** Fires an event when the manager is attached to a mesh */
  47586. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47587. private _gizmosEnabled;
  47588. private _pointerObserver;
  47589. private _attachedMesh;
  47590. private _boundingBoxColor;
  47591. private _defaultUtilityLayer;
  47592. private _defaultKeepDepthUtilityLayer;
  47593. /**
  47594. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47595. */
  47596. boundingBoxDragBehavior: SixDofDragBehavior;
  47597. /**
  47598. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47599. */
  47600. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47601. /**
  47602. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47603. */
  47604. usePointerToAttachGizmos: boolean;
  47605. /**
  47606. * Utility layer that the bounding box gizmo belongs to
  47607. */
  47608. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47609. /**
  47610. * Utility layer that all gizmos besides bounding box belong to
  47611. */
  47612. get utilityLayer(): UtilityLayerRenderer;
  47613. /**
  47614. * Instatiates a gizmo manager
  47615. * @param scene the scene to overlay the gizmos on top of
  47616. */
  47617. constructor(scene: Scene);
  47618. /**
  47619. * Attaches a set of gizmos to the specified mesh
  47620. * @param mesh The mesh the gizmo's should be attached to
  47621. */
  47622. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47623. /**
  47624. * If the position gizmo is enabled
  47625. */
  47626. set positionGizmoEnabled(value: boolean);
  47627. get positionGizmoEnabled(): boolean;
  47628. /**
  47629. * If the rotation gizmo is enabled
  47630. */
  47631. set rotationGizmoEnabled(value: boolean);
  47632. get rotationGizmoEnabled(): boolean;
  47633. /**
  47634. * If the scale gizmo is enabled
  47635. */
  47636. set scaleGizmoEnabled(value: boolean);
  47637. get scaleGizmoEnabled(): boolean;
  47638. /**
  47639. * If the boundingBox gizmo is enabled
  47640. */
  47641. set boundingBoxGizmoEnabled(value: boolean);
  47642. get boundingBoxGizmoEnabled(): boolean;
  47643. /**
  47644. * Disposes of the gizmo manager
  47645. */
  47646. dispose(): void;
  47647. }
  47648. }
  47649. declare module BABYLON {
  47650. /**
  47651. * A directional light is defined by a direction (what a surprise!).
  47652. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47653. * 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.
  47654. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47655. */
  47656. export class DirectionalLight extends ShadowLight {
  47657. private _shadowFrustumSize;
  47658. /**
  47659. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47660. */
  47661. get shadowFrustumSize(): number;
  47662. /**
  47663. * Specifies a fix frustum size for the shadow generation.
  47664. */
  47665. set shadowFrustumSize(value: number);
  47666. private _shadowOrthoScale;
  47667. /**
  47668. * Gets the shadow projection scale against the optimal computed one.
  47669. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47670. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47671. */
  47672. get shadowOrthoScale(): number;
  47673. /**
  47674. * Sets the shadow projection scale against the optimal computed one.
  47675. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47676. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47677. */
  47678. set shadowOrthoScale(value: number);
  47679. /**
  47680. * Automatically compute the projection matrix to best fit (including all the casters)
  47681. * on each frame.
  47682. */
  47683. autoUpdateExtends: boolean;
  47684. private _orthoLeft;
  47685. private _orthoRight;
  47686. private _orthoTop;
  47687. private _orthoBottom;
  47688. /**
  47689. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47690. * The directional light is emitted from everywhere in the given direction.
  47691. * It can cast shadows.
  47692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47693. * @param name The friendly name of the light
  47694. * @param direction The direction of the light
  47695. * @param scene The scene the light belongs to
  47696. */
  47697. constructor(name: string, direction: Vector3, scene: Scene);
  47698. /**
  47699. * Returns the string "DirectionalLight".
  47700. * @return The class name
  47701. */
  47702. getClassName(): string;
  47703. /**
  47704. * Returns the integer 1.
  47705. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47706. */
  47707. getTypeID(): number;
  47708. /**
  47709. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47710. * Returns the DirectionalLight Shadow projection matrix.
  47711. */
  47712. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47713. /**
  47714. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47715. * Returns the DirectionalLight Shadow projection matrix.
  47716. */
  47717. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47718. /**
  47719. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47720. * Returns the DirectionalLight Shadow projection matrix.
  47721. */
  47722. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47723. protected _buildUniformLayout(): void;
  47724. /**
  47725. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47726. * @param effect The effect to update
  47727. * @param lightIndex The index of the light in the effect to update
  47728. * @returns The directional light
  47729. */
  47730. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47731. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47732. /**
  47733. * Gets the minZ used for shadow according to both the scene and the light.
  47734. *
  47735. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47736. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47737. * @param activeCamera The camera we are returning the min for
  47738. * @returns the depth min z
  47739. */
  47740. getDepthMinZ(activeCamera: Camera): number;
  47741. /**
  47742. * Gets the maxZ used for shadow according to both the scene and the light.
  47743. *
  47744. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47745. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47746. * @param activeCamera The camera we are returning the max for
  47747. * @returns the depth max z
  47748. */
  47749. getDepthMaxZ(activeCamera: Camera): number;
  47750. /**
  47751. * Prepares the list of defines specific to the light type.
  47752. * @param defines the list of defines
  47753. * @param lightIndex defines the index of the light for the effect
  47754. */
  47755. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47756. }
  47757. }
  47758. declare module BABYLON {
  47759. /**
  47760. * Class containing static functions to help procedurally build meshes
  47761. */
  47762. export class HemisphereBuilder {
  47763. /**
  47764. * Creates a hemisphere mesh
  47765. * @param name defines the name of the mesh
  47766. * @param options defines the options used to create the mesh
  47767. * @param scene defines the hosting scene
  47768. * @returns the hemisphere mesh
  47769. */
  47770. static CreateHemisphere(name: string, options: {
  47771. segments?: number;
  47772. diameter?: number;
  47773. sideOrientation?: number;
  47774. }, scene: any): Mesh;
  47775. }
  47776. }
  47777. declare module BABYLON {
  47778. /**
  47779. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47780. * These values define a cone of light starting from the position, emitting toward the direction.
  47781. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47782. * and the exponent defines the speed of the decay of the light with distance (reach).
  47783. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47784. */
  47785. export class SpotLight extends ShadowLight {
  47786. private _angle;
  47787. private _innerAngle;
  47788. private _cosHalfAngle;
  47789. private _lightAngleScale;
  47790. private _lightAngleOffset;
  47791. /**
  47792. * Gets the cone angle of the spot light in Radians.
  47793. */
  47794. get angle(): number;
  47795. /**
  47796. * Sets the cone angle of the spot light in Radians.
  47797. */
  47798. set angle(value: number);
  47799. /**
  47800. * Only used in gltf falloff mode, this defines the angle where
  47801. * the directional falloff will start before cutting at angle which could be seen
  47802. * as outer angle.
  47803. */
  47804. get innerAngle(): number;
  47805. /**
  47806. * Only used in gltf falloff mode, this defines the angle where
  47807. * the directional falloff will start before cutting at angle which could be seen
  47808. * as outer angle.
  47809. */
  47810. set innerAngle(value: number);
  47811. private _shadowAngleScale;
  47812. /**
  47813. * Allows scaling the angle of the light for shadow generation only.
  47814. */
  47815. get shadowAngleScale(): number;
  47816. /**
  47817. * Allows scaling the angle of the light for shadow generation only.
  47818. */
  47819. set shadowAngleScale(value: number);
  47820. /**
  47821. * The light decay speed with the distance from the emission spot.
  47822. */
  47823. exponent: number;
  47824. private _projectionTextureMatrix;
  47825. /**
  47826. * Allows reading the projecton texture
  47827. */
  47828. get projectionTextureMatrix(): Matrix;
  47829. protected _projectionTextureLightNear: number;
  47830. /**
  47831. * Gets the near clip of the Spotlight for texture projection.
  47832. */
  47833. get projectionTextureLightNear(): number;
  47834. /**
  47835. * Sets the near clip of the Spotlight for texture projection.
  47836. */
  47837. set projectionTextureLightNear(value: number);
  47838. protected _projectionTextureLightFar: number;
  47839. /**
  47840. * Gets the far clip of the Spotlight for texture projection.
  47841. */
  47842. get projectionTextureLightFar(): number;
  47843. /**
  47844. * Sets the far clip of the Spotlight for texture projection.
  47845. */
  47846. set projectionTextureLightFar(value: number);
  47847. protected _projectionTextureUpDirection: Vector3;
  47848. /**
  47849. * Gets the Up vector of the Spotlight for texture projection.
  47850. */
  47851. get projectionTextureUpDirection(): Vector3;
  47852. /**
  47853. * Sets the Up vector of the Spotlight for texture projection.
  47854. */
  47855. set projectionTextureUpDirection(value: Vector3);
  47856. private _projectionTexture;
  47857. /**
  47858. * Gets the projection texture of the light.
  47859. */
  47860. get projectionTexture(): Nullable<BaseTexture>;
  47861. /**
  47862. * Sets the projection texture of the light.
  47863. */
  47864. set projectionTexture(value: Nullable<BaseTexture>);
  47865. private _projectionTextureViewLightDirty;
  47866. private _projectionTextureProjectionLightDirty;
  47867. private _projectionTextureDirty;
  47868. private _projectionTextureViewTargetVector;
  47869. private _projectionTextureViewLightMatrix;
  47870. private _projectionTextureProjectionLightMatrix;
  47871. private _projectionTextureScalingMatrix;
  47872. /**
  47873. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47874. * It can cast shadows.
  47875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47876. * @param name The light friendly name
  47877. * @param position The position of the spot light in the scene
  47878. * @param direction The direction of the light in the scene
  47879. * @param angle The cone angle of the light in Radians
  47880. * @param exponent The light decay speed with the distance from the emission spot
  47881. * @param scene The scene the lights belongs to
  47882. */
  47883. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47884. /**
  47885. * Returns the string "SpotLight".
  47886. * @returns the class name
  47887. */
  47888. getClassName(): string;
  47889. /**
  47890. * Returns the integer 2.
  47891. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47892. */
  47893. getTypeID(): number;
  47894. /**
  47895. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47896. */
  47897. protected _setDirection(value: Vector3): void;
  47898. /**
  47899. * Overrides the position setter to recompute the projection texture view light Matrix.
  47900. */
  47901. protected _setPosition(value: Vector3): void;
  47902. /**
  47903. * 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.
  47904. * Returns the SpotLight.
  47905. */
  47906. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47907. protected _computeProjectionTextureViewLightMatrix(): void;
  47908. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47909. /**
  47910. * Main function for light texture projection matrix computing.
  47911. */
  47912. protected _computeProjectionTextureMatrix(): void;
  47913. protected _buildUniformLayout(): void;
  47914. private _computeAngleValues;
  47915. /**
  47916. * Sets the passed Effect "effect" with the Light textures.
  47917. * @param effect The effect to update
  47918. * @param lightIndex The index of the light in the effect to update
  47919. * @returns The light
  47920. */
  47921. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47922. /**
  47923. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47924. * @param effect The effect to update
  47925. * @param lightIndex The index of the light in the effect to update
  47926. * @returns The spot light
  47927. */
  47928. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47929. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47930. /**
  47931. * Disposes the light and the associated resources.
  47932. */
  47933. dispose(): void;
  47934. /**
  47935. * Prepares the list of defines specific to the light type.
  47936. * @param defines the list of defines
  47937. * @param lightIndex defines the index of the light for the effect
  47938. */
  47939. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47940. }
  47941. }
  47942. declare module BABYLON {
  47943. /**
  47944. * Gizmo that enables viewing a light
  47945. */
  47946. export class LightGizmo extends Gizmo {
  47947. private _lightMesh;
  47948. private _material;
  47949. private _cachedPosition;
  47950. private _cachedForward;
  47951. private _attachedMeshParent;
  47952. /**
  47953. * Creates a LightGizmo
  47954. * @param gizmoLayer The utility layer the gizmo will be added to
  47955. */
  47956. constructor(gizmoLayer?: UtilityLayerRenderer);
  47957. private _light;
  47958. /**
  47959. * The light that the gizmo is attached to
  47960. */
  47961. set light(light: Nullable<Light>);
  47962. get light(): Nullable<Light>;
  47963. /**
  47964. * Gets the material used to render the light gizmo
  47965. */
  47966. get material(): StandardMaterial;
  47967. /**
  47968. * @hidden
  47969. * Updates the gizmo to match the attached mesh's position/rotation
  47970. */
  47971. protected _update(): void;
  47972. private static _Scale;
  47973. /**
  47974. * Creates the lines for a light mesh
  47975. */
  47976. private static _CreateLightLines;
  47977. /**
  47978. * Disposes of the light gizmo
  47979. */
  47980. dispose(): void;
  47981. private static _CreateHemisphericLightMesh;
  47982. private static _CreatePointLightMesh;
  47983. private static _CreateSpotLightMesh;
  47984. private static _CreateDirectionalLightMesh;
  47985. }
  47986. }
  47987. declare module BABYLON {
  47988. /** @hidden */
  47989. export var backgroundFragmentDeclaration: {
  47990. name: string;
  47991. shader: string;
  47992. };
  47993. }
  47994. declare module BABYLON {
  47995. /** @hidden */
  47996. export var backgroundUboDeclaration: {
  47997. name: string;
  47998. shader: string;
  47999. };
  48000. }
  48001. declare module BABYLON {
  48002. /** @hidden */
  48003. export var backgroundPixelShader: {
  48004. name: string;
  48005. shader: string;
  48006. };
  48007. }
  48008. declare module BABYLON {
  48009. /** @hidden */
  48010. export var backgroundVertexDeclaration: {
  48011. name: string;
  48012. shader: string;
  48013. };
  48014. }
  48015. declare module BABYLON {
  48016. /** @hidden */
  48017. export var backgroundVertexShader: {
  48018. name: string;
  48019. shader: string;
  48020. };
  48021. }
  48022. declare module BABYLON {
  48023. /**
  48024. * Background material used to create an efficient environement around your scene.
  48025. */
  48026. export class BackgroundMaterial extends PushMaterial {
  48027. /**
  48028. * Standard reflectance value at parallel view angle.
  48029. */
  48030. static StandardReflectance0: number;
  48031. /**
  48032. * Standard reflectance value at grazing angle.
  48033. */
  48034. static StandardReflectance90: number;
  48035. protected _primaryColor: Color3;
  48036. /**
  48037. * Key light Color (multiply against the environement texture)
  48038. */
  48039. primaryColor: Color3;
  48040. protected __perceptualColor: Nullable<Color3>;
  48041. /**
  48042. * Experimental Internal Use Only.
  48043. *
  48044. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48045. * This acts as a helper to set the primary color to a more "human friendly" value.
  48046. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48047. * output color as close as possible from the chosen value.
  48048. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48049. * part of lighting setup.)
  48050. */
  48051. get _perceptualColor(): Nullable<Color3>;
  48052. set _perceptualColor(value: Nullable<Color3>);
  48053. protected _primaryColorShadowLevel: float;
  48054. /**
  48055. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48056. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48057. */
  48058. get primaryColorShadowLevel(): float;
  48059. set primaryColorShadowLevel(value: float);
  48060. protected _primaryColorHighlightLevel: float;
  48061. /**
  48062. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48063. * The primary color is used at the level chosen to define what the white area would look.
  48064. */
  48065. get primaryColorHighlightLevel(): float;
  48066. set primaryColorHighlightLevel(value: float);
  48067. protected _reflectionTexture: Nullable<BaseTexture>;
  48068. /**
  48069. * Reflection Texture used in the material.
  48070. * Should be author in a specific way for the best result (refer to the documentation).
  48071. */
  48072. reflectionTexture: Nullable<BaseTexture>;
  48073. protected _reflectionBlur: float;
  48074. /**
  48075. * Reflection Texture level of blur.
  48076. *
  48077. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48078. * texture twice.
  48079. */
  48080. reflectionBlur: float;
  48081. protected _diffuseTexture: Nullable<BaseTexture>;
  48082. /**
  48083. * Diffuse Texture used in the material.
  48084. * Should be author in a specific way for the best result (refer to the documentation).
  48085. */
  48086. diffuseTexture: Nullable<BaseTexture>;
  48087. protected _shadowLights: Nullable<IShadowLight[]>;
  48088. /**
  48089. * Specify the list of lights casting shadow on the material.
  48090. * All scene shadow lights will be included if null.
  48091. */
  48092. shadowLights: Nullable<IShadowLight[]>;
  48093. protected _shadowLevel: float;
  48094. /**
  48095. * Helps adjusting the shadow to a softer level if required.
  48096. * 0 means black shadows and 1 means no shadows.
  48097. */
  48098. shadowLevel: float;
  48099. protected _sceneCenter: Vector3;
  48100. /**
  48101. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48102. * It is usually zero but might be interesting to modify according to your setup.
  48103. */
  48104. sceneCenter: Vector3;
  48105. protected _opacityFresnel: boolean;
  48106. /**
  48107. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48108. * This helps ensuring a nice transition when the camera goes under the ground.
  48109. */
  48110. opacityFresnel: boolean;
  48111. protected _reflectionFresnel: boolean;
  48112. /**
  48113. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48114. * This helps adding a mirror texture on the ground.
  48115. */
  48116. reflectionFresnel: boolean;
  48117. protected _reflectionFalloffDistance: number;
  48118. /**
  48119. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48120. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48121. */
  48122. reflectionFalloffDistance: number;
  48123. protected _reflectionAmount: number;
  48124. /**
  48125. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48126. */
  48127. reflectionAmount: number;
  48128. protected _reflectionReflectance0: number;
  48129. /**
  48130. * This specifies the weight of the reflection at grazing angle.
  48131. */
  48132. reflectionReflectance0: number;
  48133. protected _reflectionReflectance90: number;
  48134. /**
  48135. * This specifies the weight of the reflection at a perpendicular point of view.
  48136. */
  48137. reflectionReflectance90: number;
  48138. /**
  48139. * Sets the reflection reflectance fresnel values according to the default standard
  48140. * empirically know to work well :-)
  48141. */
  48142. set reflectionStandardFresnelWeight(value: number);
  48143. protected _useRGBColor: boolean;
  48144. /**
  48145. * Helps to directly use the maps channels instead of their level.
  48146. */
  48147. useRGBColor: boolean;
  48148. protected _enableNoise: boolean;
  48149. /**
  48150. * This helps reducing the banding effect that could occur on the background.
  48151. */
  48152. enableNoise: boolean;
  48153. /**
  48154. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48155. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48156. * Recommended to be keep at 1.0 except for special cases.
  48157. */
  48158. get fovMultiplier(): number;
  48159. set fovMultiplier(value: number);
  48160. private _fovMultiplier;
  48161. /**
  48162. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48163. */
  48164. useEquirectangularFOV: boolean;
  48165. private _maxSimultaneousLights;
  48166. /**
  48167. * Number of Simultaneous lights allowed on the material.
  48168. */
  48169. maxSimultaneousLights: int;
  48170. /**
  48171. * Default configuration related to image processing available in the Background Material.
  48172. */
  48173. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48174. /**
  48175. * Keep track of the image processing observer to allow dispose and replace.
  48176. */
  48177. private _imageProcessingObserver;
  48178. /**
  48179. * Attaches a new image processing configuration to the PBR Material.
  48180. * @param configuration (if null the scene configuration will be use)
  48181. */
  48182. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48183. /**
  48184. * Gets the image processing configuration used either in this material.
  48185. */
  48186. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48187. /**
  48188. * Sets the Default image processing configuration used either in the this material.
  48189. *
  48190. * If sets to null, the scene one is in use.
  48191. */
  48192. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48193. /**
  48194. * Gets wether the color curves effect is enabled.
  48195. */
  48196. get cameraColorCurvesEnabled(): boolean;
  48197. /**
  48198. * Sets wether the color curves effect is enabled.
  48199. */
  48200. set cameraColorCurvesEnabled(value: boolean);
  48201. /**
  48202. * Gets wether the color grading effect is enabled.
  48203. */
  48204. get cameraColorGradingEnabled(): boolean;
  48205. /**
  48206. * Gets wether the color grading effect is enabled.
  48207. */
  48208. set cameraColorGradingEnabled(value: boolean);
  48209. /**
  48210. * Gets wether tonemapping is enabled or not.
  48211. */
  48212. get cameraToneMappingEnabled(): boolean;
  48213. /**
  48214. * Sets wether tonemapping is enabled or not
  48215. */
  48216. set cameraToneMappingEnabled(value: boolean);
  48217. /**
  48218. * The camera exposure used on this material.
  48219. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48220. * This corresponds to a photographic exposure.
  48221. */
  48222. get cameraExposure(): float;
  48223. /**
  48224. * The camera exposure used on this material.
  48225. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48226. * This corresponds to a photographic exposure.
  48227. */
  48228. set cameraExposure(value: float);
  48229. /**
  48230. * Gets The camera contrast used on this material.
  48231. */
  48232. get cameraContrast(): float;
  48233. /**
  48234. * Sets The camera contrast used on this material.
  48235. */
  48236. set cameraContrast(value: float);
  48237. /**
  48238. * Gets the Color Grading 2D Lookup Texture.
  48239. */
  48240. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48241. /**
  48242. * Sets the Color Grading 2D Lookup Texture.
  48243. */
  48244. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48245. /**
  48246. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48247. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48248. * 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;
  48249. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48250. */
  48251. get cameraColorCurves(): Nullable<ColorCurves>;
  48252. /**
  48253. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48254. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48255. * 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;
  48256. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48257. */
  48258. set cameraColorCurves(value: Nullable<ColorCurves>);
  48259. /**
  48260. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48261. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48262. */
  48263. switchToBGR: boolean;
  48264. private _renderTargets;
  48265. private _reflectionControls;
  48266. private _white;
  48267. private _primaryShadowColor;
  48268. private _primaryHighlightColor;
  48269. /**
  48270. * Instantiates a Background Material in the given scene
  48271. * @param name The friendly name of the material
  48272. * @param scene The scene to add the material to
  48273. */
  48274. constructor(name: string, scene: Scene);
  48275. /**
  48276. * Gets a boolean indicating that current material needs to register RTT
  48277. */
  48278. get hasRenderTargetTextures(): boolean;
  48279. /**
  48280. * The entire material has been created in order to prevent overdraw.
  48281. * @returns false
  48282. */
  48283. needAlphaTesting(): boolean;
  48284. /**
  48285. * The entire material has been created in order to prevent overdraw.
  48286. * @returns true if blending is enable
  48287. */
  48288. needAlphaBlending(): boolean;
  48289. /**
  48290. * Checks wether the material is ready to be rendered for a given mesh.
  48291. * @param mesh The mesh to render
  48292. * @param subMesh The submesh to check against
  48293. * @param useInstances Specify wether or not the material is used with instances
  48294. * @returns true if all the dependencies are ready (Textures, Effects...)
  48295. */
  48296. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48297. /**
  48298. * Compute the primary color according to the chosen perceptual color.
  48299. */
  48300. private _computePrimaryColorFromPerceptualColor;
  48301. /**
  48302. * Compute the highlights and shadow colors according to their chosen levels.
  48303. */
  48304. private _computePrimaryColors;
  48305. /**
  48306. * Build the uniform buffer used in the material.
  48307. */
  48308. buildUniformLayout(): void;
  48309. /**
  48310. * Unbind the material.
  48311. */
  48312. unbind(): void;
  48313. /**
  48314. * Bind only the world matrix to the material.
  48315. * @param world The world matrix to bind.
  48316. */
  48317. bindOnlyWorldMatrix(world: Matrix): void;
  48318. /**
  48319. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48320. * @param world The world matrix to bind.
  48321. * @param subMesh The submesh to bind for.
  48322. */
  48323. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48324. /**
  48325. * Checks to see if a texture is used in the material.
  48326. * @param texture - Base texture to use.
  48327. * @returns - Boolean specifying if a texture is used in the material.
  48328. */
  48329. hasTexture(texture: BaseTexture): boolean;
  48330. /**
  48331. * Dispose the material.
  48332. * @param forceDisposeEffect Force disposal of the associated effect.
  48333. * @param forceDisposeTextures Force disposal of the associated textures.
  48334. */
  48335. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48336. /**
  48337. * Clones the material.
  48338. * @param name The cloned name.
  48339. * @returns The cloned material.
  48340. */
  48341. clone(name: string): BackgroundMaterial;
  48342. /**
  48343. * Serializes the current material to its JSON representation.
  48344. * @returns The JSON representation.
  48345. */
  48346. serialize(): any;
  48347. /**
  48348. * Gets the class name of the material
  48349. * @returns "BackgroundMaterial"
  48350. */
  48351. getClassName(): string;
  48352. /**
  48353. * Parse a JSON input to create back a background material.
  48354. * @param source The JSON data to parse
  48355. * @param scene The scene to create the parsed material in
  48356. * @param rootUrl The root url of the assets the material depends upon
  48357. * @returns the instantiated BackgroundMaterial.
  48358. */
  48359. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48360. }
  48361. }
  48362. declare module BABYLON {
  48363. /**
  48364. * Represents the different options available during the creation of
  48365. * a Environment helper.
  48366. *
  48367. * This can control the default ground, skybox and image processing setup of your scene.
  48368. */
  48369. export interface IEnvironmentHelperOptions {
  48370. /**
  48371. * Specifies wether or not to create a ground.
  48372. * True by default.
  48373. */
  48374. createGround: boolean;
  48375. /**
  48376. * Specifies the ground size.
  48377. * 15 by default.
  48378. */
  48379. groundSize: number;
  48380. /**
  48381. * The texture used on the ground for the main color.
  48382. * Comes from the BabylonJS CDN by default.
  48383. *
  48384. * Remarks: Can be either a texture or a url.
  48385. */
  48386. groundTexture: string | BaseTexture;
  48387. /**
  48388. * The color mixed in the ground texture by default.
  48389. * BabylonJS clearColor by default.
  48390. */
  48391. groundColor: Color3;
  48392. /**
  48393. * Specifies the ground opacity.
  48394. * 1 by default.
  48395. */
  48396. groundOpacity: number;
  48397. /**
  48398. * Enables the ground to receive shadows.
  48399. * True by default.
  48400. */
  48401. enableGroundShadow: boolean;
  48402. /**
  48403. * Helps preventing the shadow to be fully black on the ground.
  48404. * 0.5 by default.
  48405. */
  48406. groundShadowLevel: number;
  48407. /**
  48408. * Creates a mirror texture attach to the ground.
  48409. * false by default.
  48410. */
  48411. enableGroundMirror: boolean;
  48412. /**
  48413. * Specifies the ground mirror size ratio.
  48414. * 0.3 by default as the default kernel is 64.
  48415. */
  48416. groundMirrorSizeRatio: number;
  48417. /**
  48418. * Specifies the ground mirror blur kernel size.
  48419. * 64 by default.
  48420. */
  48421. groundMirrorBlurKernel: number;
  48422. /**
  48423. * Specifies the ground mirror visibility amount.
  48424. * 1 by default
  48425. */
  48426. groundMirrorAmount: number;
  48427. /**
  48428. * Specifies the ground mirror reflectance weight.
  48429. * This uses the standard weight of the background material to setup the fresnel effect
  48430. * of the mirror.
  48431. * 1 by default.
  48432. */
  48433. groundMirrorFresnelWeight: number;
  48434. /**
  48435. * Specifies the ground mirror Falloff distance.
  48436. * This can helps reducing the size of the reflection.
  48437. * 0 by Default.
  48438. */
  48439. groundMirrorFallOffDistance: number;
  48440. /**
  48441. * Specifies the ground mirror texture type.
  48442. * Unsigned Int by Default.
  48443. */
  48444. groundMirrorTextureType: number;
  48445. /**
  48446. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48447. * the shown objects.
  48448. */
  48449. groundYBias: number;
  48450. /**
  48451. * Specifies wether or not to create a skybox.
  48452. * True by default.
  48453. */
  48454. createSkybox: boolean;
  48455. /**
  48456. * Specifies the skybox size.
  48457. * 20 by default.
  48458. */
  48459. skyboxSize: number;
  48460. /**
  48461. * The texture used on the skybox for the main color.
  48462. * Comes from the BabylonJS CDN by default.
  48463. *
  48464. * Remarks: Can be either a texture or a url.
  48465. */
  48466. skyboxTexture: string | BaseTexture;
  48467. /**
  48468. * The color mixed in the skybox texture by default.
  48469. * BabylonJS clearColor by default.
  48470. */
  48471. skyboxColor: Color3;
  48472. /**
  48473. * The background rotation around the Y axis of the scene.
  48474. * This helps aligning the key lights of your scene with the background.
  48475. * 0 by default.
  48476. */
  48477. backgroundYRotation: number;
  48478. /**
  48479. * Compute automatically the size of the elements to best fit with the scene.
  48480. */
  48481. sizeAuto: boolean;
  48482. /**
  48483. * Default position of the rootMesh if autoSize is not true.
  48484. */
  48485. rootPosition: Vector3;
  48486. /**
  48487. * Sets up the image processing in the scene.
  48488. * true by default.
  48489. */
  48490. setupImageProcessing: boolean;
  48491. /**
  48492. * The texture used as your environment texture in the scene.
  48493. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48494. *
  48495. * Remarks: Can be either a texture or a url.
  48496. */
  48497. environmentTexture: string | BaseTexture;
  48498. /**
  48499. * The value of the exposure to apply to the scene.
  48500. * 0.6 by default if setupImageProcessing is true.
  48501. */
  48502. cameraExposure: number;
  48503. /**
  48504. * The value of the contrast to apply to the scene.
  48505. * 1.6 by default if setupImageProcessing is true.
  48506. */
  48507. cameraContrast: number;
  48508. /**
  48509. * Specifies wether or not tonemapping should be enabled in the scene.
  48510. * true by default if setupImageProcessing is true.
  48511. */
  48512. toneMappingEnabled: boolean;
  48513. }
  48514. /**
  48515. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48516. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48517. * It also helps with the default setup of your imageProcessing configuration.
  48518. */
  48519. export class EnvironmentHelper {
  48520. /**
  48521. * Default ground texture URL.
  48522. */
  48523. private static _groundTextureCDNUrl;
  48524. /**
  48525. * Default skybox texture URL.
  48526. */
  48527. private static _skyboxTextureCDNUrl;
  48528. /**
  48529. * Default environment texture URL.
  48530. */
  48531. private static _environmentTextureCDNUrl;
  48532. /**
  48533. * Creates the default options for the helper.
  48534. */
  48535. private static _getDefaultOptions;
  48536. private _rootMesh;
  48537. /**
  48538. * Gets the root mesh created by the helper.
  48539. */
  48540. get rootMesh(): Mesh;
  48541. private _skybox;
  48542. /**
  48543. * Gets the skybox created by the helper.
  48544. */
  48545. get skybox(): Nullable<Mesh>;
  48546. private _skyboxTexture;
  48547. /**
  48548. * Gets the skybox texture created by the helper.
  48549. */
  48550. get skyboxTexture(): Nullable<BaseTexture>;
  48551. private _skyboxMaterial;
  48552. /**
  48553. * Gets the skybox material created by the helper.
  48554. */
  48555. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48556. private _ground;
  48557. /**
  48558. * Gets the ground mesh created by the helper.
  48559. */
  48560. get ground(): Nullable<Mesh>;
  48561. private _groundTexture;
  48562. /**
  48563. * Gets the ground texture created by the helper.
  48564. */
  48565. get groundTexture(): Nullable<BaseTexture>;
  48566. private _groundMirror;
  48567. /**
  48568. * Gets the ground mirror created by the helper.
  48569. */
  48570. get groundMirror(): Nullable<MirrorTexture>;
  48571. /**
  48572. * Gets the ground mirror render list to helps pushing the meshes
  48573. * you wish in the ground reflection.
  48574. */
  48575. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48576. private _groundMaterial;
  48577. /**
  48578. * Gets the ground material created by the helper.
  48579. */
  48580. get groundMaterial(): Nullable<BackgroundMaterial>;
  48581. /**
  48582. * Stores the creation options.
  48583. */
  48584. private readonly _scene;
  48585. private _options;
  48586. /**
  48587. * This observable will be notified with any error during the creation of the environment,
  48588. * mainly texture creation errors.
  48589. */
  48590. onErrorObservable: Observable<{
  48591. message?: string;
  48592. exception?: any;
  48593. }>;
  48594. /**
  48595. * constructor
  48596. * @param options Defines the options we want to customize the helper
  48597. * @param scene The scene to add the material to
  48598. */
  48599. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48600. /**
  48601. * Updates the background according to the new options
  48602. * @param options
  48603. */
  48604. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48605. /**
  48606. * Sets the primary color of all the available elements.
  48607. * @param color the main color to affect to the ground and the background
  48608. */
  48609. setMainColor(color: Color3): void;
  48610. /**
  48611. * Setup the image processing according to the specified options.
  48612. */
  48613. private _setupImageProcessing;
  48614. /**
  48615. * Setup the environment texture according to the specified options.
  48616. */
  48617. private _setupEnvironmentTexture;
  48618. /**
  48619. * Setup the background according to the specified options.
  48620. */
  48621. private _setupBackground;
  48622. /**
  48623. * Get the scene sizes according to the setup.
  48624. */
  48625. private _getSceneSize;
  48626. /**
  48627. * Setup the ground according to the specified options.
  48628. */
  48629. private _setupGround;
  48630. /**
  48631. * Setup the ground material according to the specified options.
  48632. */
  48633. private _setupGroundMaterial;
  48634. /**
  48635. * Setup the ground diffuse texture according to the specified options.
  48636. */
  48637. private _setupGroundDiffuseTexture;
  48638. /**
  48639. * Setup the ground mirror texture according to the specified options.
  48640. */
  48641. private _setupGroundMirrorTexture;
  48642. /**
  48643. * Setup the ground to receive the mirror texture.
  48644. */
  48645. private _setupMirrorInGroundMaterial;
  48646. /**
  48647. * Setup the skybox according to the specified options.
  48648. */
  48649. private _setupSkybox;
  48650. /**
  48651. * Setup the skybox material according to the specified options.
  48652. */
  48653. private _setupSkyboxMaterial;
  48654. /**
  48655. * Setup the skybox reflection texture according to the specified options.
  48656. */
  48657. private _setupSkyboxReflectionTexture;
  48658. private _errorHandler;
  48659. /**
  48660. * Dispose all the elements created by the Helper.
  48661. */
  48662. dispose(): void;
  48663. }
  48664. }
  48665. declare module BABYLON {
  48666. /**
  48667. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48668. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48669. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48670. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48671. */
  48672. export class PhotoDome extends TransformNode {
  48673. /**
  48674. * Define the image as a Monoscopic panoramic 360 image.
  48675. */
  48676. static readonly MODE_MONOSCOPIC: number;
  48677. /**
  48678. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48679. */
  48680. static readonly MODE_TOPBOTTOM: number;
  48681. /**
  48682. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48683. */
  48684. static readonly MODE_SIDEBYSIDE: number;
  48685. private _useDirectMapping;
  48686. /**
  48687. * The texture being displayed on the sphere
  48688. */
  48689. protected _photoTexture: Texture;
  48690. /**
  48691. * Gets or sets the texture being displayed on the sphere
  48692. */
  48693. get photoTexture(): Texture;
  48694. set photoTexture(value: Texture);
  48695. /**
  48696. * Observable raised when an error occured while loading the 360 image
  48697. */
  48698. onLoadErrorObservable: Observable<string>;
  48699. /**
  48700. * The skybox material
  48701. */
  48702. protected _material: BackgroundMaterial;
  48703. /**
  48704. * The surface used for the skybox
  48705. */
  48706. protected _mesh: Mesh;
  48707. /**
  48708. * Gets the mesh used for the skybox.
  48709. */
  48710. get mesh(): Mesh;
  48711. /**
  48712. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48713. * Also see the options.resolution property.
  48714. */
  48715. get fovMultiplier(): number;
  48716. set fovMultiplier(value: number);
  48717. private _imageMode;
  48718. /**
  48719. * Gets or set the current video mode for the video. It can be:
  48720. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48721. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48722. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48723. */
  48724. get imageMode(): number;
  48725. set imageMode(value: number);
  48726. /**
  48727. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48728. * @param name Element's name, child elements will append suffixes for their own names.
  48729. * @param urlsOfPhoto defines the url of the photo to display
  48730. * @param options defines an object containing optional or exposed sub element properties
  48731. * @param onError defines a callback called when an error occured while loading the texture
  48732. */
  48733. constructor(name: string, urlOfPhoto: string, options: {
  48734. resolution?: number;
  48735. size?: number;
  48736. useDirectMapping?: boolean;
  48737. faceForward?: boolean;
  48738. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48739. private _onBeforeCameraRenderObserver;
  48740. private _changeImageMode;
  48741. /**
  48742. * Releases resources associated with this node.
  48743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48745. */
  48746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48747. }
  48748. }
  48749. declare module BABYLON {
  48750. /**
  48751. * Class used to host RGBD texture specific utilities
  48752. */
  48753. export class RGBDTextureTools {
  48754. /**
  48755. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48756. * @param texture the texture to expand.
  48757. */
  48758. static ExpandRGBDTexture(texture: Texture): void;
  48759. }
  48760. }
  48761. declare module BABYLON {
  48762. /**
  48763. * Class used to host texture specific utilities
  48764. */
  48765. export class BRDFTextureTools {
  48766. /**
  48767. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48768. * @param scene defines the hosting scene
  48769. * @returns the environment BRDF texture
  48770. */
  48771. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48772. private static _environmentBRDFBase64Texture;
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * @hidden
  48778. */
  48779. export interface IMaterialClearCoatDefines {
  48780. CLEARCOAT: boolean;
  48781. CLEARCOAT_DEFAULTIOR: boolean;
  48782. CLEARCOAT_TEXTURE: boolean;
  48783. CLEARCOAT_TEXTUREDIRECTUV: number;
  48784. CLEARCOAT_BUMP: boolean;
  48785. CLEARCOAT_BUMPDIRECTUV: number;
  48786. CLEARCOAT_TINT: boolean;
  48787. CLEARCOAT_TINT_TEXTURE: boolean;
  48788. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48789. /** @hidden */
  48790. _areTexturesDirty: boolean;
  48791. }
  48792. /**
  48793. * Define the code related to the clear coat parameters of the pbr material.
  48794. */
  48795. export class PBRClearCoatConfiguration {
  48796. /**
  48797. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48798. * The default fits with a polyurethane material.
  48799. */
  48800. private static readonly _DefaultIndexOfRefraction;
  48801. private _isEnabled;
  48802. /**
  48803. * Defines if the clear coat is enabled in the material.
  48804. */
  48805. isEnabled: boolean;
  48806. /**
  48807. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48808. */
  48809. intensity: number;
  48810. /**
  48811. * Defines the clear coat layer roughness.
  48812. */
  48813. roughness: number;
  48814. private _indexOfRefraction;
  48815. /**
  48816. * Defines the index of refraction of the clear coat.
  48817. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48818. * The default fits with a polyurethane material.
  48819. * Changing the default value is more performance intensive.
  48820. */
  48821. indexOfRefraction: number;
  48822. private _texture;
  48823. /**
  48824. * Stores the clear coat values in a texture.
  48825. */
  48826. texture: Nullable<BaseTexture>;
  48827. private _bumpTexture;
  48828. /**
  48829. * Define the clear coat specific bump texture.
  48830. */
  48831. bumpTexture: Nullable<BaseTexture>;
  48832. private _isTintEnabled;
  48833. /**
  48834. * Defines if the clear coat tint is enabled in the material.
  48835. */
  48836. isTintEnabled: boolean;
  48837. /**
  48838. * Defines the clear coat tint of the material.
  48839. * This is only use if tint is enabled
  48840. */
  48841. tintColor: Color3;
  48842. /**
  48843. * Defines the distance at which the tint color should be found in the
  48844. * clear coat media.
  48845. * This is only use if tint is enabled
  48846. */
  48847. tintColorAtDistance: number;
  48848. /**
  48849. * Defines the clear coat layer thickness.
  48850. * This is only use if tint is enabled
  48851. */
  48852. tintThickness: number;
  48853. private _tintTexture;
  48854. /**
  48855. * Stores the clear tint values in a texture.
  48856. * rgb is tint
  48857. * a is a thickness factor
  48858. */
  48859. tintTexture: Nullable<BaseTexture>;
  48860. /** @hidden */
  48861. private _internalMarkAllSubMeshesAsTexturesDirty;
  48862. /** @hidden */
  48863. _markAllSubMeshesAsTexturesDirty(): void;
  48864. /**
  48865. * Instantiate a new istance of clear coat configuration.
  48866. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48867. */
  48868. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48869. /**
  48870. * Gets wehter the submesh is ready to be used or not.
  48871. * @param defines the list of "defines" to update.
  48872. * @param scene defines the scene the material belongs to.
  48873. * @param engine defines the engine the material belongs to.
  48874. * @param disableBumpMap defines wether the material disables bump or not.
  48875. * @returns - boolean indicating that the submesh is ready or not.
  48876. */
  48877. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48878. /**
  48879. * Checks to see if a texture is used in the material.
  48880. * @param defines the list of "defines" to update.
  48881. * @param scene defines the scene to the material belongs to.
  48882. */
  48883. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48884. /**
  48885. * Binds the material data.
  48886. * @param uniformBuffer defines the Uniform buffer to fill in.
  48887. * @param scene defines the scene the material belongs to.
  48888. * @param engine defines the engine the material belongs to.
  48889. * @param disableBumpMap defines wether the material disables bump or not.
  48890. * @param isFrozen defines wether the material is frozen or not.
  48891. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48892. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48893. */
  48894. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48895. /**
  48896. * Checks to see if a texture is used in the material.
  48897. * @param texture - Base texture to use.
  48898. * @returns - Boolean specifying if a texture is used in the material.
  48899. */
  48900. hasTexture(texture: BaseTexture): boolean;
  48901. /**
  48902. * Returns an array of the actively used textures.
  48903. * @param activeTextures Array of BaseTextures
  48904. */
  48905. getActiveTextures(activeTextures: BaseTexture[]): void;
  48906. /**
  48907. * Returns the animatable textures.
  48908. * @param animatables Array of animatable textures.
  48909. */
  48910. getAnimatables(animatables: IAnimatable[]): void;
  48911. /**
  48912. * Disposes the resources of the material.
  48913. * @param forceDisposeTextures - Forces the disposal of all textures.
  48914. */
  48915. dispose(forceDisposeTextures?: boolean): void;
  48916. /**
  48917. * Get the current class name of the texture useful for serialization or dynamic coding.
  48918. * @returns "PBRClearCoatConfiguration"
  48919. */
  48920. getClassName(): string;
  48921. /**
  48922. * Add fallbacks to the effect fallbacks list.
  48923. * @param defines defines the Base texture to use.
  48924. * @param fallbacks defines the current fallback list.
  48925. * @param currentRank defines the current fallback rank.
  48926. * @returns the new fallback rank.
  48927. */
  48928. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48929. /**
  48930. * Add the required uniforms to the current list.
  48931. * @param uniforms defines the current uniform list.
  48932. */
  48933. static AddUniforms(uniforms: string[]): void;
  48934. /**
  48935. * Add the required samplers to the current list.
  48936. * @param samplers defines the current sampler list.
  48937. */
  48938. static AddSamplers(samplers: string[]): void;
  48939. /**
  48940. * Add the required uniforms to the current buffer.
  48941. * @param uniformBuffer defines the current uniform buffer.
  48942. */
  48943. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48944. /**
  48945. * Makes a duplicate of the current configuration into another one.
  48946. * @param clearCoatConfiguration define the config where to copy the info
  48947. */
  48948. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48949. /**
  48950. * Serializes this clear coat configuration.
  48951. * @returns - An object with the serialized config.
  48952. */
  48953. serialize(): any;
  48954. /**
  48955. * Parses a anisotropy Configuration from a serialized object.
  48956. * @param source - Serialized object.
  48957. * @param scene Defines the scene we are parsing for
  48958. * @param rootUrl Defines the rootUrl to load from
  48959. */
  48960. parse(source: any, scene: Scene, rootUrl: string): void;
  48961. }
  48962. }
  48963. declare module BABYLON {
  48964. /**
  48965. * @hidden
  48966. */
  48967. export interface IMaterialAnisotropicDefines {
  48968. ANISOTROPIC: boolean;
  48969. ANISOTROPIC_TEXTURE: boolean;
  48970. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48971. MAINUV1: boolean;
  48972. _areTexturesDirty: boolean;
  48973. _needUVs: boolean;
  48974. }
  48975. /**
  48976. * Define the code related to the anisotropic parameters of the pbr material.
  48977. */
  48978. export class PBRAnisotropicConfiguration {
  48979. private _isEnabled;
  48980. /**
  48981. * Defines if the anisotropy is enabled in the material.
  48982. */
  48983. isEnabled: boolean;
  48984. /**
  48985. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48986. */
  48987. intensity: number;
  48988. /**
  48989. * Defines if the effect is along the tangents, bitangents or in between.
  48990. * By default, the effect is "strectching" the highlights along the tangents.
  48991. */
  48992. direction: Vector2;
  48993. private _texture;
  48994. /**
  48995. * Stores the anisotropy values in a texture.
  48996. * rg is direction (like normal from -1 to 1)
  48997. * b is a intensity
  48998. */
  48999. texture: Nullable<BaseTexture>;
  49000. /** @hidden */
  49001. private _internalMarkAllSubMeshesAsTexturesDirty;
  49002. /** @hidden */
  49003. _markAllSubMeshesAsTexturesDirty(): void;
  49004. /**
  49005. * Instantiate a new istance of anisotropy configuration.
  49006. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49007. */
  49008. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49009. /**
  49010. * Specifies that the submesh is ready to be used.
  49011. * @param defines the list of "defines" to update.
  49012. * @param scene defines the scene the material belongs to.
  49013. * @returns - boolean indicating that the submesh is ready or not.
  49014. */
  49015. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49016. /**
  49017. * Checks to see if a texture is used in the material.
  49018. * @param defines the list of "defines" to update.
  49019. * @param mesh the mesh we are preparing the defines for.
  49020. * @param scene defines the scene the material belongs to.
  49021. */
  49022. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49023. /**
  49024. * Binds the material data.
  49025. * @param uniformBuffer defines the Uniform buffer to fill in.
  49026. * @param scene defines the scene the material belongs to.
  49027. * @param isFrozen defines wether the material is frozen or not.
  49028. */
  49029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49030. /**
  49031. * Checks to see if a texture is used in the material.
  49032. * @param texture - Base texture to use.
  49033. * @returns - Boolean specifying if a texture is used in the material.
  49034. */
  49035. hasTexture(texture: BaseTexture): boolean;
  49036. /**
  49037. * Returns an array of the actively used textures.
  49038. * @param activeTextures Array of BaseTextures
  49039. */
  49040. getActiveTextures(activeTextures: BaseTexture[]): void;
  49041. /**
  49042. * Returns the animatable textures.
  49043. * @param animatables Array of animatable textures.
  49044. */
  49045. getAnimatables(animatables: IAnimatable[]): void;
  49046. /**
  49047. * Disposes the resources of the material.
  49048. * @param forceDisposeTextures - Forces the disposal of all textures.
  49049. */
  49050. dispose(forceDisposeTextures?: boolean): void;
  49051. /**
  49052. * Get the current class name of the texture useful for serialization or dynamic coding.
  49053. * @returns "PBRAnisotropicConfiguration"
  49054. */
  49055. getClassName(): string;
  49056. /**
  49057. * Add fallbacks to the effect fallbacks list.
  49058. * @param defines defines the Base texture to use.
  49059. * @param fallbacks defines the current fallback list.
  49060. * @param currentRank defines the current fallback rank.
  49061. * @returns the new fallback rank.
  49062. */
  49063. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49064. /**
  49065. * Add the required uniforms to the current list.
  49066. * @param uniforms defines the current uniform list.
  49067. */
  49068. static AddUniforms(uniforms: string[]): void;
  49069. /**
  49070. * Add the required uniforms to the current buffer.
  49071. * @param uniformBuffer defines the current uniform buffer.
  49072. */
  49073. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49074. /**
  49075. * Add the required samplers to the current list.
  49076. * @param samplers defines the current sampler list.
  49077. */
  49078. static AddSamplers(samplers: string[]): void;
  49079. /**
  49080. * Makes a duplicate of the current configuration into another one.
  49081. * @param anisotropicConfiguration define the config where to copy the info
  49082. */
  49083. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49084. /**
  49085. * Serializes this anisotropy configuration.
  49086. * @returns - An object with the serialized config.
  49087. */
  49088. serialize(): any;
  49089. /**
  49090. * Parses a anisotropy Configuration from a serialized object.
  49091. * @param source - Serialized object.
  49092. * @param scene Defines the scene we are parsing for
  49093. * @param rootUrl Defines the rootUrl to load from
  49094. */
  49095. parse(source: any, scene: Scene, rootUrl: string): void;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /**
  49100. * @hidden
  49101. */
  49102. export interface IMaterialBRDFDefines {
  49103. BRDF_V_HEIGHT_CORRELATED: boolean;
  49104. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49105. SPHERICAL_HARMONICS: boolean;
  49106. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49107. /** @hidden */
  49108. _areMiscDirty: boolean;
  49109. }
  49110. /**
  49111. * Define the code related to the BRDF parameters of the pbr material.
  49112. */
  49113. export class PBRBRDFConfiguration {
  49114. /**
  49115. * Default value used for the energy conservation.
  49116. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49117. */
  49118. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49119. /**
  49120. * Default value used for the Smith Visibility Height Correlated mode.
  49121. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49122. */
  49123. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49124. /**
  49125. * Default value used for the IBL diffuse part.
  49126. * This can help switching back to the polynomials mode globally which is a tiny bit
  49127. * less GPU intensive at the drawback of a lower quality.
  49128. */
  49129. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49130. /**
  49131. * Default value used for activating energy conservation for the specular workflow.
  49132. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49133. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49134. */
  49135. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49136. private _useEnergyConservation;
  49137. /**
  49138. * Defines if the material uses energy conservation.
  49139. */
  49140. useEnergyConservation: boolean;
  49141. private _useSmithVisibilityHeightCorrelated;
  49142. /**
  49143. * LEGACY Mode set to false
  49144. * Defines if the material uses height smith correlated visibility term.
  49145. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49146. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49147. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49148. * Not relying on height correlated will also disable energy conservation.
  49149. */
  49150. useSmithVisibilityHeightCorrelated: boolean;
  49151. private _useSphericalHarmonics;
  49152. /**
  49153. * LEGACY Mode set to false
  49154. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49155. * diffuse part of the IBL.
  49156. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49157. * to the ground truth.
  49158. */
  49159. useSphericalHarmonics: boolean;
  49160. private _useSpecularGlossinessInputEnergyConservation;
  49161. /**
  49162. * Defines if the material uses energy conservation, when the specular workflow is active.
  49163. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49164. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49165. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49166. */
  49167. useSpecularGlossinessInputEnergyConservation: boolean;
  49168. /** @hidden */
  49169. private _internalMarkAllSubMeshesAsMiscDirty;
  49170. /** @hidden */
  49171. _markAllSubMeshesAsMiscDirty(): void;
  49172. /**
  49173. * Instantiate a new istance of clear coat configuration.
  49174. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49175. */
  49176. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49177. /**
  49178. * Checks to see if a texture is used in the material.
  49179. * @param defines the list of "defines" to update.
  49180. */
  49181. prepareDefines(defines: IMaterialBRDFDefines): void;
  49182. /**
  49183. * Get the current class name of the texture useful for serialization or dynamic coding.
  49184. * @returns "PBRClearCoatConfiguration"
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Makes a duplicate of the current configuration into another one.
  49189. * @param brdfConfiguration define the config where to copy the info
  49190. */
  49191. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49192. /**
  49193. * Serializes this BRDF configuration.
  49194. * @returns - An object with the serialized config.
  49195. */
  49196. serialize(): any;
  49197. /**
  49198. * Parses a anisotropy Configuration from a serialized object.
  49199. * @param source - Serialized object.
  49200. * @param scene Defines the scene we are parsing for
  49201. * @param rootUrl Defines the rootUrl to load from
  49202. */
  49203. parse(source: any, scene: Scene, rootUrl: string): void;
  49204. }
  49205. }
  49206. declare module BABYLON {
  49207. /**
  49208. * @hidden
  49209. */
  49210. export interface IMaterialSheenDefines {
  49211. SHEEN: boolean;
  49212. SHEEN_TEXTURE: boolean;
  49213. SHEEN_TEXTUREDIRECTUV: number;
  49214. SHEEN_LINKWITHALBEDO: boolean;
  49215. /** @hidden */
  49216. _areTexturesDirty: boolean;
  49217. }
  49218. /**
  49219. * Define the code related to the Sheen parameters of the pbr material.
  49220. */
  49221. export class PBRSheenConfiguration {
  49222. private _isEnabled;
  49223. /**
  49224. * Defines if the material uses sheen.
  49225. */
  49226. isEnabled: boolean;
  49227. private _linkSheenWithAlbedo;
  49228. /**
  49229. * Defines if the sheen is linked to the sheen color.
  49230. */
  49231. linkSheenWithAlbedo: boolean;
  49232. /**
  49233. * Defines the sheen intensity.
  49234. */
  49235. intensity: number;
  49236. /**
  49237. * Defines the sheen color.
  49238. */
  49239. color: Color3;
  49240. private _texture;
  49241. /**
  49242. * Stores the sheen tint values in a texture.
  49243. * rgb is tint
  49244. * a is a intensity
  49245. */
  49246. texture: Nullable<BaseTexture>;
  49247. /** @hidden */
  49248. private _internalMarkAllSubMeshesAsTexturesDirty;
  49249. /** @hidden */
  49250. _markAllSubMeshesAsTexturesDirty(): void;
  49251. /**
  49252. * Instantiate a new istance of clear coat configuration.
  49253. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49254. */
  49255. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49256. /**
  49257. * Specifies that the submesh is ready to be used.
  49258. * @param defines the list of "defines" to update.
  49259. * @param scene defines the scene the material belongs to.
  49260. * @returns - boolean indicating that the submesh is ready or not.
  49261. */
  49262. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49263. /**
  49264. * Checks to see if a texture is used in the material.
  49265. * @param defines the list of "defines" to update.
  49266. * @param scene defines the scene the material belongs to.
  49267. */
  49268. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49269. /**
  49270. * Binds the material data.
  49271. * @param uniformBuffer defines the Uniform buffer to fill in.
  49272. * @param scene defines the scene the material belongs to.
  49273. * @param isFrozen defines wether the material is frozen or not.
  49274. */
  49275. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49276. /**
  49277. * Checks to see if a texture is used in the material.
  49278. * @param texture - Base texture to use.
  49279. * @returns - Boolean specifying if a texture is used in the material.
  49280. */
  49281. hasTexture(texture: BaseTexture): boolean;
  49282. /**
  49283. * Returns an array of the actively used textures.
  49284. * @param activeTextures Array of BaseTextures
  49285. */
  49286. getActiveTextures(activeTextures: BaseTexture[]): void;
  49287. /**
  49288. * Returns the animatable textures.
  49289. * @param animatables Array of animatable textures.
  49290. */
  49291. getAnimatables(animatables: IAnimatable[]): void;
  49292. /**
  49293. * Disposes the resources of the material.
  49294. * @param forceDisposeTextures - Forces the disposal of all textures.
  49295. */
  49296. dispose(forceDisposeTextures?: boolean): void;
  49297. /**
  49298. * Get the current class name of the texture useful for serialization or dynamic coding.
  49299. * @returns "PBRSheenConfiguration"
  49300. */
  49301. getClassName(): string;
  49302. /**
  49303. * Add fallbacks to the effect fallbacks list.
  49304. * @param defines defines the Base texture to use.
  49305. * @param fallbacks defines the current fallback list.
  49306. * @param currentRank defines the current fallback rank.
  49307. * @returns the new fallback rank.
  49308. */
  49309. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49310. /**
  49311. * Add the required uniforms to the current list.
  49312. * @param uniforms defines the current uniform list.
  49313. */
  49314. static AddUniforms(uniforms: string[]): void;
  49315. /**
  49316. * Add the required uniforms to the current buffer.
  49317. * @param uniformBuffer defines the current uniform buffer.
  49318. */
  49319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49320. /**
  49321. * Add the required samplers to the current list.
  49322. * @param samplers defines the current sampler list.
  49323. */
  49324. static AddSamplers(samplers: string[]): void;
  49325. /**
  49326. * Makes a duplicate of the current configuration into another one.
  49327. * @param sheenConfiguration define the config where to copy the info
  49328. */
  49329. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49330. /**
  49331. * Serializes this BRDF configuration.
  49332. * @returns - An object with the serialized config.
  49333. */
  49334. serialize(): any;
  49335. /**
  49336. * Parses a anisotropy Configuration from a serialized object.
  49337. * @param source - Serialized object.
  49338. * @param scene Defines the scene we are parsing for
  49339. * @param rootUrl Defines the rootUrl to load from
  49340. */
  49341. parse(source: any, scene: Scene, rootUrl: string): void;
  49342. }
  49343. }
  49344. declare module BABYLON {
  49345. /**
  49346. * @hidden
  49347. */
  49348. export interface IMaterialSubSurfaceDefines {
  49349. SUBSURFACE: boolean;
  49350. SS_REFRACTION: boolean;
  49351. SS_TRANSLUCENCY: boolean;
  49352. SS_SCATERRING: boolean;
  49353. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49354. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49355. SS_REFRACTIONMAP_3D: boolean;
  49356. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49357. SS_LODINREFRACTIONALPHA: boolean;
  49358. SS_GAMMAREFRACTION: boolean;
  49359. SS_RGBDREFRACTION: boolean;
  49360. SS_LINEARSPECULARREFRACTION: boolean;
  49361. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49362. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49363. /** @hidden */
  49364. _areTexturesDirty: boolean;
  49365. }
  49366. /**
  49367. * Define the code related to the sub surface parameters of the pbr material.
  49368. */
  49369. export class PBRSubSurfaceConfiguration {
  49370. private _isRefractionEnabled;
  49371. /**
  49372. * Defines if the refraction is enabled in the material.
  49373. */
  49374. isRefractionEnabled: boolean;
  49375. private _isTranslucencyEnabled;
  49376. /**
  49377. * Defines if the translucency is enabled in the material.
  49378. */
  49379. isTranslucencyEnabled: boolean;
  49380. private _isScatteringEnabled;
  49381. /**
  49382. * Defines the refraction intensity of the material.
  49383. * The refraction when enabled replaces the Diffuse part of the material.
  49384. * The intensity helps transitionning between diffuse and refraction.
  49385. */
  49386. refractionIntensity: number;
  49387. /**
  49388. * Defines the translucency intensity of the material.
  49389. * When translucency has been enabled, this defines how much of the "translucency"
  49390. * is addded to the diffuse part of the material.
  49391. */
  49392. translucencyIntensity: number;
  49393. /**
  49394. * Defines the scattering intensity of the material.
  49395. * When scattering has been enabled, this defines how much of the "scattered light"
  49396. * is addded to the diffuse part of the material.
  49397. */
  49398. scatteringIntensity: number;
  49399. private _thicknessTexture;
  49400. /**
  49401. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49402. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49403. * 0 would mean minimumThickness
  49404. * 1 would mean maximumThickness
  49405. * The other channels might be use as a mask to vary the different effects intensity.
  49406. */
  49407. thicknessTexture: Nullable<BaseTexture>;
  49408. private _refractionTexture;
  49409. /**
  49410. * Defines the texture to use for refraction.
  49411. */
  49412. refractionTexture: Nullable<BaseTexture>;
  49413. private _indexOfRefraction;
  49414. /**
  49415. * Defines the index of refraction used in the material.
  49416. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49417. */
  49418. indexOfRefraction: number;
  49419. private _invertRefractionY;
  49420. /**
  49421. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49422. */
  49423. invertRefractionY: boolean;
  49424. private _linkRefractionWithTransparency;
  49425. /**
  49426. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49427. * Materials half opaque for instance using refraction could benefit from this control.
  49428. */
  49429. linkRefractionWithTransparency: boolean;
  49430. /**
  49431. * Defines the minimum thickness stored in the thickness map.
  49432. * If no thickness map is defined, this value will be used to simulate thickness.
  49433. */
  49434. minimumThickness: number;
  49435. /**
  49436. * Defines the maximum thickness stored in the thickness map.
  49437. */
  49438. maximumThickness: number;
  49439. /**
  49440. * Defines the volume tint of the material.
  49441. * This is used for both translucency and scattering.
  49442. */
  49443. tintColor: Color3;
  49444. /**
  49445. * Defines the distance at which the tint color should be found in the media.
  49446. * This is used for refraction only.
  49447. */
  49448. tintColorAtDistance: number;
  49449. /**
  49450. * Defines how far each channel transmit through the media.
  49451. * It is defined as a color to simplify it selection.
  49452. */
  49453. diffusionDistance: Color3;
  49454. private _useMaskFromThicknessTexture;
  49455. /**
  49456. * Stores the intensity of the different subsurface effects in the thickness texture.
  49457. * * the green channel is the translucency intensity.
  49458. * * the blue channel is the scattering intensity.
  49459. * * the alpha channel is the refraction intensity.
  49460. */
  49461. useMaskFromThicknessTexture: boolean;
  49462. /** @hidden */
  49463. private _internalMarkAllSubMeshesAsTexturesDirty;
  49464. /** @hidden */
  49465. _markAllSubMeshesAsTexturesDirty(): void;
  49466. /**
  49467. * Instantiate a new istance of sub surface configuration.
  49468. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49469. */
  49470. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49471. /**
  49472. * Gets wehter the submesh is ready to be used or not.
  49473. * @param defines the list of "defines" to update.
  49474. * @param scene defines the scene the material belongs to.
  49475. * @returns - boolean indicating that the submesh is ready or not.
  49476. */
  49477. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49478. /**
  49479. * Checks to see if a texture is used in the material.
  49480. * @param defines the list of "defines" to update.
  49481. * @param scene defines the scene to the material belongs to.
  49482. */
  49483. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49484. /**
  49485. * Binds the material data.
  49486. * @param uniformBuffer defines the Uniform buffer to fill in.
  49487. * @param scene defines the scene the material belongs to.
  49488. * @param engine defines the engine the material belongs to.
  49489. * @param isFrozen defines wether the material is frozen or not.
  49490. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49491. */
  49492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49493. /**
  49494. * Unbinds the material from the mesh.
  49495. * @param activeEffect defines the effect that should be unbound from.
  49496. * @returns true if unbound, otherwise false
  49497. */
  49498. unbind(activeEffect: Effect): boolean;
  49499. /**
  49500. * Returns the texture used for refraction or null if none is used.
  49501. * @param scene defines the scene the material belongs to.
  49502. * @returns - Refraction texture if present. If no refraction texture and refraction
  49503. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49504. */
  49505. private _getRefractionTexture;
  49506. /**
  49507. * Returns true if alpha blending should be disabled.
  49508. */
  49509. get disableAlphaBlending(): boolean;
  49510. /**
  49511. * Fills the list of render target textures.
  49512. * @param renderTargets the list of render targets to update
  49513. */
  49514. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49515. /**
  49516. * Checks to see if a texture is used in the material.
  49517. * @param texture - Base texture to use.
  49518. * @returns - Boolean specifying if a texture is used in the material.
  49519. */
  49520. hasTexture(texture: BaseTexture): boolean;
  49521. /**
  49522. * Gets a boolean indicating that current material needs to register RTT
  49523. * @returns true if this uses a render target otherwise false.
  49524. */
  49525. hasRenderTargetTextures(): boolean;
  49526. /**
  49527. * Returns an array of the actively used textures.
  49528. * @param activeTextures Array of BaseTextures
  49529. */
  49530. getActiveTextures(activeTextures: BaseTexture[]): void;
  49531. /**
  49532. * Returns the animatable textures.
  49533. * @param animatables Array of animatable textures.
  49534. */
  49535. getAnimatables(animatables: IAnimatable[]): void;
  49536. /**
  49537. * Disposes the resources of the material.
  49538. * @param forceDisposeTextures - Forces the disposal of all textures.
  49539. */
  49540. dispose(forceDisposeTextures?: boolean): void;
  49541. /**
  49542. * Get the current class name of the texture useful for serialization or dynamic coding.
  49543. * @returns "PBRSubSurfaceConfiguration"
  49544. */
  49545. getClassName(): string;
  49546. /**
  49547. * Add fallbacks to the effect fallbacks list.
  49548. * @param defines defines the Base texture to use.
  49549. * @param fallbacks defines the current fallback list.
  49550. * @param currentRank defines the current fallback rank.
  49551. * @returns the new fallback rank.
  49552. */
  49553. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49554. /**
  49555. * Add the required uniforms to the current list.
  49556. * @param uniforms defines the current uniform list.
  49557. */
  49558. static AddUniforms(uniforms: string[]): void;
  49559. /**
  49560. * Add the required samplers to the current list.
  49561. * @param samplers defines the current sampler list.
  49562. */
  49563. static AddSamplers(samplers: string[]): void;
  49564. /**
  49565. * Add the required uniforms to the current buffer.
  49566. * @param uniformBuffer defines the current uniform buffer.
  49567. */
  49568. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49569. /**
  49570. * Makes a duplicate of the current configuration into another one.
  49571. * @param configuration define the config where to copy the info
  49572. */
  49573. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49574. /**
  49575. * Serializes this Sub Surface configuration.
  49576. * @returns - An object with the serialized config.
  49577. */
  49578. serialize(): any;
  49579. /**
  49580. * Parses a anisotropy Configuration from a serialized object.
  49581. * @param source - Serialized object.
  49582. * @param scene Defines the scene we are parsing for
  49583. * @param rootUrl Defines the rootUrl to load from
  49584. */
  49585. parse(source: any, scene: Scene, rootUrl: string): void;
  49586. }
  49587. }
  49588. declare module BABYLON {
  49589. /** @hidden */
  49590. export var pbrFragmentDeclaration: {
  49591. name: string;
  49592. shader: string;
  49593. };
  49594. }
  49595. declare module BABYLON {
  49596. /** @hidden */
  49597. export var pbrUboDeclaration: {
  49598. name: string;
  49599. shader: string;
  49600. };
  49601. }
  49602. declare module BABYLON {
  49603. /** @hidden */
  49604. export var pbrFragmentExtraDeclaration: {
  49605. name: string;
  49606. shader: string;
  49607. };
  49608. }
  49609. declare module BABYLON {
  49610. /** @hidden */
  49611. export var pbrFragmentSamplersDeclaration: {
  49612. name: string;
  49613. shader: string;
  49614. };
  49615. }
  49616. declare module BABYLON {
  49617. /** @hidden */
  49618. export var pbrHelperFunctions: {
  49619. name: string;
  49620. shader: string;
  49621. };
  49622. }
  49623. declare module BABYLON {
  49624. /** @hidden */
  49625. export var harmonicsFunctions: {
  49626. name: string;
  49627. shader: string;
  49628. };
  49629. }
  49630. declare module BABYLON {
  49631. /** @hidden */
  49632. export var pbrDirectLightingSetupFunctions: {
  49633. name: string;
  49634. shader: string;
  49635. };
  49636. }
  49637. declare module BABYLON {
  49638. /** @hidden */
  49639. export var pbrDirectLightingFalloffFunctions: {
  49640. name: string;
  49641. shader: string;
  49642. };
  49643. }
  49644. declare module BABYLON {
  49645. /** @hidden */
  49646. export var pbrBRDFFunctions: {
  49647. name: string;
  49648. shader: string;
  49649. };
  49650. }
  49651. declare module BABYLON {
  49652. /** @hidden */
  49653. export var pbrDirectLightingFunctions: {
  49654. name: string;
  49655. shader: string;
  49656. };
  49657. }
  49658. declare module BABYLON {
  49659. /** @hidden */
  49660. export var pbrIBLFunctions: {
  49661. name: string;
  49662. shader: string;
  49663. };
  49664. }
  49665. declare module BABYLON {
  49666. /** @hidden */
  49667. export var pbrDebug: {
  49668. name: string;
  49669. shader: string;
  49670. };
  49671. }
  49672. declare module BABYLON {
  49673. /** @hidden */
  49674. export var pbrPixelShader: {
  49675. name: string;
  49676. shader: string;
  49677. };
  49678. }
  49679. declare module BABYLON {
  49680. /** @hidden */
  49681. export var pbrVertexDeclaration: {
  49682. name: string;
  49683. shader: string;
  49684. };
  49685. }
  49686. declare module BABYLON {
  49687. /** @hidden */
  49688. export var pbrVertexShader: {
  49689. name: string;
  49690. shader: string;
  49691. };
  49692. }
  49693. declare module BABYLON {
  49694. /**
  49695. * Manages the defines for the PBR Material.
  49696. * @hidden
  49697. */
  49698. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49699. PBR: boolean;
  49700. MAINUV1: boolean;
  49701. MAINUV2: boolean;
  49702. UV1: boolean;
  49703. UV2: boolean;
  49704. ALBEDO: boolean;
  49705. ALBEDODIRECTUV: number;
  49706. VERTEXCOLOR: boolean;
  49707. AMBIENT: boolean;
  49708. AMBIENTDIRECTUV: number;
  49709. AMBIENTINGRAYSCALE: boolean;
  49710. OPACITY: boolean;
  49711. VERTEXALPHA: boolean;
  49712. OPACITYDIRECTUV: number;
  49713. OPACITYRGB: boolean;
  49714. ALPHATEST: boolean;
  49715. DEPTHPREPASS: boolean;
  49716. ALPHABLEND: boolean;
  49717. ALPHAFROMALBEDO: boolean;
  49718. ALPHATESTVALUE: string;
  49719. SPECULAROVERALPHA: boolean;
  49720. RADIANCEOVERALPHA: boolean;
  49721. ALPHAFRESNEL: boolean;
  49722. LINEARALPHAFRESNEL: boolean;
  49723. PREMULTIPLYALPHA: boolean;
  49724. EMISSIVE: boolean;
  49725. EMISSIVEDIRECTUV: number;
  49726. REFLECTIVITY: boolean;
  49727. REFLECTIVITYDIRECTUV: number;
  49728. SPECULARTERM: boolean;
  49729. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49730. MICROSURFACEAUTOMATIC: boolean;
  49731. LODBASEDMICROSFURACE: boolean;
  49732. MICROSURFACEMAP: boolean;
  49733. MICROSURFACEMAPDIRECTUV: number;
  49734. METALLICWORKFLOW: boolean;
  49735. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49736. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49737. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49738. AOSTOREINMETALMAPRED: boolean;
  49739. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49740. ENVIRONMENTBRDF: boolean;
  49741. ENVIRONMENTBRDF_RGBD: boolean;
  49742. NORMAL: boolean;
  49743. TANGENT: boolean;
  49744. BUMP: boolean;
  49745. BUMPDIRECTUV: number;
  49746. OBJECTSPACE_NORMALMAP: boolean;
  49747. PARALLAX: boolean;
  49748. PARALLAXOCCLUSION: boolean;
  49749. NORMALXYSCALE: boolean;
  49750. LIGHTMAP: boolean;
  49751. LIGHTMAPDIRECTUV: number;
  49752. USELIGHTMAPASSHADOWMAP: boolean;
  49753. GAMMALIGHTMAP: boolean;
  49754. RGBDLIGHTMAP: boolean;
  49755. REFLECTION: boolean;
  49756. REFLECTIONMAP_3D: boolean;
  49757. REFLECTIONMAP_SPHERICAL: boolean;
  49758. REFLECTIONMAP_PLANAR: boolean;
  49759. REFLECTIONMAP_CUBIC: boolean;
  49760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49761. REFLECTIONMAP_PROJECTION: boolean;
  49762. REFLECTIONMAP_SKYBOX: boolean;
  49763. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49764. REFLECTIONMAP_EXPLICIT: boolean;
  49765. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49766. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49767. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49768. INVERTCUBICMAP: boolean;
  49769. USESPHERICALFROMREFLECTIONMAP: boolean;
  49770. USEIRRADIANCEMAP: boolean;
  49771. SPHERICAL_HARMONICS: boolean;
  49772. USESPHERICALINVERTEX: boolean;
  49773. REFLECTIONMAP_OPPOSITEZ: boolean;
  49774. LODINREFLECTIONALPHA: boolean;
  49775. GAMMAREFLECTION: boolean;
  49776. RGBDREFLECTION: boolean;
  49777. LINEARSPECULARREFLECTION: boolean;
  49778. RADIANCEOCCLUSION: boolean;
  49779. HORIZONOCCLUSION: boolean;
  49780. INSTANCES: boolean;
  49781. NUM_BONE_INFLUENCERS: number;
  49782. BonesPerMesh: number;
  49783. BONETEXTURE: boolean;
  49784. NONUNIFORMSCALING: boolean;
  49785. MORPHTARGETS: boolean;
  49786. MORPHTARGETS_NORMAL: boolean;
  49787. MORPHTARGETS_TANGENT: boolean;
  49788. MORPHTARGETS_UV: boolean;
  49789. NUM_MORPH_INFLUENCERS: number;
  49790. IMAGEPROCESSING: boolean;
  49791. VIGNETTE: boolean;
  49792. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49793. VIGNETTEBLENDMODEOPAQUE: boolean;
  49794. TONEMAPPING: boolean;
  49795. TONEMAPPING_ACES: boolean;
  49796. CONTRAST: boolean;
  49797. COLORCURVES: boolean;
  49798. COLORGRADING: boolean;
  49799. COLORGRADING3D: boolean;
  49800. SAMPLER3DGREENDEPTH: boolean;
  49801. SAMPLER3DBGRMAP: boolean;
  49802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49803. EXPOSURE: boolean;
  49804. MULTIVIEW: boolean;
  49805. USEPHYSICALLIGHTFALLOFF: boolean;
  49806. USEGLTFLIGHTFALLOFF: boolean;
  49807. TWOSIDEDLIGHTING: boolean;
  49808. SHADOWFLOAT: boolean;
  49809. CLIPPLANE: boolean;
  49810. CLIPPLANE2: boolean;
  49811. CLIPPLANE3: boolean;
  49812. CLIPPLANE4: boolean;
  49813. CLIPPLANE5: boolean;
  49814. CLIPPLANE6: boolean;
  49815. POINTSIZE: boolean;
  49816. FOG: boolean;
  49817. LOGARITHMICDEPTH: boolean;
  49818. FORCENORMALFORWARD: boolean;
  49819. SPECULARAA: boolean;
  49820. CLEARCOAT: boolean;
  49821. CLEARCOAT_DEFAULTIOR: boolean;
  49822. CLEARCOAT_TEXTURE: boolean;
  49823. CLEARCOAT_TEXTUREDIRECTUV: number;
  49824. CLEARCOAT_BUMP: boolean;
  49825. CLEARCOAT_BUMPDIRECTUV: number;
  49826. CLEARCOAT_TINT: boolean;
  49827. CLEARCOAT_TINT_TEXTURE: boolean;
  49828. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49829. ANISOTROPIC: boolean;
  49830. ANISOTROPIC_TEXTURE: boolean;
  49831. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49832. BRDF_V_HEIGHT_CORRELATED: boolean;
  49833. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49834. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49835. SHEEN: boolean;
  49836. SHEEN_TEXTURE: boolean;
  49837. SHEEN_TEXTUREDIRECTUV: number;
  49838. SHEEN_LINKWITHALBEDO: boolean;
  49839. SUBSURFACE: boolean;
  49840. SS_REFRACTION: boolean;
  49841. SS_TRANSLUCENCY: boolean;
  49842. SS_SCATERRING: boolean;
  49843. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49844. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49845. SS_REFRACTIONMAP_3D: boolean;
  49846. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49847. SS_LODINREFRACTIONALPHA: boolean;
  49848. SS_GAMMAREFRACTION: boolean;
  49849. SS_RGBDREFRACTION: boolean;
  49850. SS_LINEARSPECULARREFRACTION: boolean;
  49851. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49852. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49853. UNLIT: boolean;
  49854. DEBUGMODE: number;
  49855. /**
  49856. * Initializes the PBR Material defines.
  49857. */
  49858. constructor();
  49859. /**
  49860. * Resets the PBR Material defines.
  49861. */
  49862. reset(): void;
  49863. }
  49864. /**
  49865. * The Physically based material base class of BJS.
  49866. *
  49867. * This offers the main features of a standard PBR material.
  49868. * For more information, please refer to the documentation :
  49869. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49870. */
  49871. export abstract class PBRBaseMaterial extends PushMaterial {
  49872. /**
  49873. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49874. */
  49875. static readonly PBRMATERIAL_OPAQUE: number;
  49876. /**
  49877. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49878. */
  49879. static readonly PBRMATERIAL_ALPHATEST: number;
  49880. /**
  49881. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49882. */
  49883. static readonly PBRMATERIAL_ALPHABLEND: number;
  49884. /**
  49885. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49886. * They are also discarded below the alpha cutoff threshold to improve performances.
  49887. */
  49888. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49889. /**
  49890. * Defines the default value of how much AO map is occluding the analytical lights
  49891. * (point spot...).
  49892. */
  49893. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49894. /**
  49895. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49896. */
  49897. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49898. /**
  49899. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49900. * to enhance interoperability with other engines.
  49901. */
  49902. static readonly LIGHTFALLOFF_GLTF: number;
  49903. /**
  49904. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49905. * to enhance interoperability with other materials.
  49906. */
  49907. static readonly LIGHTFALLOFF_STANDARD: number;
  49908. /**
  49909. * Intensity of the direct lights e.g. the four lights available in your scene.
  49910. * This impacts both the direct diffuse and specular highlights.
  49911. */
  49912. protected _directIntensity: number;
  49913. /**
  49914. * Intensity of the emissive part of the material.
  49915. * This helps controlling the emissive effect without modifying the emissive color.
  49916. */
  49917. protected _emissiveIntensity: number;
  49918. /**
  49919. * Intensity of the environment e.g. how much the environment will light the object
  49920. * either through harmonics for rough material or through the refelction for shiny ones.
  49921. */
  49922. protected _environmentIntensity: number;
  49923. /**
  49924. * This is a special control allowing the reduction of the specular highlights coming from the
  49925. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49926. */
  49927. protected _specularIntensity: number;
  49928. /**
  49929. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49930. */
  49931. private _lightingInfos;
  49932. /**
  49933. * Debug Control allowing disabling the bump map on this material.
  49934. */
  49935. protected _disableBumpMap: boolean;
  49936. /**
  49937. * AKA Diffuse Texture in standard nomenclature.
  49938. */
  49939. protected _albedoTexture: Nullable<BaseTexture>;
  49940. /**
  49941. * AKA Occlusion Texture in other nomenclature.
  49942. */
  49943. protected _ambientTexture: Nullable<BaseTexture>;
  49944. /**
  49945. * AKA Occlusion Texture Intensity in other nomenclature.
  49946. */
  49947. protected _ambientTextureStrength: number;
  49948. /**
  49949. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49950. * 1 means it completely occludes it
  49951. * 0 mean it has no impact
  49952. */
  49953. protected _ambientTextureImpactOnAnalyticalLights: number;
  49954. /**
  49955. * Stores the alpha values in a texture.
  49956. */
  49957. protected _opacityTexture: Nullable<BaseTexture>;
  49958. /**
  49959. * Stores the reflection values in a texture.
  49960. */
  49961. protected _reflectionTexture: Nullable<BaseTexture>;
  49962. /**
  49963. * Stores the emissive values in a texture.
  49964. */
  49965. protected _emissiveTexture: Nullable<BaseTexture>;
  49966. /**
  49967. * AKA Specular texture in other nomenclature.
  49968. */
  49969. protected _reflectivityTexture: Nullable<BaseTexture>;
  49970. /**
  49971. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49972. */
  49973. protected _metallicTexture: Nullable<BaseTexture>;
  49974. /**
  49975. * Specifies the metallic scalar of the metallic/roughness workflow.
  49976. * Can also be used to scale the metalness values of the metallic texture.
  49977. */
  49978. protected _metallic: Nullable<number>;
  49979. /**
  49980. * Specifies the roughness scalar of the metallic/roughness workflow.
  49981. * Can also be used to scale the roughness values of the metallic texture.
  49982. */
  49983. protected _roughness: Nullable<number>;
  49984. /**
  49985. * Specifies the an F0 factor to help configuring the material F0.
  49986. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49987. * to 0.5 the previously hard coded value stays the same.
  49988. * Can also be used to scale the F0 values of the metallic texture.
  49989. */
  49990. protected _metallicF0Factor: number;
  49991. /**
  49992. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49993. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49994. * your expectation as it multiplies with the texture data.
  49995. */
  49996. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49997. /**
  49998. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49999. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50000. */
  50001. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50002. /**
  50003. * Stores surface normal data used to displace a mesh in a texture.
  50004. */
  50005. protected _bumpTexture: Nullable<BaseTexture>;
  50006. /**
  50007. * Stores the pre-calculated light information of a mesh in a texture.
  50008. */
  50009. protected _lightmapTexture: Nullable<BaseTexture>;
  50010. /**
  50011. * The color of a material in ambient lighting.
  50012. */
  50013. protected _ambientColor: Color3;
  50014. /**
  50015. * AKA Diffuse Color in other nomenclature.
  50016. */
  50017. protected _albedoColor: Color3;
  50018. /**
  50019. * AKA Specular Color in other nomenclature.
  50020. */
  50021. protected _reflectivityColor: Color3;
  50022. /**
  50023. * The color applied when light is reflected from a material.
  50024. */
  50025. protected _reflectionColor: Color3;
  50026. /**
  50027. * The color applied when light is emitted from a material.
  50028. */
  50029. protected _emissiveColor: Color3;
  50030. /**
  50031. * AKA Glossiness in other nomenclature.
  50032. */
  50033. protected _microSurface: number;
  50034. /**
  50035. * Specifies that the material will use the light map as a show map.
  50036. */
  50037. protected _useLightmapAsShadowmap: boolean;
  50038. /**
  50039. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50040. * makes the reflect vector face the model (under horizon).
  50041. */
  50042. protected _useHorizonOcclusion: boolean;
  50043. /**
  50044. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50045. * too much the area relying on ambient texture to define their ambient occlusion.
  50046. */
  50047. protected _useRadianceOcclusion: boolean;
  50048. /**
  50049. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50050. */
  50051. protected _useAlphaFromAlbedoTexture: boolean;
  50052. /**
  50053. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50054. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50055. */
  50056. protected _useSpecularOverAlpha: boolean;
  50057. /**
  50058. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50059. */
  50060. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50061. /**
  50062. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50063. */
  50064. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50065. /**
  50066. * Specifies if the metallic texture contains the roughness information in its green channel.
  50067. */
  50068. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50069. /**
  50070. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50071. */
  50072. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50073. /**
  50074. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50075. */
  50076. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50077. /**
  50078. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50079. */
  50080. protected _useAmbientInGrayScale: boolean;
  50081. /**
  50082. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50083. * The material will try to infer what glossiness each pixel should be.
  50084. */
  50085. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50086. /**
  50087. * Defines the falloff type used in this material.
  50088. * It by default is Physical.
  50089. */
  50090. protected _lightFalloff: number;
  50091. /**
  50092. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50093. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50094. */
  50095. protected _useRadianceOverAlpha: boolean;
  50096. /**
  50097. * Allows using an object space normal map (instead of tangent space).
  50098. */
  50099. protected _useObjectSpaceNormalMap: boolean;
  50100. /**
  50101. * Allows using the bump map in parallax mode.
  50102. */
  50103. protected _useParallax: boolean;
  50104. /**
  50105. * Allows using the bump map in parallax occlusion mode.
  50106. */
  50107. protected _useParallaxOcclusion: boolean;
  50108. /**
  50109. * Controls the scale bias of the parallax mode.
  50110. */
  50111. protected _parallaxScaleBias: number;
  50112. /**
  50113. * If sets to true, disables all the lights affecting the material.
  50114. */
  50115. protected _disableLighting: boolean;
  50116. /**
  50117. * Number of Simultaneous lights allowed on the material.
  50118. */
  50119. protected _maxSimultaneousLights: number;
  50120. /**
  50121. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50122. */
  50123. protected _invertNormalMapX: boolean;
  50124. /**
  50125. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50126. */
  50127. protected _invertNormalMapY: boolean;
  50128. /**
  50129. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50130. */
  50131. protected _twoSidedLighting: boolean;
  50132. /**
  50133. * Defines the alpha limits in alpha test mode.
  50134. */
  50135. protected _alphaCutOff: number;
  50136. /**
  50137. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50138. */
  50139. protected _forceAlphaTest: boolean;
  50140. /**
  50141. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50142. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50143. */
  50144. protected _useAlphaFresnel: boolean;
  50145. /**
  50146. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50147. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50148. */
  50149. protected _useLinearAlphaFresnel: boolean;
  50150. /**
  50151. * The transparency mode of the material.
  50152. */
  50153. protected _transparencyMode: Nullable<number>;
  50154. /**
  50155. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50156. * from cos thetav and roughness:
  50157. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50158. */
  50159. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50160. /**
  50161. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50162. */
  50163. protected _forceIrradianceInFragment: boolean;
  50164. /**
  50165. * Force normal to face away from face.
  50166. */
  50167. protected _forceNormalForward: boolean;
  50168. /**
  50169. * Enables specular anti aliasing in the PBR shader.
  50170. * It will both interacts on the Geometry for analytical and IBL lighting.
  50171. * It also prefilter the roughness map based on the bump values.
  50172. */
  50173. protected _enableSpecularAntiAliasing: boolean;
  50174. /**
  50175. * Default configuration related to image processing available in the PBR Material.
  50176. */
  50177. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50178. /**
  50179. * Keep track of the image processing observer to allow dispose and replace.
  50180. */
  50181. private _imageProcessingObserver;
  50182. /**
  50183. * Attaches a new image processing configuration to the PBR Material.
  50184. * @param configuration
  50185. */
  50186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50187. /**
  50188. * Stores the available render targets.
  50189. */
  50190. private _renderTargets;
  50191. /**
  50192. * Sets the global ambient color for the material used in lighting calculations.
  50193. */
  50194. private _globalAmbientColor;
  50195. /**
  50196. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50197. */
  50198. private _useLogarithmicDepth;
  50199. /**
  50200. * If set to true, no lighting calculations will be applied.
  50201. */
  50202. private _unlit;
  50203. private _debugMode;
  50204. /**
  50205. * @hidden
  50206. * This is reserved for the inspector.
  50207. * Defines the material debug mode.
  50208. * It helps seeing only some components of the material while troubleshooting.
  50209. */
  50210. debugMode: number;
  50211. /**
  50212. * @hidden
  50213. * This is reserved for the inspector.
  50214. * Specify from where on screen the debug mode should start.
  50215. * The value goes from -1 (full screen) to 1 (not visible)
  50216. * It helps with side by side comparison against the final render
  50217. * This defaults to -1
  50218. */
  50219. private debugLimit;
  50220. /**
  50221. * @hidden
  50222. * This is reserved for the inspector.
  50223. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50224. * You can use the factor to better multiply the final value.
  50225. */
  50226. private debugFactor;
  50227. /**
  50228. * Defines the clear coat layer parameters for the material.
  50229. */
  50230. readonly clearCoat: PBRClearCoatConfiguration;
  50231. /**
  50232. * Defines the anisotropic parameters for the material.
  50233. */
  50234. readonly anisotropy: PBRAnisotropicConfiguration;
  50235. /**
  50236. * Defines the BRDF parameters for the material.
  50237. */
  50238. readonly brdf: PBRBRDFConfiguration;
  50239. /**
  50240. * Defines the Sheen parameters for the material.
  50241. */
  50242. readonly sheen: PBRSheenConfiguration;
  50243. /**
  50244. * Defines the SubSurface parameters for the material.
  50245. */
  50246. readonly subSurface: PBRSubSurfaceConfiguration;
  50247. /**
  50248. * Custom callback helping to override the default shader used in the material.
  50249. */
  50250. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50251. protected _rebuildInParallel: boolean;
  50252. /**
  50253. * Instantiates a new PBRMaterial instance.
  50254. *
  50255. * @param name The material name
  50256. * @param scene The scene the material will be use in.
  50257. */
  50258. constructor(name: string, scene: Scene);
  50259. /**
  50260. * Gets a boolean indicating that current material needs to register RTT
  50261. */
  50262. get hasRenderTargetTextures(): boolean;
  50263. /**
  50264. * Gets the name of the material class.
  50265. */
  50266. getClassName(): string;
  50267. /**
  50268. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50269. */
  50270. get useLogarithmicDepth(): boolean;
  50271. /**
  50272. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50273. */
  50274. set useLogarithmicDepth(value: boolean);
  50275. /**
  50276. * Gets the current transparency mode.
  50277. */
  50278. get transparencyMode(): Nullable<number>;
  50279. /**
  50280. * Sets the transparency mode of the material.
  50281. *
  50282. * | Value | Type | Description |
  50283. * | ----- | ----------------------------------- | ----------- |
  50284. * | 0 | OPAQUE | |
  50285. * | 1 | ALPHATEST | |
  50286. * | 2 | ALPHABLEND | |
  50287. * | 3 | ALPHATESTANDBLEND | |
  50288. *
  50289. */
  50290. set transparencyMode(value: Nullable<number>);
  50291. /**
  50292. * Returns true if alpha blending should be disabled.
  50293. */
  50294. private get _disableAlphaBlending();
  50295. /**
  50296. * Specifies whether or not this material should be rendered in alpha blend mode.
  50297. */
  50298. needAlphaBlending(): boolean;
  50299. /**
  50300. * Specifies if the mesh will require alpha blending.
  50301. * @param mesh - BJS mesh.
  50302. */
  50303. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50304. /**
  50305. * Specifies whether or not this material should be rendered in alpha test mode.
  50306. */
  50307. needAlphaTesting(): boolean;
  50308. /**
  50309. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50310. */
  50311. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50312. /**
  50313. * Gets the texture used for the alpha test.
  50314. */
  50315. getAlphaTestTexture(): Nullable<BaseTexture>;
  50316. /**
  50317. * Specifies that the submesh is ready to be used.
  50318. * @param mesh - BJS mesh.
  50319. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50320. * @param useInstances - Specifies that instances should be used.
  50321. * @returns - boolean indicating that the submesh is ready or not.
  50322. */
  50323. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50324. /**
  50325. * Specifies if the material uses metallic roughness workflow.
  50326. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50327. */
  50328. isMetallicWorkflow(): boolean;
  50329. private _prepareEffect;
  50330. private _prepareDefines;
  50331. /**
  50332. * Force shader compilation
  50333. */
  50334. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50335. /**
  50336. * Initializes the uniform buffer layout for the shader.
  50337. */
  50338. buildUniformLayout(): void;
  50339. /**
  50340. * Unbinds the material from the mesh
  50341. */
  50342. unbind(): void;
  50343. /**
  50344. * Binds the submesh data.
  50345. * @param world - The world matrix.
  50346. * @param mesh - The BJS mesh.
  50347. * @param subMesh - A submesh of the BJS mesh.
  50348. */
  50349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50350. /**
  50351. * Returns the animatable textures.
  50352. * @returns - Array of animatable textures.
  50353. */
  50354. getAnimatables(): IAnimatable[];
  50355. /**
  50356. * Returns the texture used for reflections.
  50357. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50358. */
  50359. private _getReflectionTexture;
  50360. /**
  50361. * Returns an array of the actively used textures.
  50362. * @returns - Array of BaseTextures
  50363. */
  50364. getActiveTextures(): BaseTexture[];
  50365. /**
  50366. * Checks to see if a texture is used in the material.
  50367. * @param texture - Base texture to use.
  50368. * @returns - Boolean specifying if a texture is used in the material.
  50369. */
  50370. hasTexture(texture: BaseTexture): boolean;
  50371. /**
  50372. * Disposes the resources of the material.
  50373. * @param forceDisposeEffect - Forces the disposal of effects.
  50374. * @param forceDisposeTextures - Forces the disposal of all textures.
  50375. */
  50376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50377. }
  50378. }
  50379. declare module BABYLON {
  50380. /**
  50381. * The Physically based material of BJS.
  50382. *
  50383. * This offers the main features of a standard PBR material.
  50384. * For more information, please refer to the documentation :
  50385. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50386. */
  50387. export class PBRMaterial extends PBRBaseMaterial {
  50388. /**
  50389. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50390. */
  50391. static readonly PBRMATERIAL_OPAQUE: number;
  50392. /**
  50393. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50394. */
  50395. static readonly PBRMATERIAL_ALPHATEST: number;
  50396. /**
  50397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50398. */
  50399. static readonly PBRMATERIAL_ALPHABLEND: number;
  50400. /**
  50401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50402. * They are also discarded below the alpha cutoff threshold to improve performances.
  50403. */
  50404. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50405. /**
  50406. * Defines the default value of how much AO map is occluding the analytical lights
  50407. * (point spot...).
  50408. */
  50409. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50410. /**
  50411. * Intensity of the direct lights e.g. the four lights available in your scene.
  50412. * This impacts both the direct diffuse and specular highlights.
  50413. */
  50414. directIntensity: number;
  50415. /**
  50416. * Intensity of the emissive part of the material.
  50417. * This helps controlling the emissive effect without modifying the emissive color.
  50418. */
  50419. emissiveIntensity: number;
  50420. /**
  50421. * Intensity of the environment e.g. how much the environment will light the object
  50422. * either through harmonics for rough material or through the refelction for shiny ones.
  50423. */
  50424. environmentIntensity: number;
  50425. /**
  50426. * This is a special control allowing the reduction of the specular highlights coming from the
  50427. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50428. */
  50429. specularIntensity: number;
  50430. /**
  50431. * Debug Control allowing disabling the bump map on this material.
  50432. */
  50433. disableBumpMap: boolean;
  50434. /**
  50435. * AKA Diffuse Texture in standard nomenclature.
  50436. */
  50437. albedoTexture: BaseTexture;
  50438. /**
  50439. * AKA Occlusion Texture in other nomenclature.
  50440. */
  50441. ambientTexture: BaseTexture;
  50442. /**
  50443. * AKA Occlusion Texture Intensity in other nomenclature.
  50444. */
  50445. ambientTextureStrength: number;
  50446. /**
  50447. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50448. * 1 means it completely occludes it
  50449. * 0 mean it has no impact
  50450. */
  50451. ambientTextureImpactOnAnalyticalLights: number;
  50452. /**
  50453. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50454. */
  50455. opacityTexture: BaseTexture;
  50456. /**
  50457. * Stores the reflection values in a texture.
  50458. */
  50459. reflectionTexture: Nullable<BaseTexture>;
  50460. /**
  50461. * Stores the emissive values in a texture.
  50462. */
  50463. emissiveTexture: BaseTexture;
  50464. /**
  50465. * AKA Specular texture in other nomenclature.
  50466. */
  50467. reflectivityTexture: BaseTexture;
  50468. /**
  50469. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50470. */
  50471. metallicTexture: BaseTexture;
  50472. /**
  50473. * Specifies the metallic scalar of the metallic/roughness workflow.
  50474. * Can also be used to scale the metalness values of the metallic texture.
  50475. */
  50476. metallic: Nullable<number>;
  50477. /**
  50478. * Specifies the roughness scalar of the metallic/roughness workflow.
  50479. * Can also be used to scale the roughness values of the metallic texture.
  50480. */
  50481. roughness: Nullable<number>;
  50482. /**
  50483. * Specifies the an F0 factor to help configuring the material F0.
  50484. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50485. * to 0.5 the previously hard coded value stays the same.
  50486. * Can also be used to scale the F0 values of the metallic texture.
  50487. */
  50488. metallicF0Factor: number;
  50489. /**
  50490. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50491. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50492. * your expectation as it multiplies with the texture data.
  50493. */
  50494. useMetallicF0FactorFromMetallicTexture: boolean;
  50495. /**
  50496. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50497. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50498. */
  50499. microSurfaceTexture: BaseTexture;
  50500. /**
  50501. * Stores surface normal data used to displace a mesh in a texture.
  50502. */
  50503. bumpTexture: BaseTexture;
  50504. /**
  50505. * Stores the pre-calculated light information of a mesh in a texture.
  50506. */
  50507. lightmapTexture: BaseTexture;
  50508. /**
  50509. * Stores the refracted light information in a texture.
  50510. */
  50511. get refractionTexture(): Nullable<BaseTexture>;
  50512. set refractionTexture(value: Nullable<BaseTexture>);
  50513. /**
  50514. * The color of a material in ambient lighting.
  50515. */
  50516. ambientColor: Color3;
  50517. /**
  50518. * AKA Diffuse Color in other nomenclature.
  50519. */
  50520. albedoColor: Color3;
  50521. /**
  50522. * AKA Specular Color in other nomenclature.
  50523. */
  50524. reflectivityColor: Color3;
  50525. /**
  50526. * The color reflected from the material.
  50527. */
  50528. reflectionColor: Color3;
  50529. /**
  50530. * The color emitted from the material.
  50531. */
  50532. emissiveColor: Color3;
  50533. /**
  50534. * AKA Glossiness in other nomenclature.
  50535. */
  50536. microSurface: number;
  50537. /**
  50538. * source material index of refraction (IOR)' / 'destination material IOR.
  50539. */
  50540. get indexOfRefraction(): number;
  50541. set indexOfRefraction(value: number);
  50542. /**
  50543. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50544. */
  50545. get invertRefractionY(): boolean;
  50546. set invertRefractionY(value: boolean);
  50547. /**
  50548. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50549. * Materials half opaque for instance using refraction could benefit from this control.
  50550. */
  50551. get linkRefractionWithTransparency(): boolean;
  50552. set linkRefractionWithTransparency(value: boolean);
  50553. /**
  50554. * If true, the light map contains occlusion information instead of lighting info.
  50555. */
  50556. useLightmapAsShadowmap: boolean;
  50557. /**
  50558. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50559. */
  50560. useAlphaFromAlbedoTexture: boolean;
  50561. /**
  50562. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50563. */
  50564. forceAlphaTest: boolean;
  50565. /**
  50566. * Defines the alpha limits in alpha test mode.
  50567. */
  50568. alphaCutOff: number;
  50569. /**
  50570. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50571. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50572. */
  50573. useSpecularOverAlpha: boolean;
  50574. /**
  50575. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50576. */
  50577. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50578. /**
  50579. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50580. */
  50581. useRoughnessFromMetallicTextureAlpha: boolean;
  50582. /**
  50583. * Specifies if the metallic texture contains the roughness information in its green channel.
  50584. */
  50585. useRoughnessFromMetallicTextureGreen: boolean;
  50586. /**
  50587. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50588. */
  50589. useMetallnessFromMetallicTextureBlue: boolean;
  50590. /**
  50591. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50592. */
  50593. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50594. /**
  50595. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50596. */
  50597. useAmbientInGrayScale: boolean;
  50598. /**
  50599. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50600. * The material will try to infer what glossiness each pixel should be.
  50601. */
  50602. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50603. /**
  50604. * BJS is using an harcoded light falloff based on a manually sets up range.
  50605. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50606. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50607. */
  50608. get usePhysicalLightFalloff(): boolean;
  50609. /**
  50610. * BJS is using an harcoded light falloff based on a manually sets up range.
  50611. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50612. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50613. */
  50614. set usePhysicalLightFalloff(value: boolean);
  50615. /**
  50616. * In order to support the falloff compatibility with gltf, a special mode has been added
  50617. * to reproduce the gltf light falloff.
  50618. */
  50619. get useGLTFLightFalloff(): boolean;
  50620. /**
  50621. * In order to support the falloff compatibility with gltf, a special mode has been added
  50622. * to reproduce the gltf light falloff.
  50623. */
  50624. set useGLTFLightFalloff(value: boolean);
  50625. /**
  50626. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50627. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50628. */
  50629. useRadianceOverAlpha: boolean;
  50630. /**
  50631. * Allows using an object space normal map (instead of tangent space).
  50632. */
  50633. useObjectSpaceNormalMap: boolean;
  50634. /**
  50635. * Allows using the bump map in parallax mode.
  50636. */
  50637. useParallax: boolean;
  50638. /**
  50639. * Allows using the bump map in parallax occlusion mode.
  50640. */
  50641. useParallaxOcclusion: boolean;
  50642. /**
  50643. * Controls the scale bias of the parallax mode.
  50644. */
  50645. parallaxScaleBias: number;
  50646. /**
  50647. * If sets to true, disables all the lights affecting the material.
  50648. */
  50649. disableLighting: boolean;
  50650. /**
  50651. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50652. */
  50653. forceIrradianceInFragment: boolean;
  50654. /**
  50655. * Number of Simultaneous lights allowed on the material.
  50656. */
  50657. maxSimultaneousLights: number;
  50658. /**
  50659. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50660. */
  50661. invertNormalMapX: boolean;
  50662. /**
  50663. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50664. */
  50665. invertNormalMapY: boolean;
  50666. /**
  50667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50668. */
  50669. twoSidedLighting: boolean;
  50670. /**
  50671. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50672. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50673. */
  50674. useAlphaFresnel: boolean;
  50675. /**
  50676. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50677. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50678. */
  50679. useLinearAlphaFresnel: boolean;
  50680. /**
  50681. * Let user defines the brdf lookup texture used for IBL.
  50682. * A default 8bit version is embedded but you could point at :
  50683. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50684. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50685. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50686. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50687. */
  50688. environmentBRDFTexture: Nullable<BaseTexture>;
  50689. /**
  50690. * Force normal to face away from face.
  50691. */
  50692. forceNormalForward: boolean;
  50693. /**
  50694. * Enables specular anti aliasing in the PBR shader.
  50695. * It will both interacts on the Geometry for analytical and IBL lighting.
  50696. * It also prefilter the roughness map based on the bump values.
  50697. */
  50698. enableSpecularAntiAliasing: boolean;
  50699. /**
  50700. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50701. * makes the reflect vector face the model (under horizon).
  50702. */
  50703. useHorizonOcclusion: boolean;
  50704. /**
  50705. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50706. * too much the area relying on ambient texture to define their ambient occlusion.
  50707. */
  50708. useRadianceOcclusion: boolean;
  50709. /**
  50710. * If set to true, no lighting calculations will be applied.
  50711. */
  50712. unlit: boolean;
  50713. /**
  50714. * Gets the image processing configuration used either in this material.
  50715. */
  50716. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50717. /**
  50718. * Sets the Default image processing configuration used either in the this material.
  50719. *
  50720. * If sets to null, the scene one is in use.
  50721. */
  50722. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50723. /**
  50724. * Gets wether the color curves effect is enabled.
  50725. */
  50726. get cameraColorCurvesEnabled(): boolean;
  50727. /**
  50728. * Sets wether the color curves effect is enabled.
  50729. */
  50730. set cameraColorCurvesEnabled(value: boolean);
  50731. /**
  50732. * Gets wether the color grading effect is enabled.
  50733. */
  50734. get cameraColorGradingEnabled(): boolean;
  50735. /**
  50736. * Gets wether the color grading effect is enabled.
  50737. */
  50738. set cameraColorGradingEnabled(value: boolean);
  50739. /**
  50740. * Gets wether tonemapping is enabled or not.
  50741. */
  50742. get cameraToneMappingEnabled(): boolean;
  50743. /**
  50744. * Sets wether tonemapping is enabled or not
  50745. */
  50746. set cameraToneMappingEnabled(value: boolean);
  50747. /**
  50748. * The camera exposure used on this material.
  50749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50750. * This corresponds to a photographic exposure.
  50751. */
  50752. get cameraExposure(): number;
  50753. /**
  50754. * The camera exposure used on this material.
  50755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50756. * This corresponds to a photographic exposure.
  50757. */
  50758. set cameraExposure(value: number);
  50759. /**
  50760. * Gets The camera contrast used on this material.
  50761. */
  50762. get cameraContrast(): number;
  50763. /**
  50764. * Sets The camera contrast used on this material.
  50765. */
  50766. set cameraContrast(value: number);
  50767. /**
  50768. * Gets the Color Grading 2D Lookup Texture.
  50769. */
  50770. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50771. /**
  50772. * Sets the Color Grading 2D Lookup Texture.
  50773. */
  50774. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50775. /**
  50776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50778. * 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;
  50779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50780. */
  50781. get cameraColorCurves(): Nullable<ColorCurves>;
  50782. /**
  50783. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50784. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50785. * 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;
  50786. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50787. */
  50788. set cameraColorCurves(value: Nullable<ColorCurves>);
  50789. /**
  50790. * Instantiates a new PBRMaterial instance.
  50791. *
  50792. * @param name The material name
  50793. * @param scene The scene the material will be use in.
  50794. */
  50795. constructor(name: string, scene: Scene);
  50796. /**
  50797. * Returns the name of this material class.
  50798. */
  50799. getClassName(): string;
  50800. /**
  50801. * Makes a duplicate of the current material.
  50802. * @param name - name to use for the new material.
  50803. */
  50804. clone(name: string): PBRMaterial;
  50805. /**
  50806. * Serializes this PBR Material.
  50807. * @returns - An object with the serialized material.
  50808. */
  50809. serialize(): any;
  50810. /**
  50811. * Parses a PBR Material from a serialized object.
  50812. * @param source - Serialized object.
  50813. * @param scene - BJS scene instance.
  50814. * @param rootUrl - url for the scene object
  50815. * @returns - PBRMaterial
  50816. */
  50817. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50818. }
  50819. }
  50820. declare module BABYLON {
  50821. /**
  50822. * Direct draw surface info
  50823. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50824. */
  50825. export interface DDSInfo {
  50826. /**
  50827. * Width of the texture
  50828. */
  50829. width: number;
  50830. /**
  50831. * Width of the texture
  50832. */
  50833. height: number;
  50834. /**
  50835. * Number of Mipmaps for the texture
  50836. * @see https://en.wikipedia.org/wiki/Mipmap
  50837. */
  50838. mipmapCount: number;
  50839. /**
  50840. * If the textures format is a known fourCC format
  50841. * @see https://www.fourcc.org/
  50842. */
  50843. isFourCC: boolean;
  50844. /**
  50845. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50846. */
  50847. isRGB: boolean;
  50848. /**
  50849. * If the texture is a lumincance format
  50850. */
  50851. isLuminance: boolean;
  50852. /**
  50853. * If this is a cube texture
  50854. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50855. */
  50856. isCube: boolean;
  50857. /**
  50858. * If the texture is a compressed format eg. FOURCC_DXT1
  50859. */
  50860. isCompressed: boolean;
  50861. /**
  50862. * The dxgiFormat of the texture
  50863. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50864. */
  50865. dxgiFormat: number;
  50866. /**
  50867. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50868. */
  50869. textureType: number;
  50870. /**
  50871. * Sphericle polynomial created for the dds texture
  50872. */
  50873. sphericalPolynomial?: SphericalPolynomial;
  50874. }
  50875. /**
  50876. * Class used to provide DDS decompression tools
  50877. */
  50878. export class DDSTools {
  50879. /**
  50880. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50881. */
  50882. static StoreLODInAlphaChannel: boolean;
  50883. /**
  50884. * Gets DDS information from an array buffer
  50885. * @param arrayBuffer defines the array buffer to read data from
  50886. * @returns the DDS information
  50887. */
  50888. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50889. private static _FloatView;
  50890. private static _Int32View;
  50891. private static _ToHalfFloat;
  50892. private static _FromHalfFloat;
  50893. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50894. private static _GetHalfFloatRGBAArrayBuffer;
  50895. private static _GetFloatRGBAArrayBuffer;
  50896. private static _GetFloatAsUIntRGBAArrayBuffer;
  50897. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50898. private static _GetRGBAArrayBuffer;
  50899. private static _ExtractLongWordOrder;
  50900. private static _GetRGBArrayBuffer;
  50901. private static _GetLuminanceArrayBuffer;
  50902. /**
  50903. * Uploads DDS Levels to a Babylon Texture
  50904. * @hidden
  50905. */
  50906. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50907. }
  50908. interface ThinEngine {
  50909. /**
  50910. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50911. * @param rootUrl defines the url where the file to load is located
  50912. * @param scene defines the current scene
  50913. * @param lodScale defines scale to apply to the mip map selection
  50914. * @param lodOffset defines offset to apply to the mip map selection
  50915. * @param onLoad defines an optional callback raised when the texture is loaded
  50916. * @param onError defines an optional callback raised if there is an issue to load the texture
  50917. * @param format defines the format of the data
  50918. * @param forcedExtension defines the extension to use to pick the right loader
  50919. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50920. * @returns the cube texture as an InternalTexture
  50921. */
  50922. 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;
  50923. }
  50924. }
  50925. declare module BABYLON {
  50926. /**
  50927. * Implementation of the DDS Texture Loader.
  50928. * @hidden
  50929. */
  50930. export class _DDSTextureLoader implements IInternalTextureLoader {
  50931. /**
  50932. * Defines wether the loader supports cascade loading the different faces.
  50933. */
  50934. readonly supportCascades: boolean;
  50935. /**
  50936. * This returns if the loader support the current file information.
  50937. * @param extension defines the file extension of the file being loaded
  50938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50939. * @param fallback defines the fallback internal texture if any
  50940. * @param isBase64 defines whether the texture is encoded as a base64
  50941. * @param isBuffer defines whether the texture data are stored as a buffer
  50942. * @returns true if the loader can load the specified file
  50943. */
  50944. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50945. /**
  50946. * Transform the url before loading if required.
  50947. * @param rootUrl the url of the texture
  50948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50949. * @returns the transformed texture
  50950. */
  50951. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50952. /**
  50953. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50954. * @param rootUrl the url of the texture
  50955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50956. * @returns the fallback texture
  50957. */
  50958. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50959. /**
  50960. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50961. * @param data contains the texture data
  50962. * @param texture defines the BabylonJS internal texture
  50963. * @param createPolynomials will be true if polynomials have been requested
  50964. * @param onLoad defines the callback to trigger once the texture is ready
  50965. * @param onError defines the callback to trigger in case of error
  50966. */
  50967. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50968. /**
  50969. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50970. * @param data contains the texture data
  50971. * @param texture defines the BabylonJS internal texture
  50972. * @param callback defines the method to call once ready to upload
  50973. */
  50974. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. /**
  50979. * Implementation of the ENV Texture Loader.
  50980. * @hidden
  50981. */
  50982. export class _ENVTextureLoader implements IInternalTextureLoader {
  50983. /**
  50984. * Defines wether the loader supports cascade loading the different faces.
  50985. */
  50986. readonly supportCascades: boolean;
  50987. /**
  50988. * This returns if the loader support the current file information.
  50989. * @param extension defines the file extension of the file being loaded
  50990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50991. * @param fallback defines the fallback internal texture if any
  50992. * @param isBase64 defines whether the texture is encoded as a base64
  50993. * @param isBuffer defines whether the texture data are stored as a buffer
  50994. * @returns true if the loader can load the specified file
  50995. */
  50996. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50997. /**
  50998. * Transform the url before loading if required.
  50999. * @param rootUrl the url of the texture
  51000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51001. * @returns the transformed texture
  51002. */
  51003. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51004. /**
  51005. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51006. * @param rootUrl the url of the texture
  51007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51008. * @returns the fallback texture
  51009. */
  51010. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51011. /**
  51012. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51013. * @param data contains the texture data
  51014. * @param texture defines the BabylonJS internal texture
  51015. * @param createPolynomials will be true if polynomials have been requested
  51016. * @param onLoad defines the callback to trigger once the texture is ready
  51017. * @param onError defines the callback to trigger in case of error
  51018. */
  51019. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51020. /**
  51021. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51022. * @param data contains the texture data
  51023. * @param texture defines the BabylonJS internal texture
  51024. * @param callback defines the method to call once ready to upload
  51025. */
  51026. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51027. }
  51028. }
  51029. declare module BABYLON {
  51030. /**
  51031. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51032. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51033. */
  51034. export class KhronosTextureContainer {
  51035. /** contents of the KTX container file */
  51036. arrayBuffer: any;
  51037. private static HEADER_LEN;
  51038. private static COMPRESSED_2D;
  51039. private static COMPRESSED_3D;
  51040. private static TEX_2D;
  51041. private static TEX_3D;
  51042. /**
  51043. * Gets the openGL type
  51044. */
  51045. glType: number;
  51046. /**
  51047. * Gets the openGL type size
  51048. */
  51049. glTypeSize: number;
  51050. /**
  51051. * Gets the openGL format
  51052. */
  51053. glFormat: number;
  51054. /**
  51055. * Gets the openGL internal format
  51056. */
  51057. glInternalFormat: number;
  51058. /**
  51059. * Gets the base internal format
  51060. */
  51061. glBaseInternalFormat: number;
  51062. /**
  51063. * Gets image width in pixel
  51064. */
  51065. pixelWidth: number;
  51066. /**
  51067. * Gets image height in pixel
  51068. */
  51069. pixelHeight: number;
  51070. /**
  51071. * Gets image depth in pixels
  51072. */
  51073. pixelDepth: number;
  51074. /**
  51075. * Gets the number of array elements
  51076. */
  51077. numberOfArrayElements: number;
  51078. /**
  51079. * Gets the number of faces
  51080. */
  51081. numberOfFaces: number;
  51082. /**
  51083. * Gets the number of mipmap levels
  51084. */
  51085. numberOfMipmapLevels: number;
  51086. /**
  51087. * Gets the bytes of key value data
  51088. */
  51089. bytesOfKeyValueData: number;
  51090. /**
  51091. * Gets the load type
  51092. */
  51093. loadType: number;
  51094. /**
  51095. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51096. */
  51097. isInvalid: boolean;
  51098. /**
  51099. * Creates a new KhronosTextureContainer
  51100. * @param arrayBuffer contents of the KTX container file
  51101. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51102. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51103. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51104. */
  51105. constructor(
  51106. /** contents of the KTX container file */
  51107. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51108. /**
  51109. * Uploads KTX content to a Babylon Texture.
  51110. * It is assumed that the texture has already been created & is currently bound
  51111. * @hidden
  51112. */
  51113. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51114. private _upload2DCompressedLevels;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * Implementation of the KTX Texture Loader.
  51120. * @hidden
  51121. */
  51122. export class _KTXTextureLoader implements IInternalTextureLoader {
  51123. /**
  51124. * Defines wether the loader supports cascade loading the different faces.
  51125. */
  51126. readonly supportCascades: boolean;
  51127. /**
  51128. * This returns if the loader support the current file information.
  51129. * @param extension defines the file extension of the file being loaded
  51130. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51131. * @param fallback defines the fallback internal texture if any
  51132. * @param isBase64 defines whether the texture is encoded as a base64
  51133. * @param isBuffer defines whether the texture data are stored as a buffer
  51134. * @returns true if the loader can load the specified file
  51135. */
  51136. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51137. /**
  51138. * Transform the url before loading if required.
  51139. * @param rootUrl the url of the texture
  51140. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51141. * @returns the transformed texture
  51142. */
  51143. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51144. /**
  51145. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51146. * @param rootUrl the url of the texture
  51147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51148. * @returns the fallback texture
  51149. */
  51150. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51151. /**
  51152. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51153. * @param data contains the texture data
  51154. * @param texture defines the BabylonJS internal texture
  51155. * @param createPolynomials will be true if polynomials have been requested
  51156. * @param onLoad defines the callback to trigger once the texture is ready
  51157. * @param onError defines the callback to trigger in case of error
  51158. */
  51159. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51160. /**
  51161. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51162. * @param data contains the texture data
  51163. * @param texture defines the BabylonJS internal texture
  51164. * @param callback defines the method to call once ready to upload
  51165. */
  51166. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51167. }
  51168. }
  51169. declare module BABYLON {
  51170. /** @hidden */
  51171. export var _forceSceneHelpersToBundle: boolean;
  51172. interface Scene {
  51173. /**
  51174. * Creates a default light for the scene.
  51175. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51176. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51177. */
  51178. createDefaultLight(replace?: boolean): void;
  51179. /**
  51180. * Creates a default camera for the scene.
  51181. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51182. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51183. * @param replace has default false, when true replaces the active camera in the scene
  51184. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51185. */
  51186. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51187. /**
  51188. * Creates a default camera and a default light.
  51189. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51190. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51191. * @param replace has the default false, when true replaces the active camera/light in the scene
  51192. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51193. */
  51194. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51195. /**
  51196. * Creates a new sky box
  51197. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51198. * @param environmentTexture defines the texture to use as environment texture
  51199. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51200. * @param scale defines the overall scale of the skybox
  51201. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51202. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51203. * @returns a new mesh holding the sky box
  51204. */
  51205. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51206. /**
  51207. * Creates a new environment
  51208. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51209. * @param options defines the options you can use to configure the environment
  51210. * @returns the new EnvironmentHelper
  51211. */
  51212. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51213. /**
  51214. * Creates a new VREXperienceHelper
  51215. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51216. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51217. * @returns a new VREXperienceHelper
  51218. */
  51219. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51220. /**
  51221. * Creates a new WebXRDefaultExperience
  51222. * @see http://doc.babylonjs.com/how_to/webxr
  51223. * @param options experience options
  51224. * @returns a promise for a new WebXRDefaultExperience
  51225. */
  51226. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51227. }
  51228. }
  51229. declare module BABYLON {
  51230. /**
  51231. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51232. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51233. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51234. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51235. */
  51236. export class VideoDome extends TransformNode {
  51237. /**
  51238. * Define the video source as a Monoscopic panoramic 360 video.
  51239. */
  51240. static readonly MODE_MONOSCOPIC: number;
  51241. /**
  51242. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51243. */
  51244. static readonly MODE_TOPBOTTOM: number;
  51245. /**
  51246. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51247. */
  51248. static readonly MODE_SIDEBYSIDE: number;
  51249. private _halfDome;
  51250. private _useDirectMapping;
  51251. /**
  51252. * The video texture being displayed on the sphere
  51253. */
  51254. protected _videoTexture: VideoTexture;
  51255. /**
  51256. * Gets the video texture being displayed on the sphere
  51257. */
  51258. get videoTexture(): VideoTexture;
  51259. /**
  51260. * The skybox material
  51261. */
  51262. protected _material: BackgroundMaterial;
  51263. /**
  51264. * The surface used for the skybox
  51265. */
  51266. protected _mesh: Mesh;
  51267. /**
  51268. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51269. */
  51270. private _halfDomeMask;
  51271. /**
  51272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51273. * Also see the options.resolution property.
  51274. */
  51275. get fovMultiplier(): number;
  51276. set fovMultiplier(value: number);
  51277. private _videoMode;
  51278. /**
  51279. * Gets or set the current video mode for the video. It can be:
  51280. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51281. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51282. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51283. */
  51284. get videoMode(): number;
  51285. set videoMode(value: number);
  51286. /**
  51287. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51288. *
  51289. */
  51290. get halfDome(): boolean;
  51291. /**
  51292. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51293. */
  51294. set halfDome(enabled: boolean);
  51295. /**
  51296. * Oberserver used in Stereoscopic VR Mode.
  51297. */
  51298. private _onBeforeCameraRenderObserver;
  51299. /**
  51300. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51301. * @param name Element's name, child elements will append suffixes for their own names.
  51302. * @param urlsOrVideo defines the url(s) or the video element to use
  51303. * @param options An object containing optional or exposed sub element properties
  51304. */
  51305. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51306. resolution?: number;
  51307. clickToPlay?: boolean;
  51308. autoPlay?: boolean;
  51309. loop?: boolean;
  51310. size?: number;
  51311. poster?: string;
  51312. faceForward?: boolean;
  51313. useDirectMapping?: boolean;
  51314. halfDomeMode?: boolean;
  51315. }, scene: Scene);
  51316. private _changeVideoMode;
  51317. /**
  51318. * Releases resources associated with this node.
  51319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51321. */
  51322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51323. }
  51324. }
  51325. declare module BABYLON {
  51326. /**
  51327. * This class can be used to get instrumentation data from a Babylon engine
  51328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51329. */
  51330. export class EngineInstrumentation implements IDisposable {
  51331. /**
  51332. * Define the instrumented engine.
  51333. */
  51334. engine: Engine;
  51335. private _captureGPUFrameTime;
  51336. private _gpuFrameTimeToken;
  51337. private _gpuFrameTime;
  51338. private _captureShaderCompilationTime;
  51339. private _shaderCompilationTime;
  51340. private _onBeginFrameObserver;
  51341. private _onEndFrameObserver;
  51342. private _onBeforeShaderCompilationObserver;
  51343. private _onAfterShaderCompilationObserver;
  51344. /**
  51345. * Gets the perf counter used for GPU frame time
  51346. */
  51347. get gpuFrameTimeCounter(): PerfCounter;
  51348. /**
  51349. * Gets the GPU frame time capture status
  51350. */
  51351. get captureGPUFrameTime(): boolean;
  51352. /**
  51353. * Enable or disable the GPU frame time capture
  51354. */
  51355. set captureGPUFrameTime(value: boolean);
  51356. /**
  51357. * Gets the perf counter used for shader compilation time
  51358. */
  51359. get shaderCompilationTimeCounter(): PerfCounter;
  51360. /**
  51361. * Gets the shader compilation time capture status
  51362. */
  51363. get captureShaderCompilationTime(): boolean;
  51364. /**
  51365. * Enable or disable the shader compilation time capture
  51366. */
  51367. set captureShaderCompilationTime(value: boolean);
  51368. /**
  51369. * Instantiates a new engine instrumentation.
  51370. * This class can be used to get instrumentation data from a Babylon engine
  51371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51372. * @param engine Defines the engine to instrument
  51373. */
  51374. constructor(
  51375. /**
  51376. * Define the instrumented engine.
  51377. */
  51378. engine: Engine);
  51379. /**
  51380. * Dispose and release associated resources.
  51381. */
  51382. dispose(): void;
  51383. }
  51384. }
  51385. declare module BABYLON {
  51386. /**
  51387. * This class can be used to get instrumentation data from a Babylon engine
  51388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51389. */
  51390. export class SceneInstrumentation implements IDisposable {
  51391. /**
  51392. * Defines the scene to instrument
  51393. */
  51394. scene: Scene;
  51395. private _captureActiveMeshesEvaluationTime;
  51396. private _activeMeshesEvaluationTime;
  51397. private _captureRenderTargetsRenderTime;
  51398. private _renderTargetsRenderTime;
  51399. private _captureFrameTime;
  51400. private _frameTime;
  51401. private _captureRenderTime;
  51402. private _renderTime;
  51403. private _captureInterFrameTime;
  51404. private _interFrameTime;
  51405. private _captureParticlesRenderTime;
  51406. private _particlesRenderTime;
  51407. private _captureSpritesRenderTime;
  51408. private _spritesRenderTime;
  51409. private _capturePhysicsTime;
  51410. private _physicsTime;
  51411. private _captureAnimationsTime;
  51412. private _animationsTime;
  51413. private _captureCameraRenderTime;
  51414. private _cameraRenderTime;
  51415. private _onBeforeActiveMeshesEvaluationObserver;
  51416. private _onAfterActiveMeshesEvaluationObserver;
  51417. private _onBeforeRenderTargetsRenderObserver;
  51418. private _onAfterRenderTargetsRenderObserver;
  51419. private _onAfterRenderObserver;
  51420. private _onBeforeDrawPhaseObserver;
  51421. private _onAfterDrawPhaseObserver;
  51422. private _onBeforeAnimationsObserver;
  51423. private _onBeforeParticlesRenderingObserver;
  51424. private _onAfterParticlesRenderingObserver;
  51425. private _onBeforeSpritesRenderingObserver;
  51426. private _onAfterSpritesRenderingObserver;
  51427. private _onBeforePhysicsObserver;
  51428. private _onAfterPhysicsObserver;
  51429. private _onAfterAnimationsObserver;
  51430. private _onBeforeCameraRenderObserver;
  51431. private _onAfterCameraRenderObserver;
  51432. /**
  51433. * Gets the perf counter used for active meshes evaluation time
  51434. */
  51435. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51436. /**
  51437. * Gets the active meshes evaluation time capture status
  51438. */
  51439. get captureActiveMeshesEvaluationTime(): boolean;
  51440. /**
  51441. * Enable or disable the active meshes evaluation time capture
  51442. */
  51443. set captureActiveMeshesEvaluationTime(value: boolean);
  51444. /**
  51445. * Gets the perf counter used for render targets render time
  51446. */
  51447. get renderTargetsRenderTimeCounter(): PerfCounter;
  51448. /**
  51449. * Gets the render targets render time capture status
  51450. */
  51451. get captureRenderTargetsRenderTime(): boolean;
  51452. /**
  51453. * Enable or disable the render targets render time capture
  51454. */
  51455. set captureRenderTargetsRenderTime(value: boolean);
  51456. /**
  51457. * Gets the perf counter used for particles render time
  51458. */
  51459. get particlesRenderTimeCounter(): PerfCounter;
  51460. /**
  51461. * Gets the particles render time capture status
  51462. */
  51463. get captureParticlesRenderTime(): boolean;
  51464. /**
  51465. * Enable or disable the particles render time capture
  51466. */
  51467. set captureParticlesRenderTime(value: boolean);
  51468. /**
  51469. * Gets the perf counter used for sprites render time
  51470. */
  51471. get spritesRenderTimeCounter(): PerfCounter;
  51472. /**
  51473. * Gets the sprites render time capture status
  51474. */
  51475. get captureSpritesRenderTime(): boolean;
  51476. /**
  51477. * Enable or disable the sprites render time capture
  51478. */
  51479. set captureSpritesRenderTime(value: boolean);
  51480. /**
  51481. * Gets the perf counter used for physics time
  51482. */
  51483. get physicsTimeCounter(): PerfCounter;
  51484. /**
  51485. * Gets the physics time capture status
  51486. */
  51487. get capturePhysicsTime(): boolean;
  51488. /**
  51489. * Enable or disable the physics time capture
  51490. */
  51491. set capturePhysicsTime(value: boolean);
  51492. /**
  51493. * Gets the perf counter used for animations time
  51494. */
  51495. get animationsTimeCounter(): PerfCounter;
  51496. /**
  51497. * Gets the animations time capture status
  51498. */
  51499. get captureAnimationsTime(): boolean;
  51500. /**
  51501. * Enable or disable the animations time capture
  51502. */
  51503. set captureAnimationsTime(value: boolean);
  51504. /**
  51505. * Gets the perf counter used for frame time capture
  51506. */
  51507. get frameTimeCounter(): PerfCounter;
  51508. /**
  51509. * Gets the frame time capture status
  51510. */
  51511. get captureFrameTime(): boolean;
  51512. /**
  51513. * Enable or disable the frame time capture
  51514. */
  51515. set captureFrameTime(value: boolean);
  51516. /**
  51517. * Gets the perf counter used for inter-frames time capture
  51518. */
  51519. get interFrameTimeCounter(): PerfCounter;
  51520. /**
  51521. * Gets the inter-frames time capture status
  51522. */
  51523. get captureInterFrameTime(): boolean;
  51524. /**
  51525. * Enable or disable the inter-frames time capture
  51526. */
  51527. set captureInterFrameTime(value: boolean);
  51528. /**
  51529. * Gets the perf counter used for render time capture
  51530. */
  51531. get renderTimeCounter(): PerfCounter;
  51532. /**
  51533. * Gets the render time capture status
  51534. */
  51535. get captureRenderTime(): boolean;
  51536. /**
  51537. * Enable or disable the render time capture
  51538. */
  51539. set captureRenderTime(value: boolean);
  51540. /**
  51541. * Gets the perf counter used for camera render time capture
  51542. */
  51543. get cameraRenderTimeCounter(): PerfCounter;
  51544. /**
  51545. * Gets the camera render time capture status
  51546. */
  51547. get captureCameraRenderTime(): boolean;
  51548. /**
  51549. * Enable or disable the camera render time capture
  51550. */
  51551. set captureCameraRenderTime(value: boolean);
  51552. /**
  51553. * Gets the perf counter used for draw calls
  51554. */
  51555. get drawCallsCounter(): PerfCounter;
  51556. /**
  51557. * Instantiates a new scene instrumentation.
  51558. * This class can be used to get instrumentation data from a Babylon engine
  51559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51560. * @param scene Defines the scene to instrument
  51561. */
  51562. constructor(
  51563. /**
  51564. * Defines the scene to instrument
  51565. */
  51566. scene: Scene);
  51567. /**
  51568. * Dispose and release associated resources.
  51569. */
  51570. dispose(): void;
  51571. }
  51572. }
  51573. declare module BABYLON {
  51574. /** @hidden */
  51575. export var glowMapGenerationPixelShader: {
  51576. name: string;
  51577. shader: string;
  51578. };
  51579. }
  51580. declare module BABYLON {
  51581. /** @hidden */
  51582. export var glowMapGenerationVertexShader: {
  51583. name: string;
  51584. shader: string;
  51585. };
  51586. }
  51587. declare module BABYLON {
  51588. /**
  51589. * Effect layer options. This helps customizing the behaviour
  51590. * of the effect layer.
  51591. */
  51592. export interface IEffectLayerOptions {
  51593. /**
  51594. * Multiplication factor apply to the canvas size to compute the render target size
  51595. * used to generated the objects (the smaller the faster).
  51596. */
  51597. mainTextureRatio: number;
  51598. /**
  51599. * Enforces a fixed size texture to ensure effect stability across devices.
  51600. */
  51601. mainTextureFixedSize?: number;
  51602. /**
  51603. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51604. */
  51605. alphaBlendingMode: number;
  51606. /**
  51607. * The camera attached to the layer.
  51608. */
  51609. camera: Nullable<Camera>;
  51610. /**
  51611. * The rendering group to draw the layer in.
  51612. */
  51613. renderingGroupId: number;
  51614. }
  51615. /**
  51616. * The effect layer Helps adding post process effect blended with the main pass.
  51617. *
  51618. * This can be for instance use to generate glow or higlight effects on the scene.
  51619. *
  51620. * The effect layer class can not be used directly and is intented to inherited from to be
  51621. * customized per effects.
  51622. */
  51623. export abstract class EffectLayer {
  51624. private _vertexBuffers;
  51625. private _indexBuffer;
  51626. private _cachedDefines;
  51627. private _effectLayerMapGenerationEffect;
  51628. private _effectLayerOptions;
  51629. private _mergeEffect;
  51630. protected _scene: Scene;
  51631. protected _engine: Engine;
  51632. protected _maxSize: number;
  51633. protected _mainTextureDesiredSize: ISize;
  51634. protected _mainTexture: RenderTargetTexture;
  51635. protected _shouldRender: boolean;
  51636. protected _postProcesses: PostProcess[];
  51637. protected _textures: BaseTexture[];
  51638. protected _emissiveTextureAndColor: {
  51639. texture: Nullable<BaseTexture>;
  51640. color: Color4;
  51641. };
  51642. /**
  51643. * The name of the layer
  51644. */
  51645. name: string;
  51646. /**
  51647. * The clear color of the texture used to generate the glow map.
  51648. */
  51649. neutralColor: Color4;
  51650. /**
  51651. * Specifies wether the highlight layer is enabled or not.
  51652. */
  51653. isEnabled: boolean;
  51654. /**
  51655. * Gets the camera attached to the layer.
  51656. */
  51657. get camera(): Nullable<Camera>;
  51658. /**
  51659. * Gets the rendering group id the layer should render in.
  51660. */
  51661. get renderingGroupId(): number;
  51662. set renderingGroupId(renderingGroupId: number);
  51663. /**
  51664. * An event triggered when the effect layer has been disposed.
  51665. */
  51666. onDisposeObservable: Observable<EffectLayer>;
  51667. /**
  51668. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51669. */
  51670. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51671. /**
  51672. * An event triggered when the generated texture is being merged in the scene.
  51673. */
  51674. onBeforeComposeObservable: Observable<EffectLayer>;
  51675. /**
  51676. * An event triggered when the mesh is rendered into the effect render target.
  51677. */
  51678. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51679. /**
  51680. * An event triggered after the mesh has been rendered into the effect render target.
  51681. */
  51682. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51683. /**
  51684. * An event triggered when the generated texture has been merged in the scene.
  51685. */
  51686. onAfterComposeObservable: Observable<EffectLayer>;
  51687. /**
  51688. * An event triggered when the efffect layer changes its size.
  51689. */
  51690. onSizeChangedObservable: Observable<EffectLayer>;
  51691. /** @hidden */
  51692. static _SceneComponentInitialization: (scene: Scene) => void;
  51693. /**
  51694. * Instantiates a new effect Layer and references it in the scene.
  51695. * @param name The name of the layer
  51696. * @param scene The scene to use the layer in
  51697. */
  51698. constructor(
  51699. /** The Friendly of the effect in the scene */
  51700. name: string, scene: Scene);
  51701. /**
  51702. * Get the effect name of the layer.
  51703. * @return The effect name
  51704. */
  51705. abstract getEffectName(): string;
  51706. /**
  51707. * Checks for the readiness of the element composing the layer.
  51708. * @param subMesh the mesh to check for
  51709. * @param useInstances specify wether or not to use instances to render the mesh
  51710. * @return true if ready otherwise, false
  51711. */
  51712. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51713. /**
  51714. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51715. * @returns true if the effect requires stencil during the main canvas render pass.
  51716. */
  51717. abstract needStencil(): boolean;
  51718. /**
  51719. * Create the merge effect. This is the shader use to blit the information back
  51720. * to the main canvas at the end of the scene rendering.
  51721. * @returns The effect containing the shader used to merge the effect on the main canvas
  51722. */
  51723. protected abstract _createMergeEffect(): Effect;
  51724. /**
  51725. * Creates the render target textures and post processes used in the effect layer.
  51726. */
  51727. protected abstract _createTextureAndPostProcesses(): void;
  51728. /**
  51729. * Implementation specific of rendering the generating effect on the main canvas.
  51730. * @param effect The effect used to render through
  51731. */
  51732. protected abstract _internalRender(effect: Effect): void;
  51733. /**
  51734. * Sets the required values for both the emissive texture and and the main color.
  51735. */
  51736. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51737. /**
  51738. * Free any resources and references associated to a mesh.
  51739. * Internal use
  51740. * @param mesh The mesh to free.
  51741. */
  51742. abstract _disposeMesh(mesh: Mesh): void;
  51743. /**
  51744. * Serializes this layer (Glow or Highlight for example)
  51745. * @returns a serialized layer object
  51746. */
  51747. abstract serialize?(): any;
  51748. /**
  51749. * Initializes the effect layer with the required options.
  51750. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51751. */
  51752. protected _init(options: Partial<IEffectLayerOptions>): void;
  51753. /**
  51754. * Generates the index buffer of the full screen quad blending to the main canvas.
  51755. */
  51756. private _generateIndexBuffer;
  51757. /**
  51758. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51759. */
  51760. private _generateVertexBuffer;
  51761. /**
  51762. * Sets the main texture desired size which is the closest power of two
  51763. * of the engine canvas size.
  51764. */
  51765. private _setMainTextureSize;
  51766. /**
  51767. * Creates the main texture for the effect layer.
  51768. */
  51769. protected _createMainTexture(): void;
  51770. /**
  51771. * Adds specific effects defines.
  51772. * @param defines The defines to add specifics to.
  51773. */
  51774. protected _addCustomEffectDefines(defines: string[]): void;
  51775. /**
  51776. * Checks for the readiness of the element composing the layer.
  51777. * @param subMesh the mesh to check for
  51778. * @param useInstances specify wether or not to use instances to render the mesh
  51779. * @param emissiveTexture the associated emissive texture used to generate the glow
  51780. * @return true if ready otherwise, false
  51781. */
  51782. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51783. /**
  51784. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51785. */
  51786. render(): void;
  51787. /**
  51788. * Determine if a given mesh will be used in the current effect.
  51789. * @param mesh mesh to test
  51790. * @returns true if the mesh will be used
  51791. */
  51792. hasMesh(mesh: AbstractMesh): boolean;
  51793. /**
  51794. * Returns true if the layer contains information to display, otherwise false.
  51795. * @returns true if the glow layer should be rendered
  51796. */
  51797. shouldRender(): boolean;
  51798. /**
  51799. * Returns true if the mesh should render, otherwise false.
  51800. * @param mesh The mesh to render
  51801. * @returns true if it should render otherwise false
  51802. */
  51803. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51804. /**
  51805. * Returns true if the mesh can be rendered, otherwise false.
  51806. * @param mesh The mesh to render
  51807. * @param material The material used on the mesh
  51808. * @returns true if it can be rendered otherwise false
  51809. */
  51810. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51811. /**
  51812. * Returns true if the mesh should render, otherwise false.
  51813. * @param mesh The mesh to render
  51814. * @returns true if it should render otherwise false
  51815. */
  51816. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51817. /**
  51818. * Renders the submesh passed in parameter to the generation map.
  51819. */
  51820. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51821. /**
  51822. * Defines wether the current material of the mesh should be use to render the effect.
  51823. * @param mesh defines the current mesh to render
  51824. */
  51825. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51826. /**
  51827. * Rebuild the required buffers.
  51828. * @hidden Internal use only.
  51829. */
  51830. _rebuild(): void;
  51831. /**
  51832. * Dispose only the render target textures and post process.
  51833. */
  51834. private _disposeTextureAndPostProcesses;
  51835. /**
  51836. * Dispose the highlight layer and free resources.
  51837. */
  51838. dispose(): void;
  51839. /**
  51840. * Gets the class name of the effect layer
  51841. * @returns the string with the class name of the effect layer
  51842. */
  51843. getClassName(): string;
  51844. /**
  51845. * Creates an effect layer from parsed effect layer data
  51846. * @param parsedEffectLayer defines effect layer data
  51847. * @param scene defines the current scene
  51848. * @param rootUrl defines the root URL containing the effect layer information
  51849. * @returns a parsed effect Layer
  51850. */
  51851. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51852. }
  51853. }
  51854. declare module BABYLON {
  51855. interface AbstractScene {
  51856. /**
  51857. * The list of effect layers (highlights/glow) added to the scene
  51858. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51859. * @see http://doc.babylonjs.com/how_to/glow_layer
  51860. */
  51861. effectLayers: Array<EffectLayer>;
  51862. /**
  51863. * Removes the given effect layer from this scene.
  51864. * @param toRemove defines the effect layer to remove
  51865. * @returns the index of the removed effect layer
  51866. */
  51867. removeEffectLayer(toRemove: EffectLayer): number;
  51868. /**
  51869. * Adds the given effect layer to this scene
  51870. * @param newEffectLayer defines the effect layer to add
  51871. */
  51872. addEffectLayer(newEffectLayer: EffectLayer): void;
  51873. }
  51874. /**
  51875. * Defines the layer scene component responsible to manage any effect layers
  51876. * in a given scene.
  51877. */
  51878. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51879. /**
  51880. * The component name helpfull to identify the component in the list of scene components.
  51881. */
  51882. readonly name: string;
  51883. /**
  51884. * The scene the component belongs to.
  51885. */
  51886. scene: Scene;
  51887. private _engine;
  51888. private _renderEffects;
  51889. private _needStencil;
  51890. private _previousStencilState;
  51891. /**
  51892. * Creates a new instance of the component for the given scene
  51893. * @param scene Defines the scene to register the component in
  51894. */
  51895. constructor(scene: Scene);
  51896. /**
  51897. * Registers the component in a given scene
  51898. */
  51899. register(): void;
  51900. /**
  51901. * Rebuilds the elements related to this component in case of
  51902. * context lost for instance.
  51903. */
  51904. rebuild(): void;
  51905. /**
  51906. * Serializes the component data to the specified json object
  51907. * @param serializationObject The object to serialize to
  51908. */
  51909. serialize(serializationObject: any): void;
  51910. /**
  51911. * Adds all the elements from the container to the scene
  51912. * @param container the container holding the elements
  51913. */
  51914. addFromContainer(container: AbstractScene): void;
  51915. /**
  51916. * Removes all the elements in the container from the scene
  51917. * @param container contains the elements to remove
  51918. * @param dispose if the removed element should be disposed (default: false)
  51919. */
  51920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51921. /**
  51922. * Disposes the component and the associated ressources.
  51923. */
  51924. dispose(): void;
  51925. private _isReadyForMesh;
  51926. private _renderMainTexture;
  51927. private _setStencil;
  51928. private _setStencilBack;
  51929. private _draw;
  51930. private _drawCamera;
  51931. private _drawRenderingGroup;
  51932. }
  51933. }
  51934. declare module BABYLON {
  51935. /** @hidden */
  51936. export var glowMapMergePixelShader: {
  51937. name: string;
  51938. shader: string;
  51939. };
  51940. }
  51941. declare module BABYLON {
  51942. /** @hidden */
  51943. export var glowMapMergeVertexShader: {
  51944. name: string;
  51945. shader: string;
  51946. };
  51947. }
  51948. declare module BABYLON {
  51949. interface AbstractScene {
  51950. /**
  51951. * Return a the first highlight layer of the scene with a given name.
  51952. * @param name The name of the highlight layer to look for.
  51953. * @return The highlight layer if found otherwise null.
  51954. */
  51955. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51956. }
  51957. /**
  51958. * Glow layer options. This helps customizing the behaviour
  51959. * of the glow layer.
  51960. */
  51961. export interface IGlowLayerOptions {
  51962. /**
  51963. * Multiplication factor apply to the canvas size to compute the render target size
  51964. * used to generated the glowing objects (the smaller the faster).
  51965. */
  51966. mainTextureRatio: number;
  51967. /**
  51968. * Enforces a fixed size texture to ensure resize independant blur.
  51969. */
  51970. mainTextureFixedSize?: number;
  51971. /**
  51972. * How big is the kernel of the blur texture.
  51973. */
  51974. blurKernelSize: number;
  51975. /**
  51976. * The camera attached to the layer.
  51977. */
  51978. camera: Nullable<Camera>;
  51979. /**
  51980. * Enable MSAA by chosing the number of samples.
  51981. */
  51982. mainTextureSamples?: number;
  51983. /**
  51984. * The rendering group to draw the layer in.
  51985. */
  51986. renderingGroupId: number;
  51987. }
  51988. /**
  51989. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51990. *
  51991. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51992. *
  51993. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51994. */
  51995. export class GlowLayer extends EffectLayer {
  51996. /**
  51997. * Effect Name of the layer.
  51998. */
  51999. static readonly EffectName: string;
  52000. /**
  52001. * The default blur kernel size used for the glow.
  52002. */
  52003. static DefaultBlurKernelSize: number;
  52004. /**
  52005. * The default texture size ratio used for the glow.
  52006. */
  52007. static DefaultTextureRatio: number;
  52008. /**
  52009. * Sets the kernel size of the blur.
  52010. */
  52011. set blurKernelSize(value: number);
  52012. /**
  52013. * Gets the kernel size of the blur.
  52014. */
  52015. get blurKernelSize(): number;
  52016. /**
  52017. * Sets the glow intensity.
  52018. */
  52019. set intensity(value: number);
  52020. /**
  52021. * Gets the glow intensity.
  52022. */
  52023. get intensity(): number;
  52024. private _options;
  52025. private _intensity;
  52026. private _horizontalBlurPostprocess1;
  52027. private _verticalBlurPostprocess1;
  52028. private _horizontalBlurPostprocess2;
  52029. private _verticalBlurPostprocess2;
  52030. private _blurTexture1;
  52031. private _blurTexture2;
  52032. private _postProcesses1;
  52033. private _postProcesses2;
  52034. private _includedOnlyMeshes;
  52035. private _excludedMeshes;
  52036. private _meshesUsingTheirOwnMaterials;
  52037. /**
  52038. * Callback used to let the user override the color selection on a per mesh basis
  52039. */
  52040. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52041. /**
  52042. * Callback used to let the user override the texture selection on a per mesh basis
  52043. */
  52044. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52045. /**
  52046. * Instantiates a new glow Layer and references it to the scene.
  52047. * @param name The name of the layer
  52048. * @param scene The scene to use the layer in
  52049. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52050. */
  52051. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52052. /**
  52053. * Get the effect name of the layer.
  52054. * @return The effect name
  52055. */
  52056. getEffectName(): string;
  52057. /**
  52058. * Create the merge effect. This is the shader use to blit the information back
  52059. * to the main canvas at the end of the scene rendering.
  52060. */
  52061. protected _createMergeEffect(): Effect;
  52062. /**
  52063. * Creates the render target textures and post processes used in the glow layer.
  52064. */
  52065. protected _createTextureAndPostProcesses(): void;
  52066. /**
  52067. * Checks for the readiness of the element composing the layer.
  52068. * @param subMesh the mesh to check for
  52069. * @param useInstances specify wether or not to use instances to render the mesh
  52070. * @param emissiveTexture the associated emissive texture used to generate the glow
  52071. * @return true if ready otherwise, false
  52072. */
  52073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52074. /**
  52075. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52076. */
  52077. needStencil(): boolean;
  52078. /**
  52079. * Returns true if the mesh can be rendered, otherwise false.
  52080. * @param mesh The mesh to render
  52081. * @param material The material used on the mesh
  52082. * @returns true if it can be rendered otherwise false
  52083. */
  52084. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52085. /**
  52086. * Implementation specific of rendering the generating effect on the main canvas.
  52087. * @param effect The effect used to render through
  52088. */
  52089. protected _internalRender(effect: Effect): void;
  52090. /**
  52091. * Sets the required values for both the emissive texture and and the main color.
  52092. */
  52093. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52094. /**
  52095. * Returns true if the mesh should render, otherwise false.
  52096. * @param mesh The mesh to render
  52097. * @returns true if it should render otherwise false
  52098. */
  52099. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52100. /**
  52101. * Adds specific effects defines.
  52102. * @param defines The defines to add specifics to.
  52103. */
  52104. protected _addCustomEffectDefines(defines: string[]): void;
  52105. /**
  52106. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52107. * @param mesh The mesh to exclude from the glow layer
  52108. */
  52109. addExcludedMesh(mesh: Mesh): void;
  52110. /**
  52111. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52112. * @param mesh The mesh to remove
  52113. */
  52114. removeExcludedMesh(mesh: Mesh): void;
  52115. /**
  52116. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52117. * @param mesh The mesh to include in the glow layer
  52118. */
  52119. addIncludedOnlyMesh(mesh: Mesh): void;
  52120. /**
  52121. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52122. * @param mesh The mesh to remove
  52123. */
  52124. removeIncludedOnlyMesh(mesh: Mesh): void;
  52125. /**
  52126. * Determine if a given mesh will be used in the glow layer
  52127. * @param mesh The mesh to test
  52128. * @returns true if the mesh will be highlighted by the current glow layer
  52129. */
  52130. hasMesh(mesh: AbstractMesh): boolean;
  52131. /**
  52132. * Defines wether the current material of the mesh should be use to render the effect.
  52133. * @param mesh defines the current mesh to render
  52134. */
  52135. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52136. /**
  52137. * Add a mesh to be rendered through its own material and not with emissive only.
  52138. * @param mesh The mesh for which we need to use its material
  52139. */
  52140. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52141. /**
  52142. * Remove a mesh from being rendered through its own material and not with emissive only.
  52143. * @param mesh The mesh for which we need to not use its material
  52144. */
  52145. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52146. /**
  52147. * Free any resources and references associated to a mesh.
  52148. * Internal use
  52149. * @param mesh The mesh to free.
  52150. * @hidden
  52151. */
  52152. _disposeMesh(mesh: Mesh): void;
  52153. /**
  52154. * Gets the class name of the effect layer
  52155. * @returns the string with the class name of the effect layer
  52156. */
  52157. getClassName(): string;
  52158. /**
  52159. * Serializes this glow layer
  52160. * @returns a serialized glow layer object
  52161. */
  52162. serialize(): any;
  52163. /**
  52164. * Creates a Glow Layer from parsed glow layer data
  52165. * @param parsedGlowLayer defines glow layer data
  52166. * @param scene defines the current scene
  52167. * @param rootUrl defines the root URL containing the glow layer information
  52168. * @returns a parsed Glow Layer
  52169. */
  52170. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52171. }
  52172. }
  52173. declare module BABYLON {
  52174. /** @hidden */
  52175. export var glowBlurPostProcessPixelShader: {
  52176. name: string;
  52177. shader: string;
  52178. };
  52179. }
  52180. declare module BABYLON {
  52181. interface AbstractScene {
  52182. /**
  52183. * Return a the first highlight layer of the scene with a given name.
  52184. * @param name The name of the highlight layer to look for.
  52185. * @return The highlight layer if found otherwise null.
  52186. */
  52187. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52188. }
  52189. /**
  52190. * Highlight layer options. This helps customizing the behaviour
  52191. * of the highlight layer.
  52192. */
  52193. export interface IHighlightLayerOptions {
  52194. /**
  52195. * Multiplication factor apply to the canvas size to compute the render target size
  52196. * used to generated the glowing objects (the smaller the faster).
  52197. */
  52198. mainTextureRatio: number;
  52199. /**
  52200. * Enforces a fixed size texture to ensure resize independant blur.
  52201. */
  52202. mainTextureFixedSize?: number;
  52203. /**
  52204. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52205. * of the picture to blur (the smaller the faster).
  52206. */
  52207. blurTextureSizeRatio: number;
  52208. /**
  52209. * How big in texel of the blur texture is the vertical blur.
  52210. */
  52211. blurVerticalSize: number;
  52212. /**
  52213. * How big in texel of the blur texture is the horizontal blur.
  52214. */
  52215. blurHorizontalSize: number;
  52216. /**
  52217. * Alpha blending mode used to apply the blur. Default is combine.
  52218. */
  52219. alphaBlendingMode: number;
  52220. /**
  52221. * The camera attached to the layer.
  52222. */
  52223. camera: Nullable<Camera>;
  52224. /**
  52225. * Should we display highlight as a solid stroke?
  52226. */
  52227. isStroke?: boolean;
  52228. /**
  52229. * The rendering group to draw the layer in.
  52230. */
  52231. renderingGroupId: number;
  52232. }
  52233. /**
  52234. * The highlight layer Helps adding a glow effect around a mesh.
  52235. *
  52236. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52237. * glowy meshes to your scene.
  52238. *
  52239. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52240. */
  52241. export class HighlightLayer extends EffectLayer {
  52242. name: string;
  52243. /**
  52244. * Effect Name of the highlight layer.
  52245. */
  52246. static readonly EffectName: string;
  52247. /**
  52248. * The neutral color used during the preparation of the glow effect.
  52249. * This is black by default as the blend operation is a blend operation.
  52250. */
  52251. static NeutralColor: Color4;
  52252. /**
  52253. * Stencil value used for glowing meshes.
  52254. */
  52255. static GlowingMeshStencilReference: number;
  52256. /**
  52257. * Stencil value used for the other meshes in the scene.
  52258. */
  52259. static NormalMeshStencilReference: number;
  52260. /**
  52261. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52262. */
  52263. innerGlow: boolean;
  52264. /**
  52265. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52266. */
  52267. outerGlow: boolean;
  52268. /**
  52269. * Specifies the horizontal size of the blur.
  52270. */
  52271. set blurHorizontalSize(value: number);
  52272. /**
  52273. * Specifies the vertical size of the blur.
  52274. */
  52275. set blurVerticalSize(value: number);
  52276. /**
  52277. * Gets the horizontal size of the blur.
  52278. */
  52279. get blurHorizontalSize(): number;
  52280. /**
  52281. * Gets the vertical size of the blur.
  52282. */
  52283. get blurVerticalSize(): number;
  52284. /**
  52285. * An event triggered when the highlight layer is being blurred.
  52286. */
  52287. onBeforeBlurObservable: Observable<HighlightLayer>;
  52288. /**
  52289. * An event triggered when the highlight layer has been blurred.
  52290. */
  52291. onAfterBlurObservable: Observable<HighlightLayer>;
  52292. private _instanceGlowingMeshStencilReference;
  52293. private _options;
  52294. private _downSamplePostprocess;
  52295. private _horizontalBlurPostprocess;
  52296. private _verticalBlurPostprocess;
  52297. private _blurTexture;
  52298. private _meshes;
  52299. private _excludedMeshes;
  52300. /**
  52301. * Instantiates a new highlight Layer and references it to the scene..
  52302. * @param name The name of the layer
  52303. * @param scene The scene to use the layer in
  52304. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52305. */
  52306. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52307. /**
  52308. * Get the effect name of the layer.
  52309. * @return The effect name
  52310. */
  52311. getEffectName(): string;
  52312. /**
  52313. * Create the merge effect. This is the shader use to blit the information back
  52314. * to the main canvas at the end of the scene rendering.
  52315. */
  52316. protected _createMergeEffect(): Effect;
  52317. /**
  52318. * Creates the render target textures and post processes used in the highlight layer.
  52319. */
  52320. protected _createTextureAndPostProcesses(): void;
  52321. /**
  52322. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52323. */
  52324. needStencil(): boolean;
  52325. /**
  52326. * Checks for the readiness of the element composing the layer.
  52327. * @param subMesh the mesh to check for
  52328. * @param useInstances specify wether or not to use instances to render the mesh
  52329. * @param emissiveTexture the associated emissive texture used to generate the glow
  52330. * @return true if ready otherwise, false
  52331. */
  52332. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52333. /**
  52334. * Implementation specific of rendering the generating effect on the main canvas.
  52335. * @param effect The effect used to render through
  52336. */
  52337. protected _internalRender(effect: Effect): void;
  52338. /**
  52339. * Returns true if the layer contains information to display, otherwise false.
  52340. */
  52341. shouldRender(): boolean;
  52342. /**
  52343. * Returns true if the mesh should render, otherwise false.
  52344. * @param mesh The mesh to render
  52345. * @returns true if it should render otherwise false
  52346. */
  52347. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52348. /**
  52349. * Sets the required values for both the emissive texture and and the main color.
  52350. */
  52351. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52352. /**
  52353. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52354. * @param mesh The mesh to exclude from the highlight layer
  52355. */
  52356. addExcludedMesh(mesh: Mesh): void;
  52357. /**
  52358. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52359. * @param mesh The mesh to highlight
  52360. */
  52361. removeExcludedMesh(mesh: Mesh): void;
  52362. /**
  52363. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52364. * @param mesh mesh to test
  52365. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52366. */
  52367. hasMesh(mesh: AbstractMesh): boolean;
  52368. /**
  52369. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52370. * @param mesh The mesh to highlight
  52371. * @param color The color of the highlight
  52372. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52373. */
  52374. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52375. /**
  52376. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52377. * @param mesh The mesh to highlight
  52378. */
  52379. removeMesh(mesh: Mesh): void;
  52380. /**
  52381. * Force the stencil to the normal expected value for none glowing parts
  52382. */
  52383. private _defaultStencilReference;
  52384. /**
  52385. * Free any resources and references associated to a mesh.
  52386. * Internal use
  52387. * @param mesh The mesh to free.
  52388. * @hidden
  52389. */
  52390. _disposeMesh(mesh: Mesh): void;
  52391. /**
  52392. * Dispose the highlight layer and free resources.
  52393. */
  52394. dispose(): void;
  52395. /**
  52396. * Gets the class name of the effect layer
  52397. * @returns the string with the class name of the effect layer
  52398. */
  52399. getClassName(): string;
  52400. /**
  52401. * Serializes this Highlight layer
  52402. * @returns a serialized Highlight layer object
  52403. */
  52404. serialize(): any;
  52405. /**
  52406. * Creates a Highlight layer from parsed Highlight layer data
  52407. * @param parsedHightlightLayer defines the Highlight layer data
  52408. * @param scene defines the current scene
  52409. * @param rootUrl defines the root URL containing the Highlight layer information
  52410. * @returns a parsed Highlight layer
  52411. */
  52412. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. interface AbstractScene {
  52417. /**
  52418. * The list of layers (background and foreground) of the scene
  52419. */
  52420. layers: Array<Layer>;
  52421. }
  52422. /**
  52423. * Defines the layer scene component responsible to manage any layers
  52424. * in a given scene.
  52425. */
  52426. export class LayerSceneComponent implements ISceneComponent {
  52427. /**
  52428. * The component name helpfull to identify the component in the list of scene components.
  52429. */
  52430. readonly name: string;
  52431. /**
  52432. * The scene the component belongs to.
  52433. */
  52434. scene: Scene;
  52435. private _engine;
  52436. /**
  52437. * Creates a new instance of the component for the given scene
  52438. * @param scene Defines the scene to register the component in
  52439. */
  52440. constructor(scene: Scene);
  52441. /**
  52442. * Registers the component in a given scene
  52443. */
  52444. register(): void;
  52445. /**
  52446. * Rebuilds the elements related to this component in case of
  52447. * context lost for instance.
  52448. */
  52449. rebuild(): void;
  52450. /**
  52451. * Disposes the component and the associated ressources.
  52452. */
  52453. dispose(): void;
  52454. private _draw;
  52455. private _drawCameraPredicate;
  52456. private _drawCameraBackground;
  52457. private _drawCameraForeground;
  52458. private _drawRenderTargetPredicate;
  52459. private _drawRenderTargetBackground;
  52460. private _drawRenderTargetForeground;
  52461. /**
  52462. * Adds all the elements from the container to the scene
  52463. * @param container the container holding the elements
  52464. */
  52465. addFromContainer(container: AbstractScene): void;
  52466. /**
  52467. * Removes all the elements in the container from the scene
  52468. * @param container contains the elements to remove
  52469. * @param dispose if the removed element should be disposed (default: false)
  52470. */
  52471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /** @hidden */
  52476. export var layerPixelShader: {
  52477. name: string;
  52478. shader: string;
  52479. };
  52480. }
  52481. declare module BABYLON {
  52482. /** @hidden */
  52483. export var layerVertexShader: {
  52484. name: string;
  52485. shader: string;
  52486. };
  52487. }
  52488. declare module BABYLON {
  52489. /**
  52490. * This represents a full screen 2d layer.
  52491. * This can be useful to display a picture in the background of your scene for instance.
  52492. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52493. */
  52494. export class Layer {
  52495. /**
  52496. * Define the name of the layer.
  52497. */
  52498. name: string;
  52499. /**
  52500. * Define the texture the layer should display.
  52501. */
  52502. texture: Nullable<Texture>;
  52503. /**
  52504. * Is the layer in background or foreground.
  52505. */
  52506. isBackground: boolean;
  52507. /**
  52508. * Define the color of the layer (instead of texture).
  52509. */
  52510. color: Color4;
  52511. /**
  52512. * Define the scale of the layer in order to zoom in out of the texture.
  52513. */
  52514. scale: Vector2;
  52515. /**
  52516. * Define an offset for the layer in order to shift the texture.
  52517. */
  52518. offset: Vector2;
  52519. /**
  52520. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52521. */
  52522. alphaBlendingMode: number;
  52523. /**
  52524. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52525. * Alpha test will not mix with the background color in case of transparency.
  52526. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52527. */
  52528. alphaTest: boolean;
  52529. /**
  52530. * Define a mask to restrict the layer to only some of the scene cameras.
  52531. */
  52532. layerMask: number;
  52533. /**
  52534. * Define the list of render target the layer is visible into.
  52535. */
  52536. renderTargetTextures: RenderTargetTexture[];
  52537. /**
  52538. * Define if the layer is only used in renderTarget or if it also
  52539. * renders in the main frame buffer of the canvas.
  52540. */
  52541. renderOnlyInRenderTargetTextures: boolean;
  52542. private _scene;
  52543. private _vertexBuffers;
  52544. private _indexBuffer;
  52545. private _effect;
  52546. private _previousDefines;
  52547. /**
  52548. * An event triggered when the layer is disposed.
  52549. */
  52550. onDisposeObservable: Observable<Layer>;
  52551. private _onDisposeObserver;
  52552. /**
  52553. * Back compatibility with callback before the onDisposeObservable existed.
  52554. * The set callback will be triggered when the layer has been disposed.
  52555. */
  52556. set onDispose(callback: () => void);
  52557. /**
  52558. * An event triggered before rendering the scene
  52559. */
  52560. onBeforeRenderObservable: Observable<Layer>;
  52561. private _onBeforeRenderObserver;
  52562. /**
  52563. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52564. * The set callback will be triggered just before rendering the layer.
  52565. */
  52566. set onBeforeRender(callback: () => void);
  52567. /**
  52568. * An event triggered after rendering the scene
  52569. */
  52570. onAfterRenderObservable: Observable<Layer>;
  52571. private _onAfterRenderObserver;
  52572. /**
  52573. * Back compatibility with callback before the onAfterRenderObservable existed.
  52574. * The set callback will be triggered just after rendering the layer.
  52575. */
  52576. set onAfterRender(callback: () => void);
  52577. /**
  52578. * Instantiates a new layer.
  52579. * This represents a full screen 2d layer.
  52580. * This can be useful to display a picture in the background of your scene for instance.
  52581. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52582. * @param name Define the name of the layer in the scene
  52583. * @param imgUrl Define the url of the texture to display in the layer
  52584. * @param scene Define the scene the layer belongs to
  52585. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52586. * @param color Defines a color for the layer
  52587. */
  52588. constructor(
  52589. /**
  52590. * Define the name of the layer.
  52591. */
  52592. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52593. private _createIndexBuffer;
  52594. /** @hidden */
  52595. _rebuild(): void;
  52596. /**
  52597. * Renders the layer in the scene.
  52598. */
  52599. render(): void;
  52600. /**
  52601. * Disposes and releases the associated ressources.
  52602. */
  52603. dispose(): void;
  52604. }
  52605. }
  52606. declare module BABYLON {
  52607. /** @hidden */
  52608. export var lensFlarePixelShader: {
  52609. name: string;
  52610. shader: string;
  52611. };
  52612. }
  52613. declare module BABYLON {
  52614. /** @hidden */
  52615. export var lensFlareVertexShader: {
  52616. name: string;
  52617. shader: string;
  52618. };
  52619. }
  52620. declare module BABYLON {
  52621. /**
  52622. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52623. * It is usually composed of several `lensFlare`.
  52624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52625. */
  52626. export class LensFlareSystem {
  52627. /**
  52628. * Define the name of the lens flare system
  52629. */
  52630. name: string;
  52631. /**
  52632. * List of lens flares used in this system.
  52633. */
  52634. lensFlares: LensFlare[];
  52635. /**
  52636. * Define a limit from the border the lens flare can be visible.
  52637. */
  52638. borderLimit: number;
  52639. /**
  52640. * Define a viewport border we do not want to see the lens flare in.
  52641. */
  52642. viewportBorder: number;
  52643. /**
  52644. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52645. */
  52646. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52647. /**
  52648. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52649. */
  52650. layerMask: number;
  52651. /**
  52652. * Define the id of the lens flare system in the scene.
  52653. * (equal to name by default)
  52654. */
  52655. id: string;
  52656. private _scene;
  52657. private _emitter;
  52658. private _vertexBuffers;
  52659. private _indexBuffer;
  52660. private _effect;
  52661. private _positionX;
  52662. private _positionY;
  52663. private _isEnabled;
  52664. /** @hidden */
  52665. static _SceneComponentInitialization: (scene: Scene) => void;
  52666. /**
  52667. * Instantiates a lens flare system.
  52668. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52669. * It is usually composed of several `lensFlare`.
  52670. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52671. * @param name Define the name of the lens flare system in the scene
  52672. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52673. * @param scene Define the scene the lens flare system belongs to
  52674. */
  52675. constructor(
  52676. /**
  52677. * Define the name of the lens flare system
  52678. */
  52679. name: string, emitter: any, scene: Scene);
  52680. /**
  52681. * Define if the lens flare system is enabled.
  52682. */
  52683. get isEnabled(): boolean;
  52684. set isEnabled(value: boolean);
  52685. /**
  52686. * Get the scene the effects belongs to.
  52687. * @returns the scene holding the lens flare system
  52688. */
  52689. getScene(): Scene;
  52690. /**
  52691. * Get the emitter of the lens flare system.
  52692. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52693. * @returns the emitter of the lens flare system
  52694. */
  52695. getEmitter(): any;
  52696. /**
  52697. * Set the emitter of the lens flare system.
  52698. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52699. * @param newEmitter Define the new emitter of the system
  52700. */
  52701. setEmitter(newEmitter: any): void;
  52702. /**
  52703. * Get the lens flare system emitter position.
  52704. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52705. * @returns the position
  52706. */
  52707. getEmitterPosition(): Vector3;
  52708. /**
  52709. * @hidden
  52710. */
  52711. computeEffectivePosition(globalViewport: Viewport): boolean;
  52712. /** @hidden */
  52713. _isVisible(): boolean;
  52714. /**
  52715. * @hidden
  52716. */
  52717. render(): boolean;
  52718. /**
  52719. * Dispose and release the lens flare with its associated resources.
  52720. */
  52721. dispose(): void;
  52722. /**
  52723. * Parse a lens flare system from a JSON repressentation
  52724. * @param parsedLensFlareSystem Define the JSON to parse
  52725. * @param scene Define the scene the parsed system should be instantiated in
  52726. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52727. * @returns the parsed system
  52728. */
  52729. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52730. /**
  52731. * Serialize the current Lens Flare System into a JSON representation.
  52732. * @returns the serialized JSON
  52733. */
  52734. serialize(): any;
  52735. }
  52736. }
  52737. declare module BABYLON {
  52738. /**
  52739. * This represents one of the lens effect in a `lensFlareSystem`.
  52740. * It controls one of the indiviual texture used in the effect.
  52741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52742. */
  52743. export class LensFlare {
  52744. /**
  52745. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52746. */
  52747. size: number;
  52748. /**
  52749. * 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.
  52750. */
  52751. position: number;
  52752. /**
  52753. * Define the lens color.
  52754. */
  52755. color: Color3;
  52756. /**
  52757. * Define the lens texture.
  52758. */
  52759. texture: Nullable<Texture>;
  52760. /**
  52761. * Define the alpha mode to render this particular lens.
  52762. */
  52763. alphaMode: number;
  52764. private _system;
  52765. /**
  52766. * Creates a new Lens Flare.
  52767. * This represents one of the lens effect in a `lensFlareSystem`.
  52768. * It controls one of the indiviual texture used in the effect.
  52769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52770. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52771. * @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.
  52772. * @param color Define the lens color
  52773. * @param imgUrl Define the lens texture url
  52774. * @param system Define the `lensFlareSystem` this flare is part of
  52775. * @returns The newly created Lens Flare
  52776. */
  52777. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52778. /**
  52779. * Instantiates a new Lens Flare.
  52780. * This represents one of the lens effect in a `lensFlareSystem`.
  52781. * It controls one of the indiviual texture used in the effect.
  52782. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52783. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52784. * @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.
  52785. * @param color Define the lens color
  52786. * @param imgUrl Define the lens texture url
  52787. * @param system Define the `lensFlareSystem` this flare is part of
  52788. */
  52789. constructor(
  52790. /**
  52791. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52792. */
  52793. size: number,
  52794. /**
  52795. * 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.
  52796. */
  52797. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52798. /**
  52799. * Dispose and release the lens flare with its associated resources.
  52800. */
  52801. dispose(): void;
  52802. }
  52803. }
  52804. declare module BABYLON {
  52805. interface AbstractScene {
  52806. /**
  52807. * The list of lens flare system added to the scene
  52808. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52809. */
  52810. lensFlareSystems: Array<LensFlareSystem>;
  52811. /**
  52812. * Removes the given lens flare system from this scene.
  52813. * @param toRemove The lens flare system to remove
  52814. * @returns The index of the removed lens flare system
  52815. */
  52816. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52817. /**
  52818. * Adds the given lens flare system to this scene
  52819. * @param newLensFlareSystem The lens flare system to add
  52820. */
  52821. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52822. /**
  52823. * Gets a lens flare system using its name
  52824. * @param name defines the name to look for
  52825. * @returns the lens flare system or null if not found
  52826. */
  52827. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52828. /**
  52829. * Gets a lens flare system using its id
  52830. * @param id defines the id to look for
  52831. * @returns the lens flare system or null if not found
  52832. */
  52833. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52834. }
  52835. /**
  52836. * Defines the lens flare scene component responsible to manage any lens flares
  52837. * in a given scene.
  52838. */
  52839. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52840. /**
  52841. * The component name helpfull to identify the component in the list of scene components.
  52842. */
  52843. readonly name: string;
  52844. /**
  52845. * The scene the component belongs to.
  52846. */
  52847. scene: Scene;
  52848. /**
  52849. * Creates a new instance of the component for the given scene
  52850. * @param scene Defines the scene to register the component in
  52851. */
  52852. constructor(scene: Scene);
  52853. /**
  52854. * Registers the component in a given scene
  52855. */
  52856. register(): void;
  52857. /**
  52858. * Rebuilds the elements related to this component in case of
  52859. * context lost for instance.
  52860. */
  52861. rebuild(): void;
  52862. /**
  52863. * Adds all the elements from the container to the scene
  52864. * @param container the container holding the elements
  52865. */
  52866. addFromContainer(container: AbstractScene): void;
  52867. /**
  52868. * Removes all the elements in the container from the scene
  52869. * @param container contains the elements to remove
  52870. * @param dispose if the removed element should be disposed (default: false)
  52871. */
  52872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52873. /**
  52874. * Serializes the component data to the specified json object
  52875. * @param serializationObject The object to serialize to
  52876. */
  52877. serialize(serializationObject: any): void;
  52878. /**
  52879. * Disposes the component and the associated ressources.
  52880. */
  52881. dispose(): void;
  52882. private _draw;
  52883. }
  52884. }
  52885. declare module BABYLON {
  52886. /**
  52887. * Defines the shadow generator component responsible to manage any shadow generators
  52888. * in a given scene.
  52889. */
  52890. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52891. /**
  52892. * The component name helpfull to identify the component in the list of scene components.
  52893. */
  52894. readonly name: string;
  52895. /**
  52896. * The scene the component belongs to.
  52897. */
  52898. scene: Scene;
  52899. /**
  52900. * Creates a new instance of the component for the given scene
  52901. * @param scene Defines the scene to register the component in
  52902. */
  52903. constructor(scene: Scene);
  52904. /**
  52905. * Registers the component in a given scene
  52906. */
  52907. register(): void;
  52908. /**
  52909. * Rebuilds the elements related to this component in case of
  52910. * context lost for instance.
  52911. */
  52912. rebuild(): void;
  52913. /**
  52914. * Serializes the component data to the specified json object
  52915. * @param serializationObject The object to serialize to
  52916. */
  52917. serialize(serializationObject: any): void;
  52918. /**
  52919. * Adds all the elements from the container to the scene
  52920. * @param container the container holding the elements
  52921. */
  52922. addFromContainer(container: AbstractScene): void;
  52923. /**
  52924. * Removes all the elements in the container from the scene
  52925. * @param container contains the elements to remove
  52926. * @param dispose if the removed element should be disposed (default: false)
  52927. */
  52928. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52929. /**
  52930. * Rebuilds the elements related to this component in case of
  52931. * context lost for instance.
  52932. */
  52933. dispose(): void;
  52934. private _gatherRenderTargets;
  52935. }
  52936. }
  52937. declare module BABYLON {
  52938. /**
  52939. * A point light is a light defined by an unique point in world space.
  52940. * The light is emitted in every direction from this point.
  52941. * A good example of a point light is a standard light bulb.
  52942. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52943. */
  52944. export class PointLight extends ShadowLight {
  52945. private _shadowAngle;
  52946. /**
  52947. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52948. * This specifies what angle the shadow will use to be created.
  52949. *
  52950. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52951. */
  52952. get shadowAngle(): number;
  52953. /**
  52954. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52955. * This specifies what angle the shadow will use to be created.
  52956. *
  52957. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52958. */
  52959. set shadowAngle(value: number);
  52960. /**
  52961. * Gets the direction if it has been set.
  52962. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52963. */
  52964. get direction(): Vector3;
  52965. /**
  52966. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52967. */
  52968. set direction(value: Vector3);
  52969. /**
  52970. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52971. * A PointLight emits the light in every direction.
  52972. * It can cast shadows.
  52973. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52974. * ```javascript
  52975. * var pointLight = new PointLight("pl", camera.position, scene);
  52976. * ```
  52977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52978. * @param name The light friendly name
  52979. * @param position The position of the point light in the scene
  52980. * @param scene The scene the lights belongs to
  52981. */
  52982. constructor(name: string, position: Vector3, scene: Scene);
  52983. /**
  52984. * Returns the string "PointLight"
  52985. * @returns the class name
  52986. */
  52987. getClassName(): string;
  52988. /**
  52989. * Returns the integer 0.
  52990. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52991. */
  52992. getTypeID(): number;
  52993. /**
  52994. * Specifies wether or not the shadowmap should be a cube texture.
  52995. * @returns true if the shadowmap needs to be a cube texture.
  52996. */
  52997. needCube(): boolean;
  52998. /**
  52999. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53000. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53001. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53002. */
  53003. getShadowDirection(faceIndex?: number): Vector3;
  53004. /**
  53005. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53006. * - fov = PI / 2
  53007. * - aspect ratio : 1.0
  53008. * - z-near and far equal to the active camera minZ and maxZ.
  53009. * Returns the PointLight.
  53010. */
  53011. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53012. protected _buildUniformLayout(): void;
  53013. /**
  53014. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53015. * @param effect The effect to update
  53016. * @param lightIndex The index of the light in the effect to update
  53017. * @returns The point light
  53018. */
  53019. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53021. /**
  53022. * Prepares the list of defines specific to the light type.
  53023. * @param defines the list of defines
  53024. * @param lightIndex defines the index of the light for the effect
  53025. */
  53026. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53027. }
  53028. }
  53029. declare module BABYLON {
  53030. /**
  53031. * Header information of HDR texture files.
  53032. */
  53033. export interface HDRInfo {
  53034. /**
  53035. * The height of the texture in pixels.
  53036. */
  53037. height: number;
  53038. /**
  53039. * The width of the texture in pixels.
  53040. */
  53041. width: number;
  53042. /**
  53043. * The index of the beginning of the data in the binary file.
  53044. */
  53045. dataPosition: number;
  53046. }
  53047. /**
  53048. * This groups tools to convert HDR texture to native colors array.
  53049. */
  53050. export class HDRTools {
  53051. private static Ldexp;
  53052. private static Rgbe2float;
  53053. private static readStringLine;
  53054. /**
  53055. * Reads header information from an RGBE texture stored in a native array.
  53056. * More information on this format are available here:
  53057. * https://en.wikipedia.org/wiki/RGBE_image_format
  53058. *
  53059. * @param uint8array The binary file stored in native array.
  53060. * @return The header information.
  53061. */
  53062. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53063. /**
  53064. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53065. * This RGBE texture needs to store the information as a panorama.
  53066. *
  53067. * More information on this format are available here:
  53068. * https://en.wikipedia.org/wiki/RGBE_image_format
  53069. *
  53070. * @param buffer The binary file stored in an array buffer.
  53071. * @param size The expected size of the extracted cubemap.
  53072. * @return The Cube Map information.
  53073. */
  53074. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53075. /**
  53076. * Returns the pixels data extracted from an RGBE texture.
  53077. * This pixels will be stored left to right up to down in the R G B order in one array.
  53078. *
  53079. * More information on this format are available here:
  53080. * https://en.wikipedia.org/wiki/RGBE_image_format
  53081. *
  53082. * @param uint8array The binary file stored in an array buffer.
  53083. * @param hdrInfo The header information of the file.
  53084. * @return The pixels data in RGB right to left up to down order.
  53085. */
  53086. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53087. private static RGBE_ReadPixels_RLE;
  53088. }
  53089. }
  53090. declare module BABYLON {
  53091. /**
  53092. * This represents a texture coming from an HDR input.
  53093. *
  53094. * The only supported format is currently panorama picture stored in RGBE format.
  53095. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53096. */
  53097. export class HDRCubeTexture extends BaseTexture {
  53098. private static _facesMapping;
  53099. private _generateHarmonics;
  53100. private _noMipmap;
  53101. private _textureMatrix;
  53102. private _size;
  53103. private _onLoad;
  53104. private _onError;
  53105. /**
  53106. * The texture URL.
  53107. */
  53108. url: string;
  53109. /**
  53110. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53111. */
  53112. coordinatesMode: number;
  53113. protected _isBlocking: boolean;
  53114. /**
  53115. * Sets wether or not the texture is blocking during loading.
  53116. */
  53117. set isBlocking(value: boolean);
  53118. /**
  53119. * Gets wether or not the texture is blocking during loading.
  53120. */
  53121. get isBlocking(): boolean;
  53122. protected _rotationY: number;
  53123. /**
  53124. * Sets texture matrix rotation angle around Y axis in radians.
  53125. */
  53126. set rotationY(value: number);
  53127. /**
  53128. * Gets texture matrix rotation angle around Y axis radians.
  53129. */
  53130. get rotationY(): number;
  53131. /**
  53132. * Gets or sets the center of the bounding box associated with the cube texture
  53133. * It must define where the camera used to render the texture was set
  53134. */
  53135. boundingBoxPosition: Vector3;
  53136. private _boundingBoxSize;
  53137. /**
  53138. * Gets or sets the size of the bounding box associated with the cube texture
  53139. * When defined, the cubemap will switch to local mode
  53140. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53141. * @example https://www.babylonjs-playground.com/#RNASML
  53142. */
  53143. set boundingBoxSize(value: Vector3);
  53144. get boundingBoxSize(): Vector3;
  53145. /**
  53146. * Instantiates an HDRTexture from the following parameters.
  53147. *
  53148. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53149. * @param scene The scene the texture will be used in
  53150. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53151. * @param noMipmap Forces to not generate the mipmap if true
  53152. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53153. * @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)
  53154. * @param reserved Reserved flag for internal use.
  53155. */
  53156. 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>);
  53157. /**
  53158. * Get the current class name of the texture useful for serialization or dynamic coding.
  53159. * @returns "HDRCubeTexture"
  53160. */
  53161. getClassName(): string;
  53162. /**
  53163. * Occurs when the file is raw .hdr file.
  53164. */
  53165. private loadTexture;
  53166. clone(): HDRCubeTexture;
  53167. delayLoad(): void;
  53168. /**
  53169. * Get the texture reflection matrix used to rotate/transform the reflection.
  53170. * @returns the reflection matrix
  53171. */
  53172. getReflectionTextureMatrix(): Matrix;
  53173. /**
  53174. * Set the texture reflection matrix used to rotate/transform the reflection.
  53175. * @param value Define the reflection matrix to set
  53176. */
  53177. setReflectionTextureMatrix(value: Matrix): void;
  53178. /**
  53179. * Parses a JSON representation of an HDR Texture in order to create the texture
  53180. * @param parsedTexture Define the JSON representation
  53181. * @param scene Define the scene the texture should be created in
  53182. * @param rootUrl Define the root url in case we need to load relative dependencies
  53183. * @returns the newly created texture after parsing
  53184. */
  53185. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53186. serialize(): any;
  53187. }
  53188. }
  53189. declare module BABYLON {
  53190. /**
  53191. * Class used to control physics engine
  53192. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53193. */
  53194. export class PhysicsEngine implements IPhysicsEngine {
  53195. private _physicsPlugin;
  53196. /**
  53197. * Global value used to control the smallest number supported by the simulation
  53198. */
  53199. static Epsilon: number;
  53200. private _impostors;
  53201. private _joints;
  53202. private _subTimeStep;
  53203. /**
  53204. * Gets the gravity vector used by the simulation
  53205. */
  53206. gravity: Vector3;
  53207. /**
  53208. * Factory used to create the default physics plugin.
  53209. * @returns The default physics plugin
  53210. */
  53211. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53212. /**
  53213. * Creates a new Physics Engine
  53214. * @param gravity defines the gravity vector used by the simulation
  53215. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53216. */
  53217. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53218. /**
  53219. * Sets the gravity vector used by the simulation
  53220. * @param gravity defines the gravity vector to use
  53221. */
  53222. setGravity(gravity: Vector3): void;
  53223. /**
  53224. * Set the time step of the physics engine.
  53225. * Default is 1/60.
  53226. * To slow it down, enter 1/600 for example.
  53227. * To speed it up, 1/30
  53228. * @param newTimeStep defines the new timestep to apply to this world.
  53229. */
  53230. setTimeStep(newTimeStep?: number): void;
  53231. /**
  53232. * Get the time step of the physics engine.
  53233. * @returns the current time step
  53234. */
  53235. getTimeStep(): number;
  53236. /**
  53237. * Set the sub time step of the physics engine.
  53238. * Default is 0 meaning there is no sub steps
  53239. * To increase physics resolution precision, set a small value (like 1 ms)
  53240. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53241. */
  53242. setSubTimeStep(subTimeStep?: number): void;
  53243. /**
  53244. * Get the sub time step of the physics engine.
  53245. * @returns the current sub time step
  53246. */
  53247. getSubTimeStep(): number;
  53248. /**
  53249. * Release all resources
  53250. */
  53251. dispose(): void;
  53252. /**
  53253. * Gets the name of the current physics plugin
  53254. * @returns the name of the plugin
  53255. */
  53256. getPhysicsPluginName(): string;
  53257. /**
  53258. * Adding a new impostor for the impostor tracking.
  53259. * This will be done by the impostor itself.
  53260. * @param impostor the impostor to add
  53261. */
  53262. addImpostor(impostor: PhysicsImpostor): void;
  53263. /**
  53264. * Remove an impostor from the engine.
  53265. * This impostor and its mesh will not longer be updated by the physics engine.
  53266. * @param impostor the impostor to remove
  53267. */
  53268. removeImpostor(impostor: PhysicsImpostor): void;
  53269. /**
  53270. * Add a joint to the physics engine
  53271. * @param mainImpostor defines the main impostor to which the joint is added.
  53272. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53273. * @param joint defines the joint that will connect both impostors.
  53274. */
  53275. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53276. /**
  53277. * Removes a joint from the simulation
  53278. * @param mainImpostor defines the impostor used with the joint
  53279. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53280. * @param joint defines the joint to remove
  53281. */
  53282. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53283. /**
  53284. * Called by the scene. No need to call it.
  53285. * @param delta defines the timespam between frames
  53286. */
  53287. _step(delta: number): void;
  53288. /**
  53289. * Gets the current plugin used to run the simulation
  53290. * @returns current plugin
  53291. */
  53292. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53293. /**
  53294. * Gets the list of physic impostors
  53295. * @returns an array of PhysicsImpostor
  53296. */
  53297. getImpostors(): Array<PhysicsImpostor>;
  53298. /**
  53299. * Gets the impostor for a physics enabled object
  53300. * @param object defines the object impersonated by the impostor
  53301. * @returns the PhysicsImpostor or null if not found
  53302. */
  53303. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53304. /**
  53305. * Gets the impostor for a physics body object
  53306. * @param body defines physics body used by the impostor
  53307. * @returns the PhysicsImpostor or null if not found
  53308. */
  53309. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53310. /**
  53311. * Does a raycast in the physics world
  53312. * @param from when should the ray start?
  53313. * @param to when should the ray end?
  53314. * @returns PhysicsRaycastResult
  53315. */
  53316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /** @hidden */
  53321. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53322. private _useDeltaForWorldStep;
  53323. world: any;
  53324. name: string;
  53325. private _physicsMaterials;
  53326. private _fixedTimeStep;
  53327. private _cannonRaycastResult;
  53328. private _raycastResult;
  53329. private _physicsBodysToRemoveAfterStep;
  53330. BJSCANNON: any;
  53331. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53332. setGravity(gravity: Vector3): void;
  53333. setTimeStep(timeStep: number): void;
  53334. getTimeStep(): number;
  53335. executeStep(delta: number): void;
  53336. private _removeMarkedPhysicsBodiesFromWorld;
  53337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53340. private _processChildMeshes;
  53341. removePhysicsBody(impostor: PhysicsImpostor): void;
  53342. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53343. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53344. private _addMaterial;
  53345. private _checkWithEpsilon;
  53346. private _createShape;
  53347. private _createHeightmap;
  53348. private _minus90X;
  53349. private _plus90X;
  53350. private _tmpPosition;
  53351. private _tmpDeltaPosition;
  53352. private _tmpUnityRotation;
  53353. private _updatePhysicsBodyTransformation;
  53354. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53356. isSupported(): boolean;
  53357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53362. getBodyMass(impostor: PhysicsImpostor): number;
  53363. getBodyFriction(impostor: PhysicsImpostor): number;
  53364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53365. getBodyRestitution(impostor: PhysicsImpostor): number;
  53366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53367. sleepBody(impostor: PhysicsImpostor): void;
  53368. wakeUpBody(impostor: PhysicsImpostor): void;
  53369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53370. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53372. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53373. getRadius(impostor: PhysicsImpostor): number;
  53374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53375. dispose(): void;
  53376. private _extendNamespace;
  53377. /**
  53378. * Does a raycast in the physics world
  53379. * @param from when should the ray start?
  53380. * @param to when should the ray end?
  53381. * @returns PhysicsRaycastResult
  53382. */
  53383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53384. }
  53385. }
  53386. declare module BABYLON {
  53387. /** @hidden */
  53388. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53389. world: any;
  53390. name: string;
  53391. BJSOIMO: any;
  53392. private _raycastResult;
  53393. constructor(iterations?: number, oimoInjection?: any);
  53394. setGravity(gravity: Vector3): void;
  53395. setTimeStep(timeStep: number): void;
  53396. getTimeStep(): number;
  53397. private _tmpImpostorsArray;
  53398. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53399. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53400. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53401. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53402. private _tmpPositionVector;
  53403. removePhysicsBody(impostor: PhysicsImpostor): void;
  53404. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53405. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53406. isSupported(): boolean;
  53407. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53408. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53411. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53414. getBodyMass(impostor: PhysicsImpostor): number;
  53415. getBodyFriction(impostor: PhysicsImpostor): number;
  53416. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53417. getBodyRestitution(impostor: PhysicsImpostor): number;
  53418. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53419. sleepBody(impostor: PhysicsImpostor): void;
  53420. wakeUpBody(impostor: PhysicsImpostor): void;
  53421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53422. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53425. getRadius(impostor: PhysicsImpostor): number;
  53426. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53427. dispose(): void;
  53428. /**
  53429. * Does a raycast in the physics world
  53430. * @param from when should the ray start?
  53431. * @param to when should the ray end?
  53432. * @returns PhysicsRaycastResult
  53433. */
  53434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53435. }
  53436. }
  53437. declare module BABYLON {
  53438. /**
  53439. * Class containing static functions to help procedurally build meshes
  53440. */
  53441. export class RibbonBuilder {
  53442. /**
  53443. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53444. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53445. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53446. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53447. * * 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
  53448. * * 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
  53449. * * 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
  53450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53451. * * 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
  53452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53453. * * 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
  53454. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53455. * * 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
  53456. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53458. * @param name defines the name of the mesh
  53459. * @param options defines the options used to create the mesh
  53460. * @param scene defines the hosting scene
  53461. * @returns the ribbon mesh
  53462. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53464. */
  53465. static CreateRibbon(name: string, options: {
  53466. pathArray: Vector3[][];
  53467. closeArray?: boolean;
  53468. closePath?: boolean;
  53469. offset?: number;
  53470. updatable?: boolean;
  53471. sideOrientation?: number;
  53472. frontUVs?: Vector4;
  53473. backUVs?: Vector4;
  53474. instance?: Mesh;
  53475. invertUV?: boolean;
  53476. uvs?: Vector2[];
  53477. colors?: Color4[];
  53478. }, scene?: Nullable<Scene>): Mesh;
  53479. }
  53480. }
  53481. declare module BABYLON {
  53482. /**
  53483. * Class containing static functions to help procedurally build meshes
  53484. */
  53485. export class ShapeBuilder {
  53486. /**
  53487. * 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.
  53488. * * 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.
  53489. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53490. * * 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.
  53491. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53492. * * 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
  53493. * * 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
  53494. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53496. * * 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
  53497. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53499. * @param name defines the name of the mesh
  53500. * @param options defines the options used to create the mesh
  53501. * @param scene defines the hosting scene
  53502. * @returns the extruded shape mesh
  53503. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53505. */
  53506. static ExtrudeShape(name: string, options: {
  53507. shape: Vector3[];
  53508. path: Vector3[];
  53509. scale?: number;
  53510. rotation?: number;
  53511. cap?: number;
  53512. updatable?: boolean;
  53513. sideOrientation?: number;
  53514. frontUVs?: Vector4;
  53515. backUVs?: Vector4;
  53516. instance?: Mesh;
  53517. invertUV?: boolean;
  53518. }, scene?: Nullable<Scene>): Mesh;
  53519. /**
  53520. * Creates an custom extruded shape mesh.
  53521. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53522. * * 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.
  53523. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53524. * * 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
  53525. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53526. * * 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
  53527. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53528. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53529. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53530. * * 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
  53531. * * 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
  53532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53534. * * 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
  53535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53537. * @param name defines the name of the mesh
  53538. * @param options defines the options used to create the mesh
  53539. * @param scene defines the hosting scene
  53540. * @returns the custom extruded shape mesh
  53541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53542. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53544. */
  53545. static ExtrudeShapeCustom(name: string, options: {
  53546. shape: Vector3[];
  53547. path: Vector3[];
  53548. scaleFunction?: any;
  53549. rotationFunction?: any;
  53550. ribbonCloseArray?: boolean;
  53551. ribbonClosePath?: boolean;
  53552. cap?: number;
  53553. updatable?: boolean;
  53554. sideOrientation?: number;
  53555. frontUVs?: Vector4;
  53556. backUVs?: Vector4;
  53557. instance?: Mesh;
  53558. invertUV?: boolean;
  53559. }, scene?: Nullable<Scene>): Mesh;
  53560. private static _ExtrudeShapeGeneric;
  53561. }
  53562. }
  53563. declare module BABYLON {
  53564. /**
  53565. * AmmoJS Physics plugin
  53566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53567. * @see https://github.com/kripken/ammo.js/
  53568. */
  53569. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53570. private _useDeltaForWorldStep;
  53571. /**
  53572. * Reference to the Ammo library
  53573. */
  53574. bjsAMMO: any;
  53575. /**
  53576. * Created ammoJS world which physics bodies are added to
  53577. */
  53578. world: any;
  53579. /**
  53580. * Name of the plugin
  53581. */
  53582. name: string;
  53583. private _timeStep;
  53584. private _fixedTimeStep;
  53585. private _maxSteps;
  53586. private _tmpQuaternion;
  53587. private _tmpAmmoTransform;
  53588. private _tmpAmmoQuaternion;
  53589. private _tmpAmmoConcreteContactResultCallback;
  53590. private _collisionConfiguration;
  53591. private _dispatcher;
  53592. private _overlappingPairCache;
  53593. private _solver;
  53594. private _softBodySolver;
  53595. private _tmpAmmoVectorA;
  53596. private _tmpAmmoVectorB;
  53597. private _tmpAmmoVectorC;
  53598. private _tmpAmmoVectorD;
  53599. private _tmpContactCallbackResult;
  53600. private _tmpAmmoVectorRCA;
  53601. private _tmpAmmoVectorRCB;
  53602. private _raycastResult;
  53603. private static readonly DISABLE_COLLISION_FLAG;
  53604. private static readonly KINEMATIC_FLAG;
  53605. private static readonly DISABLE_DEACTIVATION_FLAG;
  53606. /**
  53607. * Initializes the ammoJS plugin
  53608. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53609. * @param ammoInjection can be used to inject your own ammo reference
  53610. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53611. */
  53612. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53613. /**
  53614. * Sets the gravity of the physics world (m/(s^2))
  53615. * @param gravity Gravity to set
  53616. */
  53617. setGravity(gravity: Vector3): void;
  53618. /**
  53619. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53620. * @param timeStep timestep to use in seconds
  53621. */
  53622. setTimeStep(timeStep: number): void;
  53623. /**
  53624. * 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)
  53625. * @param fixedTimeStep fixedTimeStep to use in seconds
  53626. */
  53627. setFixedTimeStep(fixedTimeStep: number): void;
  53628. /**
  53629. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53630. * @param maxSteps the maximum number of steps by the physics engine per frame
  53631. */
  53632. setMaxSteps(maxSteps: number): void;
  53633. /**
  53634. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53635. * @returns the current timestep in seconds
  53636. */
  53637. getTimeStep(): number;
  53638. /**
  53639. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53640. */
  53641. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53642. private _isImpostorInContact;
  53643. private _isImpostorPairInContact;
  53644. private _stepSimulation;
  53645. /**
  53646. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53647. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53648. * After the step the babylon meshes are set to the position of the physics imposters
  53649. * @param delta amount of time to step forward
  53650. * @param impostors array of imposters to update before/after the step
  53651. */
  53652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53653. /**
  53654. * Update babylon mesh to match physics world object
  53655. * @param impostor imposter to match
  53656. */
  53657. private _afterSoftStep;
  53658. /**
  53659. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53660. * @param impostor imposter to match
  53661. */
  53662. private _ropeStep;
  53663. /**
  53664. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53665. * @param impostor imposter to match
  53666. */
  53667. private _softbodyOrClothStep;
  53668. private _tmpVector;
  53669. private _tmpMatrix;
  53670. /**
  53671. * Applies an impulse on the imposter
  53672. * @param impostor imposter to apply impulse to
  53673. * @param force amount of force to be applied to the imposter
  53674. * @param contactPoint the location to apply the impulse on the imposter
  53675. */
  53676. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53677. /**
  53678. * Applies a force on the imposter
  53679. * @param impostor imposter to apply force
  53680. * @param force amount of force to be applied to the imposter
  53681. * @param contactPoint the location to apply the force on the imposter
  53682. */
  53683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53684. /**
  53685. * Creates a physics body using the plugin
  53686. * @param impostor the imposter to create the physics body on
  53687. */
  53688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53689. /**
  53690. * Removes the physics body from the imposter and disposes of the body's memory
  53691. * @param impostor imposter to remove the physics body from
  53692. */
  53693. removePhysicsBody(impostor: PhysicsImpostor): void;
  53694. /**
  53695. * Generates a joint
  53696. * @param impostorJoint the imposter joint to create the joint with
  53697. */
  53698. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53699. /**
  53700. * Removes a joint
  53701. * @param impostorJoint the imposter joint to remove the joint from
  53702. */
  53703. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53704. private _addMeshVerts;
  53705. /**
  53706. * Initialise the soft body vertices to match its object's (mesh) vertices
  53707. * Softbody vertices (nodes) are in world space and to match this
  53708. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53709. * @param impostor to create the softbody for
  53710. */
  53711. private _softVertexData;
  53712. /**
  53713. * Create an impostor's soft body
  53714. * @param impostor to create the softbody for
  53715. */
  53716. private _createSoftbody;
  53717. /**
  53718. * Create cloth for an impostor
  53719. * @param impostor to create the softbody for
  53720. */
  53721. private _createCloth;
  53722. /**
  53723. * Create rope for an impostor
  53724. * @param impostor to create the softbody for
  53725. */
  53726. private _createRope;
  53727. /**
  53728. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53729. * @param impostor to create the custom physics shape for
  53730. */
  53731. private _createCustom;
  53732. private _addHullVerts;
  53733. private _createShape;
  53734. /**
  53735. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53736. * @param impostor imposter containing the physics body and babylon object
  53737. */
  53738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53739. /**
  53740. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53741. * @param impostor imposter containing the physics body and babylon object
  53742. * @param newPosition new position
  53743. * @param newRotation new rotation
  53744. */
  53745. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53746. /**
  53747. * If this plugin is supported
  53748. * @returns true if its supported
  53749. */
  53750. isSupported(): boolean;
  53751. /**
  53752. * Sets the linear velocity of the physics body
  53753. * @param impostor imposter to set the velocity on
  53754. * @param velocity velocity to set
  53755. */
  53756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53757. /**
  53758. * Sets the angular velocity of the physics body
  53759. * @param impostor imposter to set the velocity on
  53760. * @param velocity velocity to set
  53761. */
  53762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53763. /**
  53764. * gets the linear velocity
  53765. * @param impostor imposter to get linear velocity from
  53766. * @returns linear velocity
  53767. */
  53768. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53769. /**
  53770. * gets the angular velocity
  53771. * @param impostor imposter to get angular velocity from
  53772. * @returns angular velocity
  53773. */
  53774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53775. /**
  53776. * Sets the mass of physics body
  53777. * @param impostor imposter to set the mass on
  53778. * @param mass mass to set
  53779. */
  53780. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53781. /**
  53782. * Gets the mass of the physics body
  53783. * @param impostor imposter to get the mass from
  53784. * @returns mass
  53785. */
  53786. getBodyMass(impostor: PhysicsImpostor): number;
  53787. /**
  53788. * Gets friction of the impostor
  53789. * @param impostor impostor to get friction from
  53790. * @returns friction value
  53791. */
  53792. getBodyFriction(impostor: PhysicsImpostor): number;
  53793. /**
  53794. * Sets friction of the impostor
  53795. * @param impostor impostor to set friction on
  53796. * @param friction friction value
  53797. */
  53798. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53799. /**
  53800. * Gets restitution of the impostor
  53801. * @param impostor impostor to get restitution from
  53802. * @returns restitution value
  53803. */
  53804. getBodyRestitution(impostor: PhysicsImpostor): number;
  53805. /**
  53806. * Sets resitution of the impostor
  53807. * @param impostor impostor to set resitution on
  53808. * @param restitution resitution value
  53809. */
  53810. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53811. /**
  53812. * Gets pressure inside the impostor
  53813. * @param impostor impostor to get pressure from
  53814. * @returns pressure value
  53815. */
  53816. getBodyPressure(impostor: PhysicsImpostor): number;
  53817. /**
  53818. * Sets pressure inside a soft body impostor
  53819. * Cloth and rope must remain 0 pressure
  53820. * @param impostor impostor to set pressure on
  53821. * @param pressure pressure value
  53822. */
  53823. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53824. /**
  53825. * Gets stiffness of the impostor
  53826. * @param impostor impostor to get stiffness from
  53827. * @returns pressure value
  53828. */
  53829. getBodyStiffness(impostor: PhysicsImpostor): number;
  53830. /**
  53831. * Sets stiffness of the impostor
  53832. * @param impostor impostor to set stiffness on
  53833. * @param stiffness stiffness value from 0 to 1
  53834. */
  53835. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53836. /**
  53837. * Gets velocityIterations of the impostor
  53838. * @param impostor impostor to get velocity iterations from
  53839. * @returns velocityIterations value
  53840. */
  53841. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53842. /**
  53843. * Sets velocityIterations of the impostor
  53844. * @param impostor impostor to set velocity iterations on
  53845. * @param velocityIterations velocityIterations value
  53846. */
  53847. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53848. /**
  53849. * Gets positionIterations of the impostor
  53850. * @param impostor impostor to get position iterations from
  53851. * @returns positionIterations value
  53852. */
  53853. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53854. /**
  53855. * Sets positionIterations of the impostor
  53856. * @param impostor impostor to set position on
  53857. * @param positionIterations positionIterations value
  53858. */
  53859. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53860. /**
  53861. * Append an anchor to a cloth object
  53862. * @param impostor is the cloth impostor to add anchor to
  53863. * @param otherImpostor is the rigid impostor to anchor to
  53864. * @param width ratio across width from 0 to 1
  53865. * @param height ratio up height from 0 to 1
  53866. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53867. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53868. */
  53869. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53870. /**
  53871. * Append an hook to a rope object
  53872. * @param impostor is the rope impostor to add hook to
  53873. * @param otherImpostor is the rigid impostor to hook to
  53874. * @param length ratio along the rope from 0 to 1
  53875. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53876. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53877. */
  53878. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53879. /**
  53880. * Sleeps the physics body and stops it from being active
  53881. * @param impostor impostor to sleep
  53882. */
  53883. sleepBody(impostor: PhysicsImpostor): void;
  53884. /**
  53885. * Activates the physics body
  53886. * @param impostor impostor to activate
  53887. */
  53888. wakeUpBody(impostor: PhysicsImpostor): void;
  53889. /**
  53890. * Updates the distance parameters of the joint
  53891. * @param joint joint to update
  53892. * @param maxDistance maximum distance of the joint
  53893. * @param minDistance minimum distance of the joint
  53894. */
  53895. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53896. /**
  53897. * Sets a motor on the joint
  53898. * @param joint joint to set motor on
  53899. * @param speed speed of the motor
  53900. * @param maxForce maximum force of the motor
  53901. * @param motorIndex index of the motor
  53902. */
  53903. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53904. /**
  53905. * Sets the motors limit
  53906. * @param joint joint to set limit on
  53907. * @param upperLimit upper limit
  53908. * @param lowerLimit lower limit
  53909. */
  53910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53911. /**
  53912. * Syncs the position and rotation of a mesh with the impostor
  53913. * @param mesh mesh to sync
  53914. * @param impostor impostor to update the mesh with
  53915. */
  53916. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53917. /**
  53918. * Gets the radius of the impostor
  53919. * @param impostor impostor to get radius from
  53920. * @returns the radius
  53921. */
  53922. getRadius(impostor: PhysicsImpostor): number;
  53923. /**
  53924. * Gets the box size of the impostor
  53925. * @param impostor impostor to get box size from
  53926. * @param result the resulting box size
  53927. */
  53928. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53929. /**
  53930. * Disposes of the impostor
  53931. */
  53932. dispose(): void;
  53933. /**
  53934. * Does a raycast in the physics world
  53935. * @param from when should the ray start?
  53936. * @param to when should the ray end?
  53937. * @returns PhysicsRaycastResult
  53938. */
  53939. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53940. }
  53941. }
  53942. declare module BABYLON {
  53943. interface AbstractScene {
  53944. /**
  53945. * The list of reflection probes added to the scene
  53946. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53947. */
  53948. reflectionProbes: Array<ReflectionProbe>;
  53949. /**
  53950. * Removes the given reflection probe from this scene.
  53951. * @param toRemove The reflection probe to remove
  53952. * @returns The index of the removed reflection probe
  53953. */
  53954. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53955. /**
  53956. * Adds the given reflection probe to this scene.
  53957. * @param newReflectionProbe The reflection probe to add
  53958. */
  53959. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53960. }
  53961. /**
  53962. * Class used to generate realtime reflection / refraction cube textures
  53963. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53964. */
  53965. export class ReflectionProbe {
  53966. /** defines the name of the probe */
  53967. name: string;
  53968. private _scene;
  53969. private _renderTargetTexture;
  53970. private _projectionMatrix;
  53971. private _viewMatrix;
  53972. private _target;
  53973. private _add;
  53974. private _attachedMesh;
  53975. private _invertYAxis;
  53976. /** Gets or sets probe position (center of the cube map) */
  53977. position: Vector3;
  53978. /**
  53979. * Creates a new reflection probe
  53980. * @param name defines the name of the probe
  53981. * @param size defines the texture resolution (for each face)
  53982. * @param scene defines the hosting scene
  53983. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53984. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53985. */
  53986. constructor(
  53987. /** defines the name of the probe */
  53988. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53989. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53990. get samples(): number;
  53991. set samples(value: number);
  53992. /** Gets or sets the refresh rate to use (on every frame by default) */
  53993. get refreshRate(): number;
  53994. set refreshRate(value: number);
  53995. /**
  53996. * Gets the hosting scene
  53997. * @returns a Scene
  53998. */
  53999. getScene(): Scene;
  54000. /** Gets the internal CubeTexture used to render to */
  54001. get cubeTexture(): RenderTargetTexture;
  54002. /** Gets the list of meshes to render */
  54003. get renderList(): Nullable<AbstractMesh[]>;
  54004. /**
  54005. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54006. * @param mesh defines the mesh to attach to
  54007. */
  54008. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54009. /**
  54010. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54011. * @param renderingGroupId The rendering group id corresponding to its index
  54012. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54013. */
  54014. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54015. /**
  54016. * Clean all associated resources
  54017. */
  54018. dispose(): void;
  54019. /**
  54020. * Converts the reflection probe information to a readable string for debug purpose.
  54021. * @param fullDetails Supports for multiple levels of logging within scene loading
  54022. * @returns the human readable reflection probe info
  54023. */
  54024. toString(fullDetails?: boolean): string;
  54025. /**
  54026. * Get the class name of the relfection probe.
  54027. * @returns "ReflectionProbe"
  54028. */
  54029. getClassName(): string;
  54030. /**
  54031. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54032. * @returns The JSON representation of the texture
  54033. */
  54034. serialize(): any;
  54035. /**
  54036. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54037. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54038. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54039. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54040. * @returns The parsed reflection probe if successful
  54041. */
  54042. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54043. }
  54044. }
  54045. declare module BABYLON {
  54046. /** @hidden */
  54047. export var _BabylonLoaderRegistered: boolean;
  54048. /**
  54049. * Helps setting up some configuration for the babylon file loader.
  54050. */
  54051. export class BabylonFileLoaderConfiguration {
  54052. /**
  54053. * The loader does not allow injecting custom physix engine into the plugins.
  54054. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54055. * So you could set this variable to your engine import to make it work.
  54056. */
  54057. static LoaderInjectedPhysicsEngine: any;
  54058. }
  54059. }
  54060. declare module BABYLON {
  54061. /**
  54062. * The Physically based simple base material of BJS.
  54063. *
  54064. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54065. * It is used as the base class for both the specGloss and metalRough conventions.
  54066. */
  54067. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54068. /**
  54069. * Number of Simultaneous lights allowed on the material.
  54070. */
  54071. maxSimultaneousLights: number;
  54072. /**
  54073. * If sets to true, disables all the lights affecting the material.
  54074. */
  54075. disableLighting: boolean;
  54076. /**
  54077. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54078. */
  54079. environmentTexture: BaseTexture;
  54080. /**
  54081. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54082. */
  54083. invertNormalMapX: boolean;
  54084. /**
  54085. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54086. */
  54087. invertNormalMapY: boolean;
  54088. /**
  54089. * Normal map used in the model.
  54090. */
  54091. normalTexture: BaseTexture;
  54092. /**
  54093. * Emissivie color used to self-illuminate the model.
  54094. */
  54095. emissiveColor: Color3;
  54096. /**
  54097. * Emissivie texture used to self-illuminate the model.
  54098. */
  54099. emissiveTexture: BaseTexture;
  54100. /**
  54101. * Occlusion Channel Strenght.
  54102. */
  54103. occlusionStrength: number;
  54104. /**
  54105. * Occlusion Texture of the material (adding extra occlusion effects).
  54106. */
  54107. occlusionTexture: BaseTexture;
  54108. /**
  54109. * Defines the alpha limits in alpha test mode.
  54110. */
  54111. alphaCutOff: number;
  54112. /**
  54113. * Gets the current double sided mode.
  54114. */
  54115. get doubleSided(): boolean;
  54116. /**
  54117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54118. */
  54119. set doubleSided(value: boolean);
  54120. /**
  54121. * Stores the pre-calculated light information of a mesh in a texture.
  54122. */
  54123. lightmapTexture: BaseTexture;
  54124. /**
  54125. * If true, the light map contains occlusion information instead of lighting info.
  54126. */
  54127. useLightmapAsShadowmap: boolean;
  54128. /**
  54129. * Instantiates a new PBRMaterial instance.
  54130. *
  54131. * @param name The material name
  54132. * @param scene The scene the material will be use in.
  54133. */
  54134. constructor(name: string, scene: Scene);
  54135. getClassName(): string;
  54136. }
  54137. }
  54138. declare module BABYLON {
  54139. /**
  54140. * The PBR material of BJS following the metal roughness convention.
  54141. *
  54142. * This fits to the PBR convention in the GLTF definition:
  54143. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54144. */
  54145. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54146. /**
  54147. * The base color has two different interpretations depending on the value of metalness.
  54148. * When the material is a metal, the base color is the specific measured reflectance value
  54149. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54150. * of the material.
  54151. */
  54152. baseColor: Color3;
  54153. /**
  54154. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54155. * well as opacity information in the alpha channel.
  54156. */
  54157. baseTexture: BaseTexture;
  54158. /**
  54159. * Specifies the metallic scalar value of the material.
  54160. * Can also be used to scale the metalness values of the metallic texture.
  54161. */
  54162. metallic: number;
  54163. /**
  54164. * Specifies the roughness scalar value of the material.
  54165. * Can also be used to scale the roughness values of the metallic texture.
  54166. */
  54167. roughness: number;
  54168. /**
  54169. * Texture containing both the metallic value in the B channel and the
  54170. * roughness value in the G channel to keep better precision.
  54171. */
  54172. metallicRoughnessTexture: BaseTexture;
  54173. /**
  54174. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54175. *
  54176. * @param name The material name
  54177. * @param scene The scene the material will be use in.
  54178. */
  54179. constructor(name: string, scene: Scene);
  54180. /**
  54181. * Return the currrent class name of the material.
  54182. */
  54183. getClassName(): string;
  54184. /**
  54185. * Makes a duplicate of the current material.
  54186. * @param name - name to use for the new material.
  54187. */
  54188. clone(name: string): PBRMetallicRoughnessMaterial;
  54189. /**
  54190. * Serialize the material to a parsable JSON object.
  54191. */
  54192. serialize(): any;
  54193. /**
  54194. * Parses a JSON object correponding to the serialize function.
  54195. */
  54196. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54197. }
  54198. }
  54199. declare module BABYLON {
  54200. /**
  54201. * The PBR material of BJS following the specular glossiness convention.
  54202. *
  54203. * This fits to the PBR convention in the GLTF definition:
  54204. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54205. */
  54206. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54207. /**
  54208. * Specifies the diffuse color of the material.
  54209. */
  54210. diffuseColor: Color3;
  54211. /**
  54212. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54213. * channel.
  54214. */
  54215. diffuseTexture: BaseTexture;
  54216. /**
  54217. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54218. */
  54219. specularColor: Color3;
  54220. /**
  54221. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54222. */
  54223. glossiness: number;
  54224. /**
  54225. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54226. */
  54227. specularGlossinessTexture: BaseTexture;
  54228. /**
  54229. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54230. *
  54231. * @param name The material name
  54232. * @param scene The scene the material will be use in.
  54233. */
  54234. constructor(name: string, scene: Scene);
  54235. /**
  54236. * Return the currrent class name of the material.
  54237. */
  54238. getClassName(): string;
  54239. /**
  54240. * Makes a duplicate of the current material.
  54241. * @param name - name to use for the new material.
  54242. */
  54243. clone(name: string): PBRSpecularGlossinessMaterial;
  54244. /**
  54245. * Serialize the material to a parsable JSON object.
  54246. */
  54247. serialize(): any;
  54248. /**
  54249. * Parses a JSON object correponding to the serialize function.
  54250. */
  54251. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54257. * It can help converting any input color in a desired output one. This can then be used to create effects
  54258. * from sepia, black and white to sixties or futuristic rendering...
  54259. *
  54260. * The only supported format is currently 3dl.
  54261. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54262. */
  54263. export class ColorGradingTexture extends BaseTexture {
  54264. /**
  54265. * The current texture matrix. (will always be identity in color grading texture)
  54266. */
  54267. private _textureMatrix;
  54268. /**
  54269. * The texture URL.
  54270. */
  54271. url: string;
  54272. /**
  54273. * Empty line regex stored for GC.
  54274. */
  54275. private static _noneEmptyLineRegex;
  54276. private _engine;
  54277. /**
  54278. * Instantiates a ColorGradingTexture from the following parameters.
  54279. *
  54280. * @param url The location of the color gradind data (currently only supporting 3dl)
  54281. * @param scene The scene the texture will be used in
  54282. */
  54283. constructor(url: string, scene: Scene);
  54284. /**
  54285. * Returns the texture matrix used in most of the material.
  54286. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54287. */
  54288. getTextureMatrix(): Matrix;
  54289. /**
  54290. * Occurs when the file being loaded is a .3dl LUT file.
  54291. */
  54292. private load3dlTexture;
  54293. /**
  54294. * Starts the loading process of the texture.
  54295. */
  54296. private loadTexture;
  54297. /**
  54298. * Clones the color gradind texture.
  54299. */
  54300. clone(): ColorGradingTexture;
  54301. /**
  54302. * Called during delayed load for textures.
  54303. */
  54304. delayLoad(): void;
  54305. /**
  54306. * Parses a color grading texture serialized by Babylon.
  54307. * @param parsedTexture The texture information being parsedTexture
  54308. * @param scene The scene to load the texture in
  54309. * @param rootUrl The root url of the data assets to load
  54310. * @return A color gradind texture
  54311. */
  54312. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54313. /**
  54314. * Serializes the LUT texture to json format.
  54315. */
  54316. serialize(): any;
  54317. }
  54318. }
  54319. declare module BABYLON {
  54320. /**
  54321. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54322. */
  54323. export class EquiRectangularCubeTexture extends BaseTexture {
  54324. /** The six faces of the cube. */
  54325. private static _FacesMapping;
  54326. private _noMipmap;
  54327. private _onLoad;
  54328. private _onError;
  54329. /** The size of the cubemap. */
  54330. private _size;
  54331. /** The buffer of the image. */
  54332. private _buffer;
  54333. /** The width of the input image. */
  54334. private _width;
  54335. /** The height of the input image. */
  54336. private _height;
  54337. /** The URL to the image. */
  54338. url: string;
  54339. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54340. coordinatesMode: number;
  54341. /**
  54342. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54343. * @param url The location of the image
  54344. * @param scene The scene the texture will be used in
  54345. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54346. * @param noMipmap Forces to not generate the mipmap if true
  54347. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54348. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54349. * @param onLoad — defines a callback called when texture is loaded
  54350. * @param onError — defines a callback called if there is an error
  54351. */
  54352. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54353. /**
  54354. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54355. */
  54356. private loadImage;
  54357. /**
  54358. * Convert the image buffer into a cubemap and create a CubeTexture.
  54359. */
  54360. private loadTexture;
  54361. /**
  54362. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54363. * @param buffer The ArrayBuffer that should be converted.
  54364. * @returns The buffer as Float32Array.
  54365. */
  54366. private getFloat32ArrayFromArrayBuffer;
  54367. /**
  54368. * Get the current class name of the texture useful for serialization or dynamic coding.
  54369. * @returns "EquiRectangularCubeTexture"
  54370. */
  54371. getClassName(): string;
  54372. /**
  54373. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54374. * @returns A clone of the current EquiRectangularCubeTexture.
  54375. */
  54376. clone(): EquiRectangularCubeTexture;
  54377. }
  54378. }
  54379. declare module BABYLON {
  54380. /**
  54381. * Based on jsTGALoader - Javascript loader for TGA file
  54382. * By Vincent Thibault
  54383. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54384. */
  54385. export class TGATools {
  54386. private static _TYPE_INDEXED;
  54387. private static _TYPE_RGB;
  54388. private static _TYPE_GREY;
  54389. private static _TYPE_RLE_INDEXED;
  54390. private static _TYPE_RLE_RGB;
  54391. private static _TYPE_RLE_GREY;
  54392. private static _ORIGIN_MASK;
  54393. private static _ORIGIN_SHIFT;
  54394. private static _ORIGIN_BL;
  54395. private static _ORIGIN_BR;
  54396. private static _ORIGIN_UL;
  54397. private static _ORIGIN_UR;
  54398. /**
  54399. * Gets the header of a TGA file
  54400. * @param data defines the TGA data
  54401. * @returns the header
  54402. */
  54403. static GetTGAHeader(data: Uint8Array): any;
  54404. /**
  54405. * Uploads TGA content to a Babylon Texture
  54406. * @hidden
  54407. */
  54408. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54409. /** @hidden */
  54410. 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;
  54411. /** @hidden */
  54412. 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;
  54413. /** @hidden */
  54414. 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;
  54415. /** @hidden */
  54416. 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;
  54417. /** @hidden */
  54418. 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;
  54419. /** @hidden */
  54420. 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;
  54421. }
  54422. }
  54423. declare module BABYLON {
  54424. /**
  54425. * Implementation of the TGA Texture Loader.
  54426. * @hidden
  54427. */
  54428. export class _TGATextureLoader implements IInternalTextureLoader {
  54429. /**
  54430. * Defines wether the loader supports cascade loading the different faces.
  54431. */
  54432. readonly supportCascades: boolean;
  54433. /**
  54434. * This returns if the loader support the current file information.
  54435. * @param extension defines the file extension of the file being loaded
  54436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54437. * @param fallback defines the fallback internal texture if any
  54438. * @param isBase64 defines whether the texture is encoded as a base64
  54439. * @param isBuffer defines whether the texture data are stored as a buffer
  54440. * @returns true if the loader can load the specified file
  54441. */
  54442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54443. /**
  54444. * Transform the url before loading if required.
  54445. * @param rootUrl the url of the texture
  54446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54447. * @returns the transformed texture
  54448. */
  54449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54450. /**
  54451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54452. * @param rootUrl the url of the texture
  54453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54454. * @returns the fallback texture
  54455. */
  54456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54457. /**
  54458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54459. * @param data contains the texture data
  54460. * @param texture defines the BabylonJS internal texture
  54461. * @param createPolynomials will be true if polynomials have been requested
  54462. * @param onLoad defines the callback to trigger once the texture is ready
  54463. * @param onError defines the callback to trigger in case of error
  54464. */
  54465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54466. /**
  54467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54468. * @param data contains the texture data
  54469. * @param texture defines the BabylonJS internal texture
  54470. * @param callback defines the method to call once ready to upload
  54471. */
  54472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54473. }
  54474. }
  54475. declare module BABYLON {
  54476. /**
  54477. * Info about the .basis files
  54478. */
  54479. class BasisFileInfo {
  54480. /**
  54481. * If the file has alpha
  54482. */
  54483. hasAlpha: boolean;
  54484. /**
  54485. * Info about each image of the basis file
  54486. */
  54487. images: Array<{
  54488. levels: Array<{
  54489. width: number;
  54490. height: number;
  54491. transcodedPixels: ArrayBufferView;
  54492. }>;
  54493. }>;
  54494. }
  54495. /**
  54496. * Result of transcoding a basis file
  54497. */
  54498. class TranscodeResult {
  54499. /**
  54500. * Info about the .basis file
  54501. */
  54502. fileInfo: BasisFileInfo;
  54503. /**
  54504. * Format to use when loading the file
  54505. */
  54506. format: number;
  54507. }
  54508. /**
  54509. * Configuration options for the Basis transcoder
  54510. */
  54511. export class BasisTranscodeConfiguration {
  54512. /**
  54513. * Supported compression formats used to determine the supported output format of the transcoder
  54514. */
  54515. supportedCompressionFormats?: {
  54516. /**
  54517. * etc1 compression format
  54518. */
  54519. etc1?: boolean;
  54520. /**
  54521. * s3tc compression format
  54522. */
  54523. s3tc?: boolean;
  54524. /**
  54525. * pvrtc compression format
  54526. */
  54527. pvrtc?: boolean;
  54528. /**
  54529. * etc2 compression format
  54530. */
  54531. etc2?: boolean;
  54532. };
  54533. /**
  54534. * If mipmap levels should be loaded for transcoded images (Default: true)
  54535. */
  54536. loadMipmapLevels?: boolean;
  54537. /**
  54538. * Index of a single image to load (Default: all images)
  54539. */
  54540. loadSingleImage?: number;
  54541. }
  54542. /**
  54543. * Used to load .Basis files
  54544. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54545. */
  54546. export class BasisTools {
  54547. private static _IgnoreSupportedFormats;
  54548. /**
  54549. * URL to use when loading the basis transcoder
  54550. */
  54551. static JSModuleURL: string;
  54552. /**
  54553. * URL to use when loading the wasm module for the transcoder
  54554. */
  54555. static WasmModuleURL: string;
  54556. /**
  54557. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54558. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54559. * @returns internal format corresponding to the Basis format
  54560. */
  54561. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54562. private static _WorkerPromise;
  54563. private static _Worker;
  54564. private static _actionId;
  54565. private static _CreateWorkerAsync;
  54566. /**
  54567. * Transcodes a loaded image file to compressed pixel data
  54568. * @param imageData image data to transcode
  54569. * @param config configuration options for the transcoding
  54570. * @returns a promise resulting in the transcoded image
  54571. */
  54572. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54573. /**
  54574. * Loads a texture from the transcode result
  54575. * @param texture texture load to
  54576. * @param transcodeResult the result of transcoding the basis file to load from
  54577. */
  54578. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54579. }
  54580. }
  54581. declare module BABYLON {
  54582. /**
  54583. * Loader for .basis file format
  54584. */
  54585. export class _BasisTextureLoader implements IInternalTextureLoader {
  54586. /**
  54587. * Defines whether the loader supports cascade loading the different faces.
  54588. */
  54589. readonly supportCascades: boolean;
  54590. /**
  54591. * This returns if the loader support the current file information.
  54592. * @param extension defines the file extension of the file being loaded
  54593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54594. * @param fallback defines the fallback internal texture if any
  54595. * @param isBase64 defines whether the texture is encoded as a base64
  54596. * @param isBuffer defines whether the texture data are stored as a buffer
  54597. * @returns true if the loader can load the specified file
  54598. */
  54599. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54600. /**
  54601. * Transform the url before loading if required.
  54602. * @param rootUrl the url of the texture
  54603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54604. * @returns the transformed texture
  54605. */
  54606. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54607. /**
  54608. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54609. * @param rootUrl the url of the texture
  54610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54611. * @returns the fallback texture
  54612. */
  54613. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54614. /**
  54615. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54616. * @param data contains the texture data
  54617. * @param texture defines the BabylonJS internal texture
  54618. * @param createPolynomials will be true if polynomials have been requested
  54619. * @param onLoad defines the callback to trigger once the texture is ready
  54620. * @param onError defines the callback to trigger in case of error
  54621. */
  54622. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54623. /**
  54624. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54625. * @param data contains the texture data
  54626. * @param texture defines the BabylonJS internal texture
  54627. * @param callback defines the method to call once ready to upload
  54628. */
  54629. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54630. }
  54631. }
  54632. declare module BABYLON {
  54633. /**
  54634. * 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.
  54635. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54636. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54637. */
  54638. export class CustomProceduralTexture extends ProceduralTexture {
  54639. private _animate;
  54640. private _time;
  54641. private _config;
  54642. private _texturePath;
  54643. /**
  54644. * Instantiates a new Custom Procedural Texture.
  54645. * 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.
  54646. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54647. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54648. * @param name Define the name of the texture
  54649. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54650. * @param size Define the size of the texture to create
  54651. * @param scene Define the scene the texture belongs to
  54652. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54653. * @param generateMipMaps Define if the texture should creates mip maps or not
  54654. */
  54655. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54656. private _loadJson;
  54657. /**
  54658. * Is the texture ready to be used ? (rendered at least once)
  54659. * @returns true if ready, otherwise, false.
  54660. */
  54661. isReady(): boolean;
  54662. /**
  54663. * Render the texture to its associated render target.
  54664. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54665. */
  54666. render(useCameraPostProcess?: boolean): void;
  54667. /**
  54668. * Update the list of dependant textures samplers in the shader.
  54669. */
  54670. updateTextures(): void;
  54671. /**
  54672. * Update the uniform values of the procedural texture in the shader.
  54673. */
  54674. updateShaderUniforms(): void;
  54675. /**
  54676. * Define if the texture animates or not.
  54677. */
  54678. get animate(): boolean;
  54679. set animate(value: boolean);
  54680. }
  54681. }
  54682. declare module BABYLON {
  54683. /** @hidden */
  54684. export var noisePixelShader: {
  54685. name: string;
  54686. shader: string;
  54687. };
  54688. }
  54689. declare module BABYLON {
  54690. /**
  54691. * Class used to generate noise procedural textures
  54692. */
  54693. export class NoiseProceduralTexture extends ProceduralTexture {
  54694. private _time;
  54695. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54696. brightness: number;
  54697. /** Defines the number of octaves to process */
  54698. octaves: number;
  54699. /** Defines the level of persistence (0.8 by default) */
  54700. persistence: number;
  54701. /** Gets or sets animation speed factor (default is 1) */
  54702. animationSpeedFactor: number;
  54703. /**
  54704. * Creates a new NoiseProceduralTexture
  54705. * @param name defines the name fo the texture
  54706. * @param size defines the size of the texture (default is 256)
  54707. * @param scene defines the hosting scene
  54708. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54709. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54710. */
  54711. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54712. private _updateShaderUniforms;
  54713. protected _getDefines(): string;
  54714. /** Generate the current state of the procedural texture */
  54715. render(useCameraPostProcess?: boolean): void;
  54716. /**
  54717. * Serializes this noise procedural texture
  54718. * @returns a serialized noise procedural texture object
  54719. */
  54720. serialize(): any;
  54721. /**
  54722. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54723. * @param parsedTexture defines parsed texture data
  54724. * @param scene defines the current scene
  54725. * @param rootUrl defines the root URL containing noise procedural texture information
  54726. * @returns a parsed NoiseProceduralTexture
  54727. */
  54728. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54729. }
  54730. }
  54731. declare module BABYLON {
  54732. /**
  54733. * Raw cube texture where the raw buffers are passed in
  54734. */
  54735. export class RawCubeTexture extends CubeTexture {
  54736. /**
  54737. * Creates a cube texture where the raw buffers are passed in.
  54738. * @param scene defines the scene the texture is attached to
  54739. * @param data defines the array of data to use to create each face
  54740. * @param size defines the size of the textures
  54741. * @param format defines the format of the data
  54742. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54743. * @param generateMipMaps defines if the engine should generate the mip levels
  54744. * @param invertY defines if data must be stored with Y axis inverted
  54745. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54746. * @param compression defines the compression used (null by default)
  54747. */
  54748. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54749. /**
  54750. * Updates the raw cube texture.
  54751. * @param data defines the data to store
  54752. * @param format defines the data format
  54753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54754. * @param invertY defines if data must be stored with Y axis inverted
  54755. * @param compression defines the compression used (null by default)
  54756. * @param level defines which level of the texture to update
  54757. */
  54758. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54759. /**
  54760. * Updates a raw cube texture with RGBD encoded data.
  54761. * @param data defines the array of data [mipmap][face] to use to create each face
  54762. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54765. * @returns a promsie that resolves when the operation is complete
  54766. */
  54767. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54768. /**
  54769. * Clones the raw cube texture.
  54770. * @return a new cube texture
  54771. */
  54772. clone(): CubeTexture;
  54773. /** @hidden */
  54774. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54775. }
  54776. }
  54777. declare module BABYLON {
  54778. /**
  54779. * Class used to store 3D textures containing user data
  54780. */
  54781. export class RawTexture3D extends Texture {
  54782. /** Gets or sets the texture format to use */
  54783. format: number;
  54784. private _engine;
  54785. /**
  54786. * Create a new RawTexture3D
  54787. * @param data defines the data of the texture
  54788. * @param width defines the width of the texture
  54789. * @param height defines the height of the texture
  54790. * @param depth defines the depth of the texture
  54791. * @param format defines the texture format to use
  54792. * @param scene defines the hosting scene
  54793. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54794. * @param invertY defines if texture must be stored with Y axis inverted
  54795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54796. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54797. */
  54798. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54799. /** Gets or sets the texture format to use */
  54800. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54801. /**
  54802. * Update the texture with new data
  54803. * @param data defines the data to store in the texture
  54804. */
  54805. update(data: ArrayBufferView): void;
  54806. }
  54807. }
  54808. declare module BABYLON {
  54809. /**
  54810. * Class used to store 2D array textures containing user data
  54811. */
  54812. export class RawTexture2DArray extends Texture {
  54813. /** Gets or sets the texture format to use */
  54814. format: number;
  54815. private _engine;
  54816. /**
  54817. * Create a new RawTexture2DArray
  54818. * @param data defines the data of the texture
  54819. * @param width defines the width of the texture
  54820. * @param height defines the height of the texture
  54821. * @param depth defines the number of layers of the texture
  54822. * @param format defines the texture format to use
  54823. * @param scene defines the hosting scene
  54824. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54825. * @param invertY defines if texture must be stored with Y axis inverted
  54826. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54827. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54828. */
  54829. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54830. /** Gets or sets the texture format to use */
  54831. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54832. /**
  54833. * Update the texture with new data
  54834. * @param data defines the data to store in the texture
  54835. */
  54836. update(data: ArrayBufferView): void;
  54837. }
  54838. }
  54839. declare module BABYLON {
  54840. /**
  54841. * Creates a refraction texture used by refraction channel of the standard material.
  54842. * It is like a mirror but to see through a material.
  54843. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54844. */
  54845. export class RefractionTexture extends RenderTargetTexture {
  54846. /**
  54847. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54848. * 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.
  54849. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54850. */
  54851. refractionPlane: Plane;
  54852. /**
  54853. * Define how deep under the surface we should see.
  54854. */
  54855. depth: number;
  54856. /**
  54857. * Creates a refraction texture used by refraction channel of the standard material.
  54858. * It is like a mirror but to see through a material.
  54859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54860. * @param name Define the texture name
  54861. * @param size Define the size of the underlying texture
  54862. * @param scene Define the scene the refraction belongs to
  54863. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54864. */
  54865. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54866. /**
  54867. * Clone the refraction texture.
  54868. * @returns the cloned texture
  54869. */
  54870. clone(): RefractionTexture;
  54871. /**
  54872. * Serialize the texture to a JSON representation you could use in Parse later on
  54873. * @returns the serialized JSON representation
  54874. */
  54875. serialize(): any;
  54876. }
  54877. }
  54878. declare module BABYLON {
  54879. /**
  54880. * Defines the options related to the creation of an HtmlElementTexture
  54881. */
  54882. export interface IHtmlElementTextureOptions {
  54883. /**
  54884. * Defines wether mip maps should be created or not.
  54885. */
  54886. generateMipMaps?: boolean;
  54887. /**
  54888. * Defines the sampling mode of the texture.
  54889. */
  54890. samplingMode?: number;
  54891. /**
  54892. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54893. */
  54894. engine: Nullable<ThinEngine>;
  54895. /**
  54896. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54897. */
  54898. scene: Nullable<Scene>;
  54899. }
  54900. /**
  54901. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54902. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54903. * is automatically managed.
  54904. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54905. * in your application.
  54906. *
  54907. * As the update is not automatic, you need to call them manually.
  54908. */
  54909. export class HtmlElementTexture extends BaseTexture {
  54910. /**
  54911. * The texture URL.
  54912. */
  54913. element: HTMLVideoElement | HTMLCanvasElement;
  54914. private static readonly DefaultOptions;
  54915. private _textureMatrix;
  54916. private _engine;
  54917. private _isVideo;
  54918. private _generateMipMaps;
  54919. private _samplingMode;
  54920. /**
  54921. * Instantiates a HtmlElementTexture from the following parameters.
  54922. *
  54923. * @param name Defines the name of the texture
  54924. * @param element Defines the video or canvas the texture is filled with
  54925. * @param options Defines the other none mandatory texture creation options
  54926. */
  54927. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54928. private _createInternalTexture;
  54929. /**
  54930. * Returns the texture matrix used in most of the material.
  54931. */
  54932. getTextureMatrix(): Matrix;
  54933. /**
  54934. * Updates the content of the texture.
  54935. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54936. */
  54937. update(invertY?: Nullable<boolean>): void;
  54938. }
  54939. }
  54940. declare module BABYLON {
  54941. /**
  54942. * Enum used to define the target of a block
  54943. */
  54944. export enum NodeMaterialBlockTargets {
  54945. /** Vertex shader */
  54946. Vertex = 1,
  54947. /** Fragment shader */
  54948. Fragment = 2,
  54949. /** Neutral */
  54950. Neutral = 4,
  54951. /** Vertex and Fragment */
  54952. VertexAndFragment = 3
  54953. }
  54954. }
  54955. declare module BABYLON {
  54956. /**
  54957. * Defines the kind of connection point for node based material
  54958. */
  54959. export enum NodeMaterialBlockConnectionPointTypes {
  54960. /** Float */
  54961. Float = 1,
  54962. /** Int */
  54963. Int = 2,
  54964. /** Vector2 */
  54965. Vector2 = 4,
  54966. /** Vector3 */
  54967. Vector3 = 8,
  54968. /** Vector4 */
  54969. Vector4 = 16,
  54970. /** Color3 */
  54971. Color3 = 32,
  54972. /** Color4 */
  54973. Color4 = 64,
  54974. /** Matrix */
  54975. Matrix = 128,
  54976. /** Detect type based on connection */
  54977. AutoDetect = 1024,
  54978. /** Output type that will be defined by input type */
  54979. BasedOnInput = 2048
  54980. }
  54981. }
  54982. declare module BABYLON {
  54983. /**
  54984. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54985. */
  54986. export enum NodeMaterialBlockConnectionPointMode {
  54987. /** Value is an uniform */
  54988. Uniform = 0,
  54989. /** Value is a mesh attribute */
  54990. Attribute = 1,
  54991. /** Value is a varying between vertex and fragment shaders */
  54992. Varying = 2,
  54993. /** Mode is undefined */
  54994. Undefined = 3
  54995. }
  54996. }
  54997. declare module BABYLON {
  54998. /**
  54999. * Enum used to define system values e.g. values automatically provided by the system
  55000. */
  55001. export enum NodeMaterialSystemValues {
  55002. /** World */
  55003. World = 1,
  55004. /** View */
  55005. View = 2,
  55006. /** Projection */
  55007. Projection = 3,
  55008. /** ViewProjection */
  55009. ViewProjection = 4,
  55010. /** WorldView */
  55011. WorldView = 5,
  55012. /** WorldViewProjection */
  55013. WorldViewProjection = 6,
  55014. /** CameraPosition */
  55015. CameraPosition = 7,
  55016. /** Fog Color */
  55017. FogColor = 8,
  55018. /** Delta time */
  55019. DeltaTime = 9
  55020. }
  55021. }
  55022. declare module BABYLON {
  55023. /**
  55024. * Root class for all node material optimizers
  55025. */
  55026. export class NodeMaterialOptimizer {
  55027. /**
  55028. * Function used to optimize a NodeMaterial graph
  55029. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55030. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55031. */
  55032. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55033. }
  55034. }
  55035. declare module BABYLON {
  55036. /**
  55037. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55038. */
  55039. export class TransformBlock extends NodeMaterialBlock {
  55040. /**
  55041. * Defines the value to use to complement W value to transform it to a Vector4
  55042. */
  55043. complementW: number;
  55044. /**
  55045. * Defines the value to use to complement z value to transform it to a Vector4
  55046. */
  55047. complementZ: number;
  55048. /**
  55049. * Creates a new TransformBlock
  55050. * @param name defines the block name
  55051. */
  55052. constructor(name: string);
  55053. /**
  55054. * Gets the current class name
  55055. * @returns the class name
  55056. */
  55057. getClassName(): string;
  55058. /**
  55059. * Gets the vector input
  55060. */
  55061. get vector(): NodeMaterialConnectionPoint;
  55062. /**
  55063. * Gets the output component
  55064. */
  55065. get output(): NodeMaterialConnectionPoint;
  55066. /**
  55067. * Gets the matrix transform input
  55068. */
  55069. get transform(): NodeMaterialConnectionPoint;
  55070. protected _buildBlock(state: NodeMaterialBuildState): this;
  55071. serialize(): any;
  55072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55073. protected _dumpPropertiesCode(): string;
  55074. }
  55075. }
  55076. declare module BABYLON {
  55077. /**
  55078. * Block used to output the vertex position
  55079. */
  55080. export class VertexOutputBlock extends NodeMaterialBlock {
  55081. /**
  55082. * Creates a new VertexOutputBlock
  55083. * @param name defines the block name
  55084. */
  55085. constructor(name: string);
  55086. /**
  55087. * Gets the current class name
  55088. * @returns the class name
  55089. */
  55090. getClassName(): string;
  55091. /**
  55092. * Gets the vector input component
  55093. */
  55094. get vector(): NodeMaterialConnectionPoint;
  55095. protected _buildBlock(state: NodeMaterialBuildState): this;
  55096. }
  55097. }
  55098. declare module BABYLON {
  55099. /**
  55100. * Block used to output the final color
  55101. */
  55102. export class FragmentOutputBlock extends NodeMaterialBlock {
  55103. /**
  55104. * Create a new FragmentOutputBlock
  55105. * @param name defines the block name
  55106. */
  55107. constructor(name: string);
  55108. /**
  55109. * Gets the current class name
  55110. * @returns the class name
  55111. */
  55112. getClassName(): string;
  55113. /**
  55114. * Gets the rgba input component
  55115. */
  55116. get rgba(): NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the rgb input component
  55119. */
  55120. get rgb(): NodeMaterialConnectionPoint;
  55121. /**
  55122. * Gets the a input component
  55123. */
  55124. get a(): NodeMaterialConnectionPoint;
  55125. protected _buildBlock(state: NodeMaterialBuildState): this;
  55126. }
  55127. }
  55128. declare module BABYLON {
  55129. /**
  55130. * Block used to read a reflection texture from a sampler
  55131. */
  55132. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55133. private _define3DName;
  55134. private _defineCubicName;
  55135. private _defineExplicitName;
  55136. private _defineProjectionName;
  55137. private _defineLocalCubicName;
  55138. private _defineSphericalName;
  55139. private _definePlanarName;
  55140. private _defineEquirectangularName;
  55141. private _defineMirroredEquirectangularFixedName;
  55142. private _defineEquirectangularFixedName;
  55143. private _defineSkyboxName;
  55144. private _cubeSamplerName;
  55145. private _2DSamplerName;
  55146. private _positionUVWName;
  55147. private _directionWName;
  55148. private _reflectionCoordsName;
  55149. private _reflection2DCoordsName;
  55150. private _reflectionColorName;
  55151. private _reflectionMatrixName;
  55152. /**
  55153. * Gets or sets the texture associated with the node
  55154. */
  55155. texture: Nullable<BaseTexture>;
  55156. /**
  55157. * Create a new TextureBlock
  55158. * @param name defines the block name
  55159. */
  55160. constructor(name: string);
  55161. /**
  55162. * Gets the current class name
  55163. * @returns the class name
  55164. */
  55165. getClassName(): string;
  55166. /**
  55167. * Gets the world position input component
  55168. */
  55169. get position(): NodeMaterialConnectionPoint;
  55170. /**
  55171. * Gets the world position input component
  55172. */
  55173. get worldPosition(): NodeMaterialConnectionPoint;
  55174. /**
  55175. * Gets the world normal input component
  55176. */
  55177. get worldNormal(): NodeMaterialConnectionPoint;
  55178. /**
  55179. * Gets the world input component
  55180. */
  55181. get world(): NodeMaterialConnectionPoint;
  55182. /**
  55183. * Gets the camera (or eye) position component
  55184. */
  55185. get cameraPosition(): NodeMaterialConnectionPoint;
  55186. /**
  55187. * Gets the view input component
  55188. */
  55189. get view(): NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the rgb output component
  55192. */
  55193. get rgb(): NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the r output component
  55196. */
  55197. get r(): NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the g output component
  55200. */
  55201. get g(): NodeMaterialConnectionPoint;
  55202. /**
  55203. * Gets the b output component
  55204. */
  55205. get b(): NodeMaterialConnectionPoint;
  55206. autoConfigure(material: NodeMaterial): void;
  55207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55208. isReady(): boolean;
  55209. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55210. private _injectVertexCode;
  55211. private _writeOutput;
  55212. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55213. protected _dumpPropertiesCode(): string;
  55214. serialize(): any;
  55215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * Interface used to configure the node material editor
  55221. */
  55222. export interface INodeMaterialEditorOptions {
  55223. /** Define the URl to load node editor script */
  55224. editorURL?: string;
  55225. }
  55226. /** @hidden */
  55227. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55228. /** BONES */
  55229. NUM_BONE_INFLUENCERS: number;
  55230. BonesPerMesh: number;
  55231. BONETEXTURE: boolean;
  55232. /** MORPH TARGETS */
  55233. MORPHTARGETS: boolean;
  55234. MORPHTARGETS_NORMAL: boolean;
  55235. MORPHTARGETS_TANGENT: boolean;
  55236. MORPHTARGETS_UV: boolean;
  55237. NUM_MORPH_INFLUENCERS: number;
  55238. /** IMAGE PROCESSING */
  55239. IMAGEPROCESSING: boolean;
  55240. VIGNETTE: boolean;
  55241. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55242. VIGNETTEBLENDMODEOPAQUE: boolean;
  55243. TONEMAPPING: boolean;
  55244. TONEMAPPING_ACES: boolean;
  55245. CONTRAST: boolean;
  55246. EXPOSURE: boolean;
  55247. COLORCURVES: boolean;
  55248. COLORGRADING: boolean;
  55249. COLORGRADING3D: boolean;
  55250. SAMPLER3DGREENDEPTH: boolean;
  55251. SAMPLER3DBGRMAP: boolean;
  55252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55253. /** MISC. */
  55254. BUMPDIRECTUV: number;
  55255. constructor();
  55256. setValue(name: string, value: boolean): void;
  55257. }
  55258. /**
  55259. * Class used to configure NodeMaterial
  55260. */
  55261. export interface INodeMaterialOptions {
  55262. /**
  55263. * Defines if blocks should emit comments
  55264. */
  55265. emitComments: boolean;
  55266. }
  55267. /**
  55268. * Class used to create a node based material built by assembling shader blocks
  55269. */
  55270. export class NodeMaterial extends PushMaterial {
  55271. private static _BuildIdGenerator;
  55272. private _options;
  55273. private _vertexCompilationState;
  55274. private _fragmentCompilationState;
  55275. private _sharedData;
  55276. private _buildId;
  55277. private _buildWasSuccessful;
  55278. private _cachedWorldViewMatrix;
  55279. private _cachedWorldViewProjectionMatrix;
  55280. private _optimizers;
  55281. private _animationFrame;
  55282. /** Define the URl to load node editor script */
  55283. static EditorURL: string;
  55284. private BJSNODEMATERIALEDITOR;
  55285. /** Get the inspector from bundle or global */
  55286. private _getGlobalNodeMaterialEditor;
  55287. /**
  55288. * Gets or sets data used by visual editor
  55289. * @see https://nme.babylonjs.com
  55290. */
  55291. editorData: any;
  55292. /**
  55293. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  55294. */
  55295. ignoreAlpha: boolean;
  55296. /**
  55297. * Defines the maximum number of lights that can be used in the material
  55298. */
  55299. maxSimultaneousLights: number;
  55300. /**
  55301. * Observable raised when the material is built
  55302. */
  55303. onBuildObservable: Observable<NodeMaterial>;
  55304. /**
  55305. * Gets or sets the root nodes of the material vertex shader
  55306. */
  55307. _vertexOutputNodes: NodeMaterialBlock[];
  55308. /**
  55309. * Gets or sets the root nodes of the material fragment (pixel) shader
  55310. */
  55311. _fragmentOutputNodes: NodeMaterialBlock[];
  55312. /** Gets or sets options to control the node material overall behavior */
  55313. get options(): INodeMaterialOptions;
  55314. set options(options: INodeMaterialOptions);
  55315. /**
  55316. * Default configuration related to image processing available in the standard Material.
  55317. */
  55318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55319. /**
  55320. * Gets the image processing configuration used either in this material.
  55321. */
  55322. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55323. /**
  55324. * Sets the Default image processing configuration used either in the this material.
  55325. *
  55326. * If sets to null, the scene one is in use.
  55327. */
  55328. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55329. /**
  55330. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55331. */
  55332. attachedBlocks: NodeMaterialBlock[];
  55333. /**
  55334. * Create a new node based material
  55335. * @param name defines the material name
  55336. * @param scene defines the hosting scene
  55337. * @param options defines creation option
  55338. */
  55339. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55340. /**
  55341. * Gets the current class name of the material e.g. "NodeMaterial"
  55342. * @returns the class name
  55343. */
  55344. getClassName(): string;
  55345. /**
  55346. * Keep track of the image processing observer to allow dispose and replace.
  55347. */
  55348. private _imageProcessingObserver;
  55349. /**
  55350. * Attaches a new image processing configuration to the Standard Material.
  55351. * @param configuration
  55352. */
  55353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55354. /**
  55355. * Get a block by its name
  55356. * @param name defines the name of the block to retrieve
  55357. * @returns the required block or null if not found
  55358. */
  55359. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55360. /**
  55361. * Get a block by its name
  55362. * @param predicate defines the predicate used to find the good candidate
  55363. * @returns the required block or null if not found
  55364. */
  55365. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55366. /**
  55367. * Get an input block by its name
  55368. * @param predicate defines the predicate used to find the good candidate
  55369. * @returns the required input block or null if not found
  55370. */
  55371. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55372. /**
  55373. * Gets the list of input blocks attached to this material
  55374. * @returns an array of InputBlocks
  55375. */
  55376. getInputBlocks(): InputBlock[];
  55377. /**
  55378. * Adds a new optimizer to the list of optimizers
  55379. * @param optimizer defines the optimizers to add
  55380. * @returns the current material
  55381. */
  55382. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55383. /**
  55384. * Remove an optimizer from the list of optimizers
  55385. * @param optimizer defines the optimizers to remove
  55386. * @returns the current material
  55387. */
  55388. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55389. /**
  55390. * Add a new block to the list of output nodes
  55391. * @param node defines the node to add
  55392. * @returns the current material
  55393. */
  55394. addOutputNode(node: NodeMaterialBlock): this;
  55395. /**
  55396. * Remove a block from the list of root nodes
  55397. * @param node defines the node to remove
  55398. * @returns the current material
  55399. */
  55400. removeOutputNode(node: NodeMaterialBlock): this;
  55401. private _addVertexOutputNode;
  55402. private _removeVertexOutputNode;
  55403. private _addFragmentOutputNode;
  55404. private _removeFragmentOutputNode;
  55405. /**
  55406. * Specifies if the material will require alpha blending
  55407. * @returns a boolean specifying if alpha blending is needed
  55408. */
  55409. needAlphaBlending(): boolean;
  55410. /**
  55411. * Specifies if this material should be rendered in alpha test mode
  55412. * @returns a boolean specifying if an alpha test is needed.
  55413. */
  55414. needAlphaTesting(): boolean;
  55415. private _initializeBlock;
  55416. private _resetDualBlocks;
  55417. /**
  55418. * Remove a block from the current node material
  55419. * @param block defines the block to remove
  55420. */
  55421. removeBlock(block: NodeMaterialBlock): void;
  55422. /**
  55423. * Build the material and generates the inner effect
  55424. * @param verbose defines if the build should log activity
  55425. */
  55426. build(verbose?: boolean): void;
  55427. /**
  55428. * Runs an otpimization phase to try to improve the shader code
  55429. */
  55430. optimize(): void;
  55431. private _prepareDefinesForAttributes;
  55432. /**
  55433. * Get if the submesh is ready to be used and all its information available.
  55434. * Child classes can use it to update shaders
  55435. * @param mesh defines the mesh to check
  55436. * @param subMesh defines which submesh to check
  55437. * @param useInstances specifies that instances should be used
  55438. * @returns a boolean indicating that the submesh is ready or not
  55439. */
  55440. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55441. /**
  55442. * Get a string representing the shaders built by the current node graph
  55443. */
  55444. get compiledShaders(): string;
  55445. /**
  55446. * Binds the world matrix to the material
  55447. * @param world defines the world transformation matrix
  55448. */
  55449. bindOnlyWorldMatrix(world: Matrix): void;
  55450. /**
  55451. * Binds the submesh to this material by preparing the effect and shader to draw
  55452. * @param world defines the world transformation matrix
  55453. * @param mesh defines the mesh containing the submesh
  55454. * @param subMesh defines the submesh to bind the material to
  55455. */
  55456. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55457. /**
  55458. * Gets the active textures from the material
  55459. * @returns an array of textures
  55460. */
  55461. getActiveTextures(): BaseTexture[];
  55462. /**
  55463. * Gets the list of texture blocks
  55464. * @returns an array of texture blocks
  55465. */
  55466. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55467. /**
  55468. * Specifies if the material uses a texture
  55469. * @param texture defines the texture to check against the material
  55470. * @returns a boolean specifying if the material uses the texture
  55471. */
  55472. hasTexture(texture: BaseTexture): boolean;
  55473. /**
  55474. * Disposes the material
  55475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55478. */
  55479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55480. /** Creates the node editor window. */
  55481. private _createNodeEditor;
  55482. /**
  55483. * Launch the node material editor
  55484. * @param config Define the configuration of the editor
  55485. * @return a promise fulfilled when the node editor is visible
  55486. */
  55487. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55488. /**
  55489. * Clear the current material
  55490. */
  55491. clear(): void;
  55492. /**
  55493. * Clear the current material and set it to a default state
  55494. */
  55495. setToDefault(): void;
  55496. /**
  55497. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55498. * @param url defines the url to load from
  55499. * @returns a promise that will fullfil when the material is fully loaded
  55500. */
  55501. loadAsync(url: string): Promise<void>;
  55502. private _gatherBlocks;
  55503. /**
  55504. * Generate a string containing the code declaration required to create an equivalent of this material
  55505. * @returns a string
  55506. */
  55507. generateCode(): string;
  55508. /**
  55509. * Serializes this material in a JSON representation
  55510. * @returns the serialized material object
  55511. */
  55512. serialize(): any;
  55513. private _restoreConnections;
  55514. /**
  55515. * Clear the current graph and load a new one from a serialization object
  55516. * @param source defines the JSON representation of the material
  55517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55518. */
  55519. loadFromSerialization(source: any, rootUrl?: string): void;
  55520. /**
  55521. * Creates a node material from parsed material data
  55522. * @param source defines the JSON representation of the material
  55523. * @param scene defines the hosting scene
  55524. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55525. * @returns a new node material
  55526. */
  55527. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55528. /**
  55529. * Creates a new node material set to default basic configuration
  55530. * @param name defines the name of the material
  55531. * @param scene defines the hosting scene
  55532. * @returns a new NodeMaterial
  55533. */
  55534. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55535. }
  55536. }
  55537. declare module BABYLON {
  55538. /**
  55539. * Block used to read a texture from a sampler
  55540. */
  55541. export class TextureBlock extends NodeMaterialBlock {
  55542. private _defineName;
  55543. private _linearDefineName;
  55544. private _tempTextureRead;
  55545. private _samplerName;
  55546. private _transformedUVName;
  55547. private _textureTransformName;
  55548. private _textureInfoName;
  55549. private _mainUVName;
  55550. private _mainUVDefineName;
  55551. /**
  55552. * Gets or sets the texture associated with the node
  55553. */
  55554. texture: Nullable<Texture>;
  55555. /**
  55556. * Create a new TextureBlock
  55557. * @param name defines the block name
  55558. */
  55559. constructor(name: string);
  55560. /**
  55561. * Gets the current class name
  55562. * @returns the class name
  55563. */
  55564. getClassName(): string;
  55565. /**
  55566. * Gets the uv input component
  55567. */
  55568. get uv(): NodeMaterialConnectionPoint;
  55569. /**
  55570. * Gets the rgba output component
  55571. */
  55572. get rgba(): NodeMaterialConnectionPoint;
  55573. /**
  55574. * Gets the rgb output component
  55575. */
  55576. get rgb(): NodeMaterialConnectionPoint;
  55577. /**
  55578. * Gets the r output component
  55579. */
  55580. get r(): NodeMaterialConnectionPoint;
  55581. /**
  55582. * Gets the g output component
  55583. */
  55584. get g(): NodeMaterialConnectionPoint;
  55585. /**
  55586. * Gets the b output component
  55587. */
  55588. get b(): NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the a output component
  55591. */
  55592. get a(): NodeMaterialConnectionPoint;
  55593. get target(): NodeMaterialBlockTargets;
  55594. autoConfigure(material: NodeMaterial): void;
  55595. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55597. private _getTextureBase;
  55598. isReady(): boolean;
  55599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55600. private get _isMixed();
  55601. private _injectVertexCode;
  55602. private _writeTextureRead;
  55603. private _writeOutput;
  55604. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55605. protected _dumpPropertiesCode(): string;
  55606. serialize(): any;
  55607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55608. }
  55609. }
  55610. declare module BABYLON {
  55611. /**
  55612. * Class used to store shared data between 2 NodeMaterialBuildState
  55613. */
  55614. export class NodeMaterialBuildStateSharedData {
  55615. /**
  55616. * Gets the list of emitted varyings
  55617. */
  55618. temps: string[];
  55619. /**
  55620. * Gets the list of emitted varyings
  55621. */
  55622. varyings: string[];
  55623. /**
  55624. * Gets the varying declaration string
  55625. */
  55626. varyingDeclaration: string;
  55627. /**
  55628. * Input blocks
  55629. */
  55630. inputBlocks: InputBlock[];
  55631. /**
  55632. * Input blocks
  55633. */
  55634. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55635. /**
  55636. * Bindable blocks (Blocks that need to set data to the effect)
  55637. */
  55638. bindableBlocks: NodeMaterialBlock[];
  55639. /**
  55640. * List of blocks that can provide a compilation fallback
  55641. */
  55642. blocksWithFallbacks: NodeMaterialBlock[];
  55643. /**
  55644. * List of blocks that can provide a define update
  55645. */
  55646. blocksWithDefines: NodeMaterialBlock[];
  55647. /**
  55648. * List of blocks that can provide a repeatable content
  55649. */
  55650. repeatableContentBlocks: NodeMaterialBlock[];
  55651. /**
  55652. * List of blocks that can provide a dynamic list of uniforms
  55653. */
  55654. dynamicUniformBlocks: NodeMaterialBlock[];
  55655. /**
  55656. * List of blocks that can block the isReady function for the material
  55657. */
  55658. blockingBlocks: NodeMaterialBlock[];
  55659. /**
  55660. * Gets the list of animated inputs
  55661. */
  55662. animatedInputs: InputBlock[];
  55663. /**
  55664. * Build Id used to avoid multiple recompilations
  55665. */
  55666. buildId: number;
  55667. /** List of emitted variables */
  55668. variableNames: {
  55669. [key: string]: number;
  55670. };
  55671. /** List of emitted defines */
  55672. defineNames: {
  55673. [key: string]: number;
  55674. };
  55675. /** Should emit comments? */
  55676. emitComments: boolean;
  55677. /** Emit build activity */
  55678. verbose: boolean;
  55679. /** Gets or sets the hosting scene */
  55680. scene: Scene;
  55681. /**
  55682. * Gets the compilation hints emitted at compilation time
  55683. */
  55684. hints: {
  55685. needWorldViewMatrix: boolean;
  55686. needWorldViewProjectionMatrix: boolean;
  55687. needAlphaBlending: boolean;
  55688. needAlphaTesting: boolean;
  55689. };
  55690. /**
  55691. * List of compilation checks
  55692. */
  55693. checks: {
  55694. emitVertex: boolean;
  55695. emitFragment: boolean;
  55696. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55697. };
  55698. /** Creates a new shared data */
  55699. constructor();
  55700. /**
  55701. * Emits console errors and exceptions if there is a failing check
  55702. */
  55703. emitErrors(): void;
  55704. }
  55705. }
  55706. declare module BABYLON {
  55707. /**
  55708. * Class used to store node based material build state
  55709. */
  55710. export class NodeMaterialBuildState {
  55711. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55712. supportUniformBuffers: boolean;
  55713. /**
  55714. * Gets the list of emitted attributes
  55715. */
  55716. attributes: string[];
  55717. /**
  55718. * Gets the list of emitted uniforms
  55719. */
  55720. uniforms: string[];
  55721. /**
  55722. * Gets the list of emitted constants
  55723. */
  55724. constants: string[];
  55725. /**
  55726. * Gets the list of emitted samplers
  55727. */
  55728. samplers: string[];
  55729. /**
  55730. * Gets the list of emitted functions
  55731. */
  55732. functions: {
  55733. [key: string]: string;
  55734. };
  55735. /**
  55736. * Gets the list of emitted extensions
  55737. */
  55738. extensions: {
  55739. [key: string]: string;
  55740. };
  55741. /**
  55742. * Gets the target of the compilation state
  55743. */
  55744. target: NodeMaterialBlockTargets;
  55745. /**
  55746. * Gets the list of emitted counters
  55747. */
  55748. counters: {
  55749. [key: string]: number;
  55750. };
  55751. /**
  55752. * Shared data between multiple NodeMaterialBuildState instances
  55753. */
  55754. sharedData: NodeMaterialBuildStateSharedData;
  55755. /** @hidden */
  55756. _vertexState: NodeMaterialBuildState;
  55757. /** @hidden */
  55758. _attributeDeclaration: string;
  55759. /** @hidden */
  55760. _uniformDeclaration: string;
  55761. /** @hidden */
  55762. _constantDeclaration: string;
  55763. /** @hidden */
  55764. _samplerDeclaration: string;
  55765. /** @hidden */
  55766. _varyingTransfer: string;
  55767. private _repeatableContentAnchorIndex;
  55768. /** @hidden */
  55769. _builtCompilationString: string;
  55770. /**
  55771. * Gets the emitted compilation strings
  55772. */
  55773. compilationString: string;
  55774. /**
  55775. * Finalize the compilation strings
  55776. * @param state defines the current compilation state
  55777. */
  55778. finalize(state: NodeMaterialBuildState): void;
  55779. /** @hidden */
  55780. get _repeatableContentAnchor(): string;
  55781. /** @hidden */
  55782. _getFreeVariableName(prefix: string): string;
  55783. /** @hidden */
  55784. _getFreeDefineName(prefix: string): string;
  55785. /** @hidden */
  55786. _excludeVariableName(name: string): void;
  55787. /** @hidden */
  55788. _emit2DSampler(name: string): void;
  55789. /** @hidden */
  55790. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55791. /** @hidden */
  55792. _emitExtension(name: string, extension: string): void;
  55793. /** @hidden */
  55794. _emitFunction(name: string, code: string, comments: string): void;
  55795. /** @hidden */
  55796. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55797. replaceStrings?: {
  55798. search: RegExp;
  55799. replace: string;
  55800. }[];
  55801. repeatKey?: string;
  55802. }): string;
  55803. /** @hidden */
  55804. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55805. repeatKey?: string;
  55806. removeAttributes?: boolean;
  55807. removeUniforms?: boolean;
  55808. removeVaryings?: boolean;
  55809. removeIfDef?: boolean;
  55810. replaceStrings?: {
  55811. search: RegExp;
  55812. replace: string;
  55813. }[];
  55814. }, storeKey?: string): void;
  55815. /** @hidden */
  55816. _registerTempVariable(name: string): boolean;
  55817. /** @hidden */
  55818. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55819. /** @hidden */
  55820. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55821. /** @hidden */
  55822. _emitFloat(value: number): string;
  55823. }
  55824. }
  55825. declare module BABYLON {
  55826. /**
  55827. * Defines a block that can be used inside a node based material
  55828. */
  55829. export class NodeMaterialBlock {
  55830. private _buildId;
  55831. private _buildTarget;
  55832. private _target;
  55833. private _isFinalMerger;
  55834. private _isInput;
  55835. protected _isUnique: boolean;
  55836. /** @hidden */
  55837. _codeVariableName: string;
  55838. /** @hidden */
  55839. _inputs: NodeMaterialConnectionPoint[];
  55840. /** @hidden */
  55841. _outputs: NodeMaterialConnectionPoint[];
  55842. /** @hidden */
  55843. _preparationId: number;
  55844. /**
  55845. * Gets or sets the name of the block
  55846. */
  55847. name: string;
  55848. /**
  55849. * Gets or sets the unique id of the node
  55850. */
  55851. uniqueId: number;
  55852. /**
  55853. * Gets or sets the comments associated with this block
  55854. */
  55855. comments: string;
  55856. /**
  55857. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55858. */
  55859. get isUnique(): boolean;
  55860. /**
  55861. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55862. */
  55863. get isFinalMerger(): boolean;
  55864. /**
  55865. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55866. */
  55867. get isInput(): boolean;
  55868. /**
  55869. * Gets or sets the build Id
  55870. */
  55871. get buildId(): number;
  55872. set buildId(value: number);
  55873. /**
  55874. * Gets or sets the target of the block
  55875. */
  55876. get target(): NodeMaterialBlockTargets;
  55877. set target(value: NodeMaterialBlockTargets);
  55878. /**
  55879. * Gets the list of input points
  55880. */
  55881. get inputs(): NodeMaterialConnectionPoint[];
  55882. /** Gets the list of output points */
  55883. get outputs(): NodeMaterialConnectionPoint[];
  55884. /**
  55885. * Find an input by its name
  55886. * @param name defines the name of the input to look for
  55887. * @returns the input or null if not found
  55888. */
  55889. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55890. /**
  55891. * Find an output by its name
  55892. * @param name defines the name of the outputto look for
  55893. * @returns the output or null if not found
  55894. */
  55895. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55896. /**
  55897. * Creates a new NodeMaterialBlock
  55898. * @param name defines the block name
  55899. * @param target defines the target of that block (Vertex by default)
  55900. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55901. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55902. */
  55903. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55904. /**
  55905. * Initialize the block and prepare the context for build
  55906. * @param state defines the state that will be used for the build
  55907. */
  55908. initialize(state: NodeMaterialBuildState): void;
  55909. /**
  55910. * Bind data to effect. Will only be called for blocks with isBindable === true
  55911. * @param effect defines the effect to bind data to
  55912. * @param nodeMaterial defines the hosting NodeMaterial
  55913. * @param mesh defines the mesh that will be rendered
  55914. */
  55915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55916. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55917. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55918. protected _writeFloat(value: number): string;
  55919. /**
  55920. * Gets the current class name e.g. "NodeMaterialBlock"
  55921. * @returns the class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Register a new input. Must be called inside a block constructor
  55926. * @param name defines the connection point name
  55927. * @param type defines the connection point type
  55928. * @param isOptional defines a boolean indicating that this input can be omitted
  55929. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55930. * @returns the current block
  55931. */
  55932. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55933. /**
  55934. * Register a new output. Must be called inside a block constructor
  55935. * @param name defines the connection point name
  55936. * @param type defines the connection point type
  55937. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55938. * @returns the current block
  55939. */
  55940. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55941. /**
  55942. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55943. * @param forOutput defines an optional connection point to check compatibility with
  55944. * @returns the first available input or null
  55945. */
  55946. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55947. /**
  55948. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55949. * @param forBlock defines an optional block to check compatibility with
  55950. * @returns the first available input or null
  55951. */
  55952. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55953. /**
  55954. * Gets the sibling of the given output
  55955. * @param current defines the current output
  55956. * @returns the next output in the list or null
  55957. */
  55958. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55959. /**
  55960. * Connect current block with another block
  55961. * @param other defines the block to connect with
  55962. * @param options define the various options to help pick the right connections
  55963. * @returns the current block
  55964. */
  55965. connectTo(other: NodeMaterialBlock, options?: {
  55966. input?: string;
  55967. output?: string;
  55968. outputSwizzle?: string;
  55969. }): this | undefined;
  55970. protected _buildBlock(state: NodeMaterialBuildState): void;
  55971. /**
  55972. * Add uniforms, samplers and uniform buffers at compilation time
  55973. * @param state defines the state to update
  55974. * @param nodeMaterial defines the node material requesting the update
  55975. * @param defines defines the material defines to update
  55976. * @param uniformBuffers defines the list of uniform buffer names
  55977. */
  55978. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55979. /**
  55980. * Add potential fallbacks if shader compilation fails
  55981. * @param mesh defines the mesh to be rendered
  55982. * @param fallbacks defines the current prioritized list of fallbacks
  55983. */
  55984. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55985. /**
  55986. * Initialize defines for shader compilation
  55987. * @param mesh defines the mesh to be rendered
  55988. * @param nodeMaterial defines the node material requesting the update
  55989. * @param defines defines the material defines to update
  55990. * @param useInstances specifies that instances should be used
  55991. */
  55992. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55993. /**
  55994. * Update defines for shader compilation
  55995. * @param mesh defines the mesh to be rendered
  55996. * @param nodeMaterial defines the node material requesting the update
  55997. * @param defines defines the material defines to update
  55998. * @param useInstances specifies that instances should be used
  55999. */
  56000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56001. /**
  56002. * Lets the block try to connect some inputs automatically
  56003. * @param material defines the hosting NodeMaterial
  56004. */
  56005. autoConfigure(material: NodeMaterial): void;
  56006. /**
  56007. * Function called when a block is declared as repeatable content generator
  56008. * @param vertexShaderState defines the current compilation state for the vertex shader
  56009. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56010. * @param mesh defines the mesh to be rendered
  56011. * @param defines defines the material defines to update
  56012. */
  56013. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56014. /**
  56015. * Checks if the block is ready
  56016. * @param mesh defines the mesh to be rendered
  56017. * @param nodeMaterial defines the node material requesting the update
  56018. * @param defines defines the material defines to update
  56019. * @param useInstances specifies that instances should be used
  56020. * @returns true if the block is ready
  56021. */
  56022. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56023. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56024. private _processBuild;
  56025. /**
  56026. * Compile the current node and generate the shader code
  56027. * @param state defines the current compilation state (uniforms, samplers, current string)
  56028. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56029. * @returns true if already built
  56030. */
  56031. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56032. protected _inputRename(name: string): string;
  56033. protected _outputRename(name: string): string;
  56034. protected _dumpPropertiesCode(): string;
  56035. /** @hidden */
  56036. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56037. /** @hidden */
  56038. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56039. /**
  56040. * Clone the current block to a new identical block
  56041. * @param scene defines the hosting scene
  56042. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56043. * @returns a copy of the current block
  56044. */
  56045. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56046. /**
  56047. * Serializes this block in a JSON representation
  56048. * @returns the serialized block object
  56049. */
  56050. serialize(): any;
  56051. /** @hidden */
  56052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56053. /**
  56054. * Release resources
  56055. */
  56056. dispose(): void;
  56057. }
  56058. }
  56059. declare module BABYLON {
  56060. /**
  56061. * Enum defining the type of animations supported by InputBlock
  56062. */
  56063. export enum AnimatedInputBlockTypes {
  56064. /** No animation */
  56065. None = 0,
  56066. /** Time based animation. Will only work for floats */
  56067. Time = 1
  56068. }
  56069. }
  56070. declare module BABYLON {
  56071. /**
  56072. * Block used to expose an input value
  56073. */
  56074. export class InputBlock extends NodeMaterialBlock {
  56075. private _mode;
  56076. private _associatedVariableName;
  56077. private _storedValue;
  56078. private _valueCallback;
  56079. private _type;
  56080. private _animationType;
  56081. /** Gets or set a value used to limit the range of float values */
  56082. min: number;
  56083. /** Gets or set a value used to limit the range of float values */
  56084. max: number;
  56085. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56086. matrixMode: number;
  56087. /** @hidden */
  56088. _systemValue: Nullable<NodeMaterialSystemValues>;
  56089. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56090. visibleInInspector: boolean;
  56091. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56092. isConstant: boolean;
  56093. /** Gets or sets the group to use to display this block in the Inspector */
  56094. groupInInspector: string;
  56095. /**
  56096. * Gets or sets the connection point type (default is float)
  56097. */
  56098. get type(): NodeMaterialBlockConnectionPointTypes;
  56099. /**
  56100. * Creates a new InputBlock
  56101. * @param name defines the block name
  56102. * @param target defines the target of that block (Vertex by default)
  56103. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56104. */
  56105. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56106. /**
  56107. * Gets the output component
  56108. */
  56109. get output(): NodeMaterialConnectionPoint;
  56110. /**
  56111. * Set the source of this connection point to a vertex attribute
  56112. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56113. * @returns the current connection point
  56114. */
  56115. setAsAttribute(attributeName?: string): InputBlock;
  56116. /**
  56117. * Set the source of this connection point to a system value
  56118. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56119. * @returns the current connection point
  56120. */
  56121. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56122. /**
  56123. * Gets or sets the value of that point.
  56124. * Please note that this value will be ignored if valueCallback is defined
  56125. */
  56126. get value(): any;
  56127. set value(value: any);
  56128. /**
  56129. * Gets or sets a callback used to get the value of that point.
  56130. * Please note that setting this value will force the connection point to ignore the value property
  56131. */
  56132. get valueCallback(): () => any;
  56133. set valueCallback(value: () => any);
  56134. /**
  56135. * Gets or sets the associated variable name in the shader
  56136. */
  56137. get associatedVariableName(): string;
  56138. set associatedVariableName(value: string);
  56139. /** Gets or sets the type of animation applied to the input */
  56140. get animationType(): AnimatedInputBlockTypes;
  56141. set animationType(value: AnimatedInputBlockTypes);
  56142. /**
  56143. * Gets a boolean indicating that this connection point not defined yet
  56144. */
  56145. get isUndefined(): boolean;
  56146. /**
  56147. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56148. * In this case the connection point name must be the name of the uniform to use.
  56149. * Can only be set on inputs
  56150. */
  56151. get isUniform(): boolean;
  56152. set isUniform(value: boolean);
  56153. /**
  56154. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56155. * In this case the connection point name must be the name of the attribute to use
  56156. * Can only be set on inputs
  56157. */
  56158. get isAttribute(): boolean;
  56159. set isAttribute(value: boolean);
  56160. /**
  56161. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56162. * Can only be set on exit points
  56163. */
  56164. get isVarying(): boolean;
  56165. set isVarying(value: boolean);
  56166. /**
  56167. * Gets a boolean indicating that the current connection point is a system value
  56168. */
  56169. get isSystemValue(): boolean;
  56170. /**
  56171. * Gets or sets the current well known value or null if not defined as a system value
  56172. */
  56173. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56174. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56175. /**
  56176. * Gets the current class name
  56177. * @returns the class name
  56178. */
  56179. getClassName(): string;
  56180. /**
  56181. * Animate the input if animationType !== None
  56182. * @param scene defines the rendering scene
  56183. */
  56184. animate(scene: Scene): void;
  56185. private _emitDefine;
  56186. initialize(state: NodeMaterialBuildState): void;
  56187. /**
  56188. * Set the input block to its default value (based on its type)
  56189. */
  56190. setDefaultValue(): void;
  56191. private _emitConstant;
  56192. private _emit;
  56193. /** @hidden */
  56194. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56195. /** @hidden */
  56196. _transmit(effect: Effect, scene: Scene): void;
  56197. protected _buildBlock(state: NodeMaterialBuildState): void;
  56198. protected _dumpPropertiesCode(): string;
  56199. serialize(): any;
  56200. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56201. }
  56202. }
  56203. declare module BABYLON {
  56204. /**
  56205. * Enum used to define the compatibility state between two connection points
  56206. */
  56207. export enum NodeMaterialConnectionPointCompatibilityStates {
  56208. /** Points are compatibles */
  56209. Compatible = 0,
  56210. /** Points are incompatible because of their types */
  56211. TypeIncompatible = 1,
  56212. /** Points are incompatible because of their targets (vertex vs fragment) */
  56213. TargetIncompatible = 2
  56214. }
  56215. /**
  56216. * Defines the direction of a connection point
  56217. */
  56218. export enum NodeMaterialConnectionPointDirection {
  56219. /** Input */
  56220. Input = 0,
  56221. /** Output */
  56222. Output = 1
  56223. }
  56224. /**
  56225. * Defines a connection point for a block
  56226. */
  56227. export class NodeMaterialConnectionPoint {
  56228. /** @hidden */
  56229. _ownerBlock: NodeMaterialBlock;
  56230. /** @hidden */
  56231. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56232. private _endpoints;
  56233. private _associatedVariableName;
  56234. private _direction;
  56235. /** @hidden */
  56236. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56237. /** @hidden */
  56238. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56239. private _type;
  56240. /** @hidden */
  56241. _enforceAssociatedVariableName: boolean;
  56242. /** Gets the direction of the point */
  56243. get direction(): NodeMaterialConnectionPointDirection;
  56244. /**
  56245. * Gets or sets the additional types supported by this connection point
  56246. */
  56247. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56248. /**
  56249. * Gets or sets the additional types excluded by this connection point
  56250. */
  56251. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56252. /**
  56253. * Observable triggered when this point is connected
  56254. */
  56255. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56256. /**
  56257. * Gets or sets the associated variable name in the shader
  56258. */
  56259. get associatedVariableName(): string;
  56260. set associatedVariableName(value: string);
  56261. /**
  56262. * Gets or sets the connection point type (default is float)
  56263. */
  56264. get type(): NodeMaterialBlockConnectionPointTypes;
  56265. set type(value: NodeMaterialBlockConnectionPointTypes);
  56266. /**
  56267. * Gets or sets the connection point name
  56268. */
  56269. name: string;
  56270. /**
  56271. * Gets or sets a boolean indicating that this connection point can be omitted
  56272. */
  56273. isOptional: boolean;
  56274. /**
  56275. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56276. */
  56277. define: string;
  56278. /** @hidden */
  56279. _prioritizeVertex: boolean;
  56280. private _target;
  56281. /** Gets or sets the target of that connection point */
  56282. get target(): NodeMaterialBlockTargets;
  56283. set target(value: NodeMaterialBlockTargets);
  56284. /**
  56285. * Gets a boolean indicating that the current point is connected
  56286. */
  56287. get isConnected(): boolean;
  56288. /**
  56289. * Gets a boolean indicating that the current point is connected to an input block
  56290. */
  56291. get isConnectedToInputBlock(): boolean;
  56292. /**
  56293. * Gets a the connected input block (if any)
  56294. */
  56295. get connectInputBlock(): Nullable<InputBlock>;
  56296. /** Get the other side of the connection (if any) */
  56297. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56298. /** Get the block that owns this connection point */
  56299. get ownerBlock(): NodeMaterialBlock;
  56300. /** Get the block connected on the other side of this connection (if any) */
  56301. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56302. /** Get the block connected on the endpoints of this connection (if any) */
  56303. get connectedBlocks(): Array<NodeMaterialBlock>;
  56304. /** Gets the list of connected endpoints */
  56305. get endpoints(): NodeMaterialConnectionPoint[];
  56306. /** Gets a boolean indicating if that output point is connected to at least one input */
  56307. get hasEndpoints(): boolean;
  56308. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56309. get isConnectedInVertexShader(): boolean;
  56310. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56311. get isConnectedInFragmentShader(): boolean;
  56312. /**
  56313. * Creates a new connection point
  56314. * @param name defines the connection point name
  56315. * @param ownerBlock defines the block hosting this connection point
  56316. * @param direction defines the direction of the connection point
  56317. */
  56318. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56319. /**
  56320. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56321. * @returns the class name
  56322. */
  56323. getClassName(): string;
  56324. /**
  56325. * Gets a boolean indicating if the current point can be connected to another point
  56326. * @param connectionPoint defines the other connection point
  56327. * @returns a boolean
  56328. */
  56329. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56330. /**
  56331. * Gets a number indicating if the current point can be connected to another point
  56332. * @param connectionPoint defines the other connection point
  56333. * @returns a number defining the compatibility state
  56334. */
  56335. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56336. /**
  56337. * Connect this point to another connection point
  56338. * @param connectionPoint defines the other connection point
  56339. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56340. * @returns the current connection point
  56341. */
  56342. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56343. /**
  56344. * Disconnect this point from one of his endpoint
  56345. * @param endpoint defines the other connection point
  56346. * @returns the current connection point
  56347. */
  56348. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56349. /**
  56350. * Serializes this point in a JSON representation
  56351. * @returns the serialized point object
  56352. */
  56353. serialize(): any;
  56354. /**
  56355. * Release resources
  56356. */
  56357. dispose(): void;
  56358. }
  56359. }
  56360. declare module BABYLON {
  56361. /**
  56362. * Block used to add support for vertex skinning (bones)
  56363. */
  56364. export class BonesBlock extends NodeMaterialBlock {
  56365. /**
  56366. * Creates a new BonesBlock
  56367. * @param name defines the block name
  56368. */
  56369. constructor(name: string);
  56370. /**
  56371. * Initialize the block and prepare the context for build
  56372. * @param state defines the state that will be used for the build
  56373. */
  56374. initialize(state: NodeMaterialBuildState): void;
  56375. /**
  56376. * Gets the current class name
  56377. * @returns the class name
  56378. */
  56379. getClassName(): string;
  56380. /**
  56381. * Gets the matrix indices input component
  56382. */
  56383. get matricesIndices(): NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the matrix weights input component
  56386. */
  56387. get matricesWeights(): NodeMaterialConnectionPoint;
  56388. /**
  56389. * Gets the extra matrix indices input component
  56390. */
  56391. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56392. /**
  56393. * Gets the extra matrix weights input component
  56394. */
  56395. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56396. /**
  56397. * Gets the world input component
  56398. */
  56399. get world(): NodeMaterialConnectionPoint;
  56400. /**
  56401. * Gets the output component
  56402. */
  56403. get output(): NodeMaterialConnectionPoint;
  56404. autoConfigure(material: NodeMaterial): void;
  56405. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56408. protected _buildBlock(state: NodeMaterialBuildState): this;
  56409. }
  56410. }
  56411. declare module BABYLON {
  56412. /**
  56413. * Block used to add support for instances
  56414. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56415. */
  56416. export class InstancesBlock extends NodeMaterialBlock {
  56417. /**
  56418. * Creates a new InstancesBlock
  56419. * @param name defines the block name
  56420. */
  56421. constructor(name: string);
  56422. /**
  56423. * Gets the current class name
  56424. * @returns the class name
  56425. */
  56426. getClassName(): string;
  56427. /**
  56428. * Gets the first world row input component
  56429. */
  56430. get world0(): NodeMaterialConnectionPoint;
  56431. /**
  56432. * Gets the second world row input component
  56433. */
  56434. get world1(): NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the third world row input component
  56437. */
  56438. get world2(): NodeMaterialConnectionPoint;
  56439. /**
  56440. * Gets the forth world row input component
  56441. */
  56442. get world3(): NodeMaterialConnectionPoint;
  56443. /**
  56444. * Gets the world input component
  56445. */
  56446. get world(): NodeMaterialConnectionPoint;
  56447. /**
  56448. * Gets the output component
  56449. */
  56450. get output(): NodeMaterialConnectionPoint;
  56451. autoConfigure(material: NodeMaterial): void;
  56452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56453. protected _buildBlock(state: NodeMaterialBuildState): this;
  56454. }
  56455. }
  56456. declare module BABYLON {
  56457. /**
  56458. * Block used to add morph targets support to vertex shader
  56459. */
  56460. export class MorphTargetsBlock extends NodeMaterialBlock {
  56461. private _repeatableContentAnchor;
  56462. private _repeatebleContentGenerated;
  56463. /**
  56464. * Create a new MorphTargetsBlock
  56465. * @param name defines the block name
  56466. */
  56467. constructor(name: string);
  56468. /**
  56469. * Gets the current class name
  56470. * @returns the class name
  56471. */
  56472. getClassName(): string;
  56473. /**
  56474. * Gets the position input component
  56475. */
  56476. get position(): NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the normal input component
  56479. */
  56480. get normal(): NodeMaterialConnectionPoint;
  56481. /**
  56482. * Gets the tangent input component
  56483. */
  56484. get tangent(): NodeMaterialConnectionPoint;
  56485. /**
  56486. * Gets the tangent input component
  56487. */
  56488. get uv(): NodeMaterialConnectionPoint;
  56489. /**
  56490. * Gets the position output component
  56491. */
  56492. get positionOutput(): NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the normal output component
  56495. */
  56496. get normalOutput(): NodeMaterialConnectionPoint;
  56497. /**
  56498. * Gets the tangent output component
  56499. */
  56500. get tangentOutput(): NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the tangent output component
  56503. */
  56504. get uvOutput(): NodeMaterialConnectionPoint;
  56505. initialize(state: NodeMaterialBuildState): void;
  56506. autoConfigure(material: NodeMaterial): void;
  56507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56509. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56510. protected _buildBlock(state: NodeMaterialBuildState): this;
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. /**
  56515. * Block used to get data information from a light
  56516. */
  56517. export class LightInformationBlock extends NodeMaterialBlock {
  56518. private _lightDataUniformName;
  56519. private _lightColorUniformName;
  56520. private _lightTypeDefineName;
  56521. /**
  56522. * Gets or sets the light associated with this block
  56523. */
  56524. light: Nullable<Light>;
  56525. /**
  56526. * Creates a new LightInformationBlock
  56527. * @param name defines the block name
  56528. */
  56529. constructor(name: string);
  56530. /**
  56531. * Gets the current class name
  56532. * @returns the class name
  56533. */
  56534. getClassName(): string;
  56535. /**
  56536. * Gets the world position input component
  56537. */
  56538. get worldPosition(): NodeMaterialConnectionPoint;
  56539. /**
  56540. * Gets the direction output component
  56541. */
  56542. get direction(): NodeMaterialConnectionPoint;
  56543. /**
  56544. * Gets the direction output component
  56545. */
  56546. get color(): NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the direction output component
  56549. */
  56550. get intensity(): NodeMaterialConnectionPoint;
  56551. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56553. protected _buildBlock(state: NodeMaterialBuildState): this;
  56554. serialize(): any;
  56555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56556. }
  56557. }
  56558. declare module BABYLON {
  56559. /**
  56560. * Block used to add image processing support to fragment shader
  56561. */
  56562. export class ImageProcessingBlock extends NodeMaterialBlock {
  56563. /**
  56564. * Create a new ImageProcessingBlock
  56565. * @param name defines the block name
  56566. */
  56567. constructor(name: string);
  56568. /**
  56569. * Gets the current class name
  56570. * @returns the class name
  56571. */
  56572. getClassName(): string;
  56573. /**
  56574. * Gets the color input component
  56575. */
  56576. get color(): NodeMaterialConnectionPoint;
  56577. /**
  56578. * Gets the output component
  56579. */
  56580. get output(): NodeMaterialConnectionPoint;
  56581. /**
  56582. * Initialize the block and prepare the context for build
  56583. * @param state defines the state that will be used for the build
  56584. */
  56585. initialize(state: NodeMaterialBuildState): void;
  56586. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56589. protected _buildBlock(state: NodeMaterialBuildState): this;
  56590. }
  56591. }
  56592. declare module BABYLON {
  56593. /**
  56594. * Block used to pertub normals based on a normal map
  56595. */
  56596. export class PerturbNormalBlock extends NodeMaterialBlock {
  56597. private _tangentSpaceParameterName;
  56598. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56599. invertX: boolean;
  56600. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56601. invertY: boolean;
  56602. /**
  56603. * Create a new PerturbNormalBlock
  56604. * @param name defines the block name
  56605. */
  56606. constructor(name: string);
  56607. /**
  56608. * Gets the current class name
  56609. * @returns the class name
  56610. */
  56611. getClassName(): string;
  56612. /**
  56613. * Gets the world position input component
  56614. */
  56615. get worldPosition(): NodeMaterialConnectionPoint;
  56616. /**
  56617. * Gets the world normal input component
  56618. */
  56619. get worldNormal(): NodeMaterialConnectionPoint;
  56620. /**
  56621. * Gets the uv input component
  56622. */
  56623. get uv(): NodeMaterialConnectionPoint;
  56624. /**
  56625. * Gets the normal map color input component
  56626. */
  56627. get normalMapColor(): NodeMaterialConnectionPoint;
  56628. /**
  56629. * Gets the strength input component
  56630. */
  56631. get strength(): NodeMaterialConnectionPoint;
  56632. /**
  56633. * Gets the output component
  56634. */
  56635. get output(): NodeMaterialConnectionPoint;
  56636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56638. autoConfigure(material: NodeMaterial): void;
  56639. protected _buildBlock(state: NodeMaterialBuildState): this;
  56640. protected _dumpPropertiesCode(): string;
  56641. serialize(): any;
  56642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56643. }
  56644. }
  56645. declare module BABYLON {
  56646. /**
  56647. * Block used to discard a pixel if a value is smaller than a cutoff
  56648. */
  56649. export class DiscardBlock extends NodeMaterialBlock {
  56650. /**
  56651. * Create a new DiscardBlock
  56652. * @param name defines the block name
  56653. */
  56654. constructor(name: string);
  56655. /**
  56656. * Gets the current class name
  56657. * @returns the class name
  56658. */
  56659. getClassName(): string;
  56660. /**
  56661. * Gets the color input component
  56662. */
  56663. get value(): NodeMaterialConnectionPoint;
  56664. /**
  56665. * Gets the cutoff input component
  56666. */
  56667. get cutoff(): NodeMaterialConnectionPoint;
  56668. protected _buildBlock(state: NodeMaterialBuildState): this;
  56669. }
  56670. }
  56671. declare module BABYLON {
  56672. /**
  56673. * Block used to test if the fragment shader is front facing
  56674. */
  56675. export class FrontFacingBlock extends NodeMaterialBlock {
  56676. /**
  56677. * Creates a new FrontFacingBlock
  56678. * @param name defines the block name
  56679. */
  56680. constructor(name: string);
  56681. /**
  56682. * Gets the current class name
  56683. * @returns the class name
  56684. */
  56685. getClassName(): string;
  56686. /**
  56687. * Gets the output component
  56688. */
  56689. get output(): NodeMaterialConnectionPoint;
  56690. protected _buildBlock(state: NodeMaterialBuildState): this;
  56691. }
  56692. }
  56693. declare module BABYLON {
  56694. /**
  56695. * Block used to get the derivative value on x and y of a given input
  56696. */
  56697. export class DerivativeBlock extends NodeMaterialBlock {
  56698. /**
  56699. * Create a new DerivativeBlock
  56700. * @param name defines the block name
  56701. */
  56702. constructor(name: string);
  56703. /**
  56704. * Gets the current class name
  56705. * @returns the class name
  56706. */
  56707. getClassName(): string;
  56708. /**
  56709. * Gets the input component
  56710. */
  56711. get input(): NodeMaterialConnectionPoint;
  56712. /**
  56713. * Gets the derivative output on x
  56714. */
  56715. get dx(): NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the derivative output on y
  56718. */
  56719. get dy(): NodeMaterialConnectionPoint;
  56720. protected _buildBlock(state: NodeMaterialBuildState): this;
  56721. }
  56722. }
  56723. declare module BABYLON {
  56724. /**
  56725. * Block used to add support for scene fog
  56726. */
  56727. export class FogBlock extends NodeMaterialBlock {
  56728. private _fogDistanceName;
  56729. private _fogParameters;
  56730. /**
  56731. * Create a new FogBlock
  56732. * @param name defines the block name
  56733. */
  56734. constructor(name: string);
  56735. /**
  56736. * Gets the current class name
  56737. * @returns the class name
  56738. */
  56739. getClassName(): string;
  56740. /**
  56741. * Gets the world position input component
  56742. */
  56743. get worldPosition(): NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the view input component
  56746. */
  56747. get view(): NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the color input component
  56750. */
  56751. get input(): NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the fog color input component
  56754. */
  56755. get fogColor(): NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the output component
  56758. */
  56759. get output(): NodeMaterialConnectionPoint;
  56760. autoConfigure(material: NodeMaterial): void;
  56761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56763. protected _buildBlock(state: NodeMaterialBuildState): this;
  56764. }
  56765. }
  56766. declare module BABYLON {
  56767. /**
  56768. * Block used to add light in the fragment shader
  56769. */
  56770. export class LightBlock extends NodeMaterialBlock {
  56771. private _lightId;
  56772. /**
  56773. * Gets or sets the light associated with this block
  56774. */
  56775. light: Nullable<Light>;
  56776. /**
  56777. * Create a new LightBlock
  56778. * @param name defines the block name
  56779. */
  56780. constructor(name: string);
  56781. /**
  56782. * Gets the current class name
  56783. * @returns the class name
  56784. */
  56785. getClassName(): string;
  56786. /**
  56787. * Gets the world position input component
  56788. */
  56789. get worldPosition(): NodeMaterialConnectionPoint;
  56790. /**
  56791. * Gets the world normal input component
  56792. */
  56793. get worldNormal(): NodeMaterialConnectionPoint;
  56794. /**
  56795. * Gets the camera (or eye) position component
  56796. */
  56797. get cameraPosition(): NodeMaterialConnectionPoint;
  56798. /**
  56799. * Gets the glossiness component
  56800. */
  56801. get glossiness(): NodeMaterialConnectionPoint;
  56802. /**
  56803. * Gets the glossinness power component
  56804. */
  56805. get glossPower(): NodeMaterialConnectionPoint;
  56806. /**
  56807. * Gets the diffuse color component
  56808. */
  56809. get diffuseColor(): NodeMaterialConnectionPoint;
  56810. /**
  56811. * Gets the specular color component
  56812. */
  56813. get specularColor(): NodeMaterialConnectionPoint;
  56814. /**
  56815. * Gets the diffuse output component
  56816. */
  56817. get diffuseOutput(): NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the specular output component
  56820. */
  56821. get specularOutput(): NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the shadow output component
  56824. */
  56825. get shadow(): NodeMaterialConnectionPoint;
  56826. autoConfigure(material: NodeMaterial): void;
  56827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56828. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56830. private _injectVertexCode;
  56831. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56832. serialize(): any;
  56833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56834. }
  56835. }
  56836. declare module BABYLON {
  56837. /**
  56838. * Block used to multiply 2 values
  56839. */
  56840. export class MultiplyBlock extends NodeMaterialBlock {
  56841. /**
  56842. * Creates a new MultiplyBlock
  56843. * @param name defines the block name
  56844. */
  56845. constructor(name: string);
  56846. /**
  56847. * Gets the current class name
  56848. * @returns the class name
  56849. */
  56850. getClassName(): string;
  56851. /**
  56852. * Gets the left operand input component
  56853. */
  56854. get left(): NodeMaterialConnectionPoint;
  56855. /**
  56856. * Gets the right operand input component
  56857. */
  56858. get right(): NodeMaterialConnectionPoint;
  56859. /**
  56860. * Gets the output component
  56861. */
  56862. get output(): NodeMaterialConnectionPoint;
  56863. protected _buildBlock(state: NodeMaterialBuildState): this;
  56864. }
  56865. }
  56866. declare module BABYLON {
  56867. /**
  56868. * Block used to add 2 vectors
  56869. */
  56870. export class AddBlock extends NodeMaterialBlock {
  56871. /**
  56872. * Creates a new AddBlock
  56873. * @param name defines the block name
  56874. */
  56875. constructor(name: string);
  56876. /**
  56877. * Gets the current class name
  56878. * @returns the class name
  56879. */
  56880. getClassName(): string;
  56881. /**
  56882. * Gets the left operand input component
  56883. */
  56884. get left(): NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the right operand input component
  56887. */
  56888. get right(): NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the output component
  56891. */
  56892. get output(): NodeMaterialConnectionPoint;
  56893. protected _buildBlock(state: NodeMaterialBuildState): this;
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /**
  56898. * Block used to scale a vector by a float
  56899. */
  56900. export class ScaleBlock extends NodeMaterialBlock {
  56901. /**
  56902. * Creates a new ScaleBlock
  56903. * @param name defines the block name
  56904. */
  56905. constructor(name: string);
  56906. /**
  56907. * Gets the current class name
  56908. * @returns the class name
  56909. */
  56910. getClassName(): string;
  56911. /**
  56912. * Gets the input component
  56913. */
  56914. get input(): NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the factor input component
  56917. */
  56918. get factor(): NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the output component
  56921. */
  56922. get output(): NodeMaterialConnectionPoint;
  56923. protected _buildBlock(state: NodeMaterialBuildState): this;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Block used to clamp a float
  56929. */
  56930. export class ClampBlock extends NodeMaterialBlock {
  56931. /** Gets or sets the minimum range */
  56932. minimum: number;
  56933. /** Gets or sets the maximum range */
  56934. maximum: number;
  56935. /**
  56936. * Creates a new ClampBlock
  56937. * @param name defines the block name
  56938. */
  56939. constructor(name: string);
  56940. /**
  56941. * Gets the current class name
  56942. * @returns the class name
  56943. */
  56944. getClassName(): string;
  56945. /**
  56946. * Gets the value input component
  56947. */
  56948. get value(): NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. get output(): NodeMaterialConnectionPoint;
  56953. protected _buildBlock(state: NodeMaterialBuildState): this;
  56954. protected _dumpPropertiesCode(): string;
  56955. serialize(): any;
  56956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56957. }
  56958. }
  56959. declare module BABYLON {
  56960. /**
  56961. * Block used to apply a cross product between 2 vectors
  56962. */
  56963. export class CrossBlock extends NodeMaterialBlock {
  56964. /**
  56965. * Creates a new CrossBlock
  56966. * @param name defines the block name
  56967. */
  56968. constructor(name: string);
  56969. /**
  56970. * Gets the current class name
  56971. * @returns the class name
  56972. */
  56973. getClassName(): string;
  56974. /**
  56975. * Gets the left operand input component
  56976. */
  56977. get left(): NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the right operand input component
  56980. */
  56981. get right(): NodeMaterialConnectionPoint;
  56982. /**
  56983. * Gets the output component
  56984. */
  56985. get output(): NodeMaterialConnectionPoint;
  56986. protected _buildBlock(state: NodeMaterialBuildState): this;
  56987. }
  56988. }
  56989. declare module BABYLON {
  56990. /**
  56991. * Block used to apply a dot product between 2 vectors
  56992. */
  56993. export class DotBlock extends NodeMaterialBlock {
  56994. /**
  56995. * Creates a new DotBlock
  56996. * @param name defines the block name
  56997. */
  56998. constructor(name: string);
  56999. /**
  57000. * Gets the current class name
  57001. * @returns the class name
  57002. */
  57003. getClassName(): string;
  57004. /**
  57005. * Gets the left operand input component
  57006. */
  57007. get left(): NodeMaterialConnectionPoint;
  57008. /**
  57009. * Gets the right operand input component
  57010. */
  57011. get right(): NodeMaterialConnectionPoint;
  57012. /**
  57013. * Gets the output component
  57014. */
  57015. get output(): NodeMaterialConnectionPoint;
  57016. protected _buildBlock(state: NodeMaterialBuildState): this;
  57017. }
  57018. }
  57019. declare module BABYLON {
  57020. /**
  57021. * Block used to remap a float from a range to a new one
  57022. */
  57023. export class RemapBlock extends NodeMaterialBlock {
  57024. /**
  57025. * Gets or sets the source range
  57026. */
  57027. sourceRange: Vector2;
  57028. /**
  57029. * Gets or sets the target range
  57030. */
  57031. targetRange: Vector2;
  57032. /**
  57033. * Creates a new RemapBlock
  57034. * @param name defines the block name
  57035. */
  57036. constructor(name: string);
  57037. /**
  57038. * Gets the current class name
  57039. * @returns the class name
  57040. */
  57041. getClassName(): string;
  57042. /**
  57043. * Gets the input component
  57044. */
  57045. get input(): NodeMaterialConnectionPoint;
  57046. /**
  57047. * Gets the source min input component
  57048. */
  57049. get sourceMin(): NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the source max input component
  57052. */
  57053. get sourceMax(): NodeMaterialConnectionPoint;
  57054. /**
  57055. * Gets the target min input component
  57056. */
  57057. get targetMin(): NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the target max input component
  57060. */
  57061. get targetMax(): NodeMaterialConnectionPoint;
  57062. /**
  57063. * Gets the output component
  57064. */
  57065. get output(): NodeMaterialConnectionPoint;
  57066. protected _buildBlock(state: NodeMaterialBuildState): this;
  57067. protected _dumpPropertiesCode(): string;
  57068. serialize(): any;
  57069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57070. }
  57071. }
  57072. declare module BABYLON {
  57073. /**
  57074. * Block used to normalize a vector
  57075. */
  57076. export class NormalizeBlock extends NodeMaterialBlock {
  57077. /**
  57078. * Creates a new NormalizeBlock
  57079. * @param name defines the block name
  57080. */
  57081. constructor(name: string);
  57082. /**
  57083. * Gets the current class name
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets the input component
  57089. */
  57090. get input(): NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the output component
  57093. */
  57094. get output(): NodeMaterialConnectionPoint;
  57095. protected _buildBlock(state: NodeMaterialBuildState): this;
  57096. }
  57097. }
  57098. declare module BABYLON {
  57099. /**
  57100. * Operations supported by the Trigonometry block
  57101. */
  57102. export enum TrigonometryBlockOperations {
  57103. /** Cos */
  57104. Cos = 0,
  57105. /** Sin */
  57106. Sin = 1,
  57107. /** Abs */
  57108. Abs = 2,
  57109. /** Exp */
  57110. Exp = 3,
  57111. /** Exp2 */
  57112. Exp2 = 4,
  57113. /** Round */
  57114. Round = 5,
  57115. /** Floor */
  57116. Floor = 6,
  57117. /** Ceiling */
  57118. Ceiling = 7,
  57119. /** Square root */
  57120. Sqrt = 8,
  57121. /** Log */
  57122. Log = 9,
  57123. /** Tangent */
  57124. Tan = 10,
  57125. /** Arc tangent */
  57126. ArcTan = 11,
  57127. /** Arc cosinus */
  57128. ArcCos = 12,
  57129. /** Arc sinus */
  57130. ArcSin = 13,
  57131. /** Fraction */
  57132. Fract = 14,
  57133. /** Sign */
  57134. Sign = 15,
  57135. /** To radians (from degrees) */
  57136. Radians = 16,
  57137. /** To degrees (from radians) */
  57138. Degrees = 17
  57139. }
  57140. /**
  57141. * Block used to apply trigonometry operation to floats
  57142. */
  57143. export class TrigonometryBlock extends NodeMaterialBlock {
  57144. /**
  57145. * Gets or sets the operation applied by the block
  57146. */
  57147. operation: TrigonometryBlockOperations;
  57148. /**
  57149. * Creates a new TrigonometryBlock
  57150. * @param name defines the block name
  57151. */
  57152. constructor(name: string);
  57153. /**
  57154. * Gets the current class name
  57155. * @returns the class name
  57156. */
  57157. getClassName(): string;
  57158. /**
  57159. * Gets the input component
  57160. */
  57161. get input(): NodeMaterialConnectionPoint;
  57162. /**
  57163. * Gets the output component
  57164. */
  57165. get output(): NodeMaterialConnectionPoint;
  57166. protected _buildBlock(state: NodeMaterialBuildState): this;
  57167. serialize(): any;
  57168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57169. protected _dumpPropertiesCode(): string;
  57170. }
  57171. }
  57172. declare module BABYLON {
  57173. /**
  57174. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57175. */
  57176. export class ColorMergerBlock extends NodeMaterialBlock {
  57177. /**
  57178. * Create a new ColorMergerBlock
  57179. * @param name defines the block name
  57180. */
  57181. constructor(name: string);
  57182. /**
  57183. * Gets the current class name
  57184. * @returns the class name
  57185. */
  57186. getClassName(): string;
  57187. /**
  57188. * Gets the rgb component (input)
  57189. */
  57190. get rgbIn(): NodeMaterialConnectionPoint;
  57191. /**
  57192. * Gets the r component (input)
  57193. */
  57194. get r(): NodeMaterialConnectionPoint;
  57195. /**
  57196. * Gets the g component (input)
  57197. */
  57198. get g(): NodeMaterialConnectionPoint;
  57199. /**
  57200. * Gets the b component (input)
  57201. */
  57202. get b(): NodeMaterialConnectionPoint;
  57203. /**
  57204. * Gets the a component (input)
  57205. */
  57206. get a(): NodeMaterialConnectionPoint;
  57207. /**
  57208. * Gets the rgba component (output)
  57209. */
  57210. get rgba(): NodeMaterialConnectionPoint;
  57211. /**
  57212. * Gets the rgb component (output)
  57213. */
  57214. get rgbOut(): NodeMaterialConnectionPoint;
  57215. /**
  57216. * Gets the rgb component (output)
  57217. * @deprecated Please use rgbOut instead.
  57218. */
  57219. get rgb(): NodeMaterialConnectionPoint;
  57220. protected _buildBlock(state: NodeMaterialBuildState): this;
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. /**
  57225. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57226. */
  57227. export class VectorMergerBlock extends NodeMaterialBlock {
  57228. /**
  57229. * Create a new VectorMergerBlock
  57230. * @param name defines the block name
  57231. */
  57232. constructor(name: string);
  57233. /**
  57234. * Gets the current class name
  57235. * @returns the class name
  57236. */
  57237. getClassName(): string;
  57238. /**
  57239. * Gets the xyz component (input)
  57240. */
  57241. get xyzIn(): NodeMaterialConnectionPoint;
  57242. /**
  57243. * Gets the xy component (input)
  57244. */
  57245. get xyIn(): NodeMaterialConnectionPoint;
  57246. /**
  57247. * Gets the x component (input)
  57248. */
  57249. get x(): NodeMaterialConnectionPoint;
  57250. /**
  57251. * Gets the y component (input)
  57252. */
  57253. get y(): NodeMaterialConnectionPoint;
  57254. /**
  57255. * Gets the z component (input)
  57256. */
  57257. get z(): NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the w component (input)
  57260. */
  57261. get w(): NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the xyzw component (output)
  57264. */
  57265. get xyzw(): NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the xyz component (output)
  57268. */
  57269. get xyzOut(): NodeMaterialConnectionPoint;
  57270. /**
  57271. * Gets the xy component (output)
  57272. */
  57273. get xyOut(): NodeMaterialConnectionPoint;
  57274. /**
  57275. * Gets the xy component (output)
  57276. * @deprecated Please use xyOut instead.
  57277. */
  57278. get xy(): NodeMaterialConnectionPoint;
  57279. /**
  57280. * Gets the xyz component (output)
  57281. * @deprecated Please use xyzOut instead.
  57282. */
  57283. get xyz(): NodeMaterialConnectionPoint;
  57284. protected _buildBlock(state: NodeMaterialBuildState): this;
  57285. }
  57286. }
  57287. declare module BABYLON {
  57288. /**
  57289. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57290. */
  57291. export class ColorSplitterBlock extends NodeMaterialBlock {
  57292. /**
  57293. * Create a new ColorSplitterBlock
  57294. * @param name defines the block name
  57295. */
  57296. constructor(name: string);
  57297. /**
  57298. * Gets the current class name
  57299. * @returns the class name
  57300. */
  57301. getClassName(): string;
  57302. /**
  57303. * Gets the rgba component (input)
  57304. */
  57305. get rgba(): NodeMaterialConnectionPoint;
  57306. /**
  57307. * Gets the rgb component (input)
  57308. */
  57309. get rgbIn(): NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the rgb component (output)
  57312. */
  57313. get rgbOut(): NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the r component (output)
  57316. */
  57317. get r(): NodeMaterialConnectionPoint;
  57318. /**
  57319. * Gets the g component (output)
  57320. */
  57321. get g(): NodeMaterialConnectionPoint;
  57322. /**
  57323. * Gets the b component (output)
  57324. */
  57325. get b(): NodeMaterialConnectionPoint;
  57326. /**
  57327. * Gets the a component (output)
  57328. */
  57329. get a(): NodeMaterialConnectionPoint;
  57330. protected _inputRename(name: string): string;
  57331. protected _outputRename(name: string): string;
  57332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57333. }
  57334. }
  57335. declare module BABYLON {
  57336. /**
  57337. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57338. */
  57339. export class VectorSplitterBlock extends NodeMaterialBlock {
  57340. /**
  57341. * Create a new VectorSplitterBlock
  57342. * @param name defines the block name
  57343. */
  57344. constructor(name: string);
  57345. /**
  57346. * Gets the current class name
  57347. * @returns the class name
  57348. */
  57349. getClassName(): string;
  57350. /**
  57351. * Gets the xyzw component (input)
  57352. */
  57353. get xyzw(): NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the xyz component (input)
  57356. */
  57357. get xyzIn(): NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the xy component (input)
  57360. */
  57361. get xyIn(): NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the xyz component (output)
  57364. */
  57365. get xyzOut(): NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the xy component (output)
  57368. */
  57369. get xyOut(): NodeMaterialConnectionPoint;
  57370. /**
  57371. * Gets the x component (output)
  57372. */
  57373. get x(): NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the y component (output)
  57376. */
  57377. get y(): NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the z component (output)
  57380. */
  57381. get z(): NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the w component (output)
  57384. */
  57385. get w(): NodeMaterialConnectionPoint;
  57386. protected _inputRename(name: string): string;
  57387. protected _outputRename(name: string): string;
  57388. protected _buildBlock(state: NodeMaterialBuildState): this;
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /**
  57393. * Block used to lerp between 2 values
  57394. */
  57395. export class LerpBlock extends NodeMaterialBlock {
  57396. /**
  57397. * Creates a new LerpBlock
  57398. * @param name defines the block name
  57399. */
  57400. constructor(name: string);
  57401. /**
  57402. * Gets the current class name
  57403. * @returns the class name
  57404. */
  57405. getClassName(): string;
  57406. /**
  57407. * Gets the left operand input component
  57408. */
  57409. get left(): NodeMaterialConnectionPoint;
  57410. /**
  57411. * Gets the right operand input component
  57412. */
  57413. get right(): NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the gradient operand input component
  57416. */
  57417. get gradient(): NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the output component
  57420. */
  57421. get output(): NodeMaterialConnectionPoint;
  57422. protected _buildBlock(state: NodeMaterialBuildState): this;
  57423. }
  57424. }
  57425. declare module BABYLON {
  57426. /**
  57427. * Block used to divide 2 vectors
  57428. */
  57429. export class DivideBlock extends NodeMaterialBlock {
  57430. /**
  57431. * Creates a new DivideBlock
  57432. * @param name defines the block name
  57433. */
  57434. constructor(name: string);
  57435. /**
  57436. * Gets the current class name
  57437. * @returns the class name
  57438. */
  57439. getClassName(): string;
  57440. /**
  57441. * Gets the left operand input component
  57442. */
  57443. get left(): NodeMaterialConnectionPoint;
  57444. /**
  57445. * Gets the right operand input component
  57446. */
  57447. get right(): NodeMaterialConnectionPoint;
  57448. /**
  57449. * Gets the output component
  57450. */
  57451. get output(): NodeMaterialConnectionPoint;
  57452. protected _buildBlock(state: NodeMaterialBuildState): this;
  57453. }
  57454. }
  57455. declare module BABYLON {
  57456. /**
  57457. * Block used to subtract 2 vectors
  57458. */
  57459. export class SubtractBlock extends NodeMaterialBlock {
  57460. /**
  57461. * Creates a new SubtractBlock
  57462. * @param name defines the block name
  57463. */
  57464. constructor(name: string);
  57465. /**
  57466. * Gets the current class name
  57467. * @returns the class name
  57468. */
  57469. getClassName(): string;
  57470. /**
  57471. * Gets the left operand input component
  57472. */
  57473. get left(): NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the right operand input component
  57476. */
  57477. get right(): NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the output component
  57480. */
  57481. get output(): NodeMaterialConnectionPoint;
  57482. protected _buildBlock(state: NodeMaterialBuildState): this;
  57483. }
  57484. }
  57485. declare module BABYLON {
  57486. /**
  57487. * Block used to step a value
  57488. */
  57489. export class StepBlock extends NodeMaterialBlock {
  57490. /**
  57491. * Creates a new StepBlock
  57492. * @param name defines the block name
  57493. */
  57494. constructor(name: string);
  57495. /**
  57496. * Gets the current class name
  57497. * @returns the class name
  57498. */
  57499. getClassName(): string;
  57500. /**
  57501. * Gets the value operand input component
  57502. */
  57503. get value(): NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the edge operand input component
  57506. */
  57507. get edge(): NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the output component
  57510. */
  57511. get output(): NodeMaterialConnectionPoint;
  57512. protected _buildBlock(state: NodeMaterialBuildState): this;
  57513. }
  57514. }
  57515. declare module BABYLON {
  57516. /**
  57517. * Block used to get the opposite (1 - x) of a value
  57518. */
  57519. export class OneMinusBlock extends NodeMaterialBlock {
  57520. /**
  57521. * Creates a new OneMinusBlock
  57522. * @param name defines the block name
  57523. */
  57524. constructor(name: string);
  57525. /**
  57526. * Gets the current class name
  57527. * @returns the class name
  57528. */
  57529. getClassName(): string;
  57530. /**
  57531. * Gets the input component
  57532. */
  57533. get input(): NodeMaterialConnectionPoint;
  57534. /**
  57535. * Gets the output component
  57536. */
  57537. get output(): NodeMaterialConnectionPoint;
  57538. protected _buildBlock(state: NodeMaterialBuildState): this;
  57539. }
  57540. }
  57541. declare module BABYLON {
  57542. /**
  57543. * Block used to get the view direction
  57544. */
  57545. export class ViewDirectionBlock extends NodeMaterialBlock {
  57546. /**
  57547. * Creates a new ViewDirectionBlock
  57548. * @param name defines the block name
  57549. */
  57550. constructor(name: string);
  57551. /**
  57552. * Gets the current class name
  57553. * @returns the class name
  57554. */
  57555. getClassName(): string;
  57556. /**
  57557. * Gets the world position component
  57558. */
  57559. get worldPosition(): NodeMaterialConnectionPoint;
  57560. /**
  57561. * Gets the camera position component
  57562. */
  57563. get cameraPosition(): NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the output component
  57566. */
  57567. get output(): NodeMaterialConnectionPoint;
  57568. autoConfigure(material: NodeMaterial): void;
  57569. protected _buildBlock(state: NodeMaterialBuildState): this;
  57570. }
  57571. }
  57572. declare module BABYLON {
  57573. /**
  57574. * Block used to compute fresnel value
  57575. */
  57576. export class FresnelBlock extends NodeMaterialBlock {
  57577. /**
  57578. * Create a new FresnelBlock
  57579. * @param name defines the block name
  57580. */
  57581. constructor(name: string);
  57582. /**
  57583. * Gets the current class name
  57584. * @returns the class name
  57585. */
  57586. getClassName(): string;
  57587. /**
  57588. * Gets the world normal input component
  57589. */
  57590. get worldNormal(): NodeMaterialConnectionPoint;
  57591. /**
  57592. * Gets the view direction input component
  57593. */
  57594. get viewDirection(): NodeMaterialConnectionPoint;
  57595. /**
  57596. * Gets the bias input component
  57597. */
  57598. get bias(): NodeMaterialConnectionPoint;
  57599. /**
  57600. * Gets the camera (or eye) position component
  57601. */
  57602. get power(): NodeMaterialConnectionPoint;
  57603. /**
  57604. * Gets the fresnel output component
  57605. */
  57606. get fresnel(): NodeMaterialConnectionPoint;
  57607. autoConfigure(material: NodeMaterial): void;
  57608. protected _buildBlock(state: NodeMaterialBuildState): this;
  57609. }
  57610. }
  57611. declare module BABYLON {
  57612. /**
  57613. * Block used to get the max of 2 values
  57614. */
  57615. export class MaxBlock extends NodeMaterialBlock {
  57616. /**
  57617. * Creates a new MaxBlock
  57618. * @param name defines the block name
  57619. */
  57620. constructor(name: string);
  57621. /**
  57622. * Gets the current class name
  57623. * @returns the class name
  57624. */
  57625. getClassName(): string;
  57626. /**
  57627. * Gets the left operand input component
  57628. */
  57629. get left(): NodeMaterialConnectionPoint;
  57630. /**
  57631. * Gets the right operand input component
  57632. */
  57633. get right(): NodeMaterialConnectionPoint;
  57634. /**
  57635. * Gets the output component
  57636. */
  57637. get output(): NodeMaterialConnectionPoint;
  57638. protected _buildBlock(state: NodeMaterialBuildState): this;
  57639. }
  57640. }
  57641. declare module BABYLON {
  57642. /**
  57643. * Block used to get the min of 2 values
  57644. */
  57645. export class MinBlock extends NodeMaterialBlock {
  57646. /**
  57647. * Creates a new MinBlock
  57648. * @param name defines the block name
  57649. */
  57650. constructor(name: string);
  57651. /**
  57652. * Gets the current class name
  57653. * @returns the class name
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Gets the left operand input component
  57658. */
  57659. get left(): NodeMaterialConnectionPoint;
  57660. /**
  57661. * Gets the right operand input component
  57662. */
  57663. get right(): NodeMaterialConnectionPoint;
  57664. /**
  57665. * Gets the output component
  57666. */
  57667. get output(): NodeMaterialConnectionPoint;
  57668. protected _buildBlock(state: NodeMaterialBuildState): this;
  57669. }
  57670. }
  57671. declare module BABYLON {
  57672. /**
  57673. * Block used to get the distance between 2 values
  57674. */
  57675. export class DistanceBlock extends NodeMaterialBlock {
  57676. /**
  57677. * Creates a new DistanceBlock
  57678. * @param name defines the block name
  57679. */
  57680. constructor(name: string);
  57681. /**
  57682. * Gets the current class name
  57683. * @returns the class name
  57684. */
  57685. getClassName(): string;
  57686. /**
  57687. * Gets the left operand input component
  57688. */
  57689. get left(): NodeMaterialConnectionPoint;
  57690. /**
  57691. * Gets the right operand input component
  57692. */
  57693. get right(): NodeMaterialConnectionPoint;
  57694. /**
  57695. * Gets the output component
  57696. */
  57697. get output(): NodeMaterialConnectionPoint;
  57698. protected _buildBlock(state: NodeMaterialBuildState): this;
  57699. }
  57700. }
  57701. declare module BABYLON {
  57702. /**
  57703. * Block used to get the length of a vector
  57704. */
  57705. export class LengthBlock extends NodeMaterialBlock {
  57706. /**
  57707. * Creates a new LengthBlock
  57708. * @param name defines the block name
  57709. */
  57710. constructor(name: string);
  57711. /**
  57712. * Gets the current class name
  57713. * @returns the class name
  57714. */
  57715. getClassName(): string;
  57716. /**
  57717. * Gets the value input component
  57718. */
  57719. get value(): NodeMaterialConnectionPoint;
  57720. /**
  57721. * Gets the output component
  57722. */
  57723. get output(): NodeMaterialConnectionPoint;
  57724. protected _buildBlock(state: NodeMaterialBuildState): this;
  57725. }
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * Block used to get negative version of a value (i.e. x * -1)
  57730. */
  57731. export class NegateBlock extends NodeMaterialBlock {
  57732. /**
  57733. * Creates a new NegateBlock
  57734. * @param name defines the block name
  57735. */
  57736. constructor(name: string);
  57737. /**
  57738. * Gets the current class name
  57739. * @returns the class name
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * Gets the value input component
  57744. */
  57745. get value(): NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the output component
  57748. */
  57749. get output(): NodeMaterialConnectionPoint;
  57750. protected _buildBlock(state: NodeMaterialBuildState): this;
  57751. }
  57752. }
  57753. declare module BABYLON {
  57754. /**
  57755. * Block used to get the value of the first parameter raised to the power of the second
  57756. */
  57757. export class PowBlock extends NodeMaterialBlock {
  57758. /**
  57759. * Creates a new PowBlock
  57760. * @param name defines the block name
  57761. */
  57762. constructor(name: string);
  57763. /**
  57764. * Gets the current class name
  57765. * @returns the class name
  57766. */
  57767. getClassName(): string;
  57768. /**
  57769. * Gets the value operand input component
  57770. */
  57771. get value(): NodeMaterialConnectionPoint;
  57772. /**
  57773. * Gets the power operand input component
  57774. */
  57775. get power(): NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the output component
  57778. */
  57779. get output(): NodeMaterialConnectionPoint;
  57780. protected _buildBlock(state: NodeMaterialBuildState): this;
  57781. }
  57782. }
  57783. declare module BABYLON {
  57784. /**
  57785. * Block used to get a random number
  57786. */
  57787. export class RandomNumberBlock extends NodeMaterialBlock {
  57788. /**
  57789. * Creates a new RandomNumberBlock
  57790. * @param name defines the block name
  57791. */
  57792. constructor(name: string);
  57793. /**
  57794. * Gets the current class name
  57795. * @returns the class name
  57796. */
  57797. getClassName(): string;
  57798. /**
  57799. * Gets the seed input component
  57800. */
  57801. get seed(): NodeMaterialConnectionPoint;
  57802. /**
  57803. * Gets the output component
  57804. */
  57805. get output(): NodeMaterialConnectionPoint;
  57806. protected _buildBlock(state: NodeMaterialBuildState): this;
  57807. }
  57808. }
  57809. declare module BABYLON {
  57810. /**
  57811. * Block used to compute arc tangent of 2 values
  57812. */
  57813. export class ArcTan2Block extends NodeMaterialBlock {
  57814. /**
  57815. * Creates a new ArcTan2Block
  57816. * @param name defines the block name
  57817. */
  57818. constructor(name: string);
  57819. /**
  57820. * Gets the current class name
  57821. * @returns the class name
  57822. */
  57823. getClassName(): string;
  57824. /**
  57825. * Gets the x operand input component
  57826. */
  57827. get x(): NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the y operand input component
  57830. */
  57831. get y(): NodeMaterialConnectionPoint;
  57832. /**
  57833. * Gets the output component
  57834. */
  57835. get output(): NodeMaterialConnectionPoint;
  57836. protected _buildBlock(state: NodeMaterialBuildState): this;
  57837. }
  57838. }
  57839. declare module BABYLON {
  57840. /**
  57841. * Block used to smooth step a value
  57842. */
  57843. export class SmoothStepBlock extends NodeMaterialBlock {
  57844. /**
  57845. * Creates a new SmoothStepBlock
  57846. * @param name defines the block name
  57847. */
  57848. constructor(name: string);
  57849. /**
  57850. * Gets the current class name
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Gets the value operand input component
  57856. */
  57857. get value(): NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the first edge operand input component
  57860. */
  57861. get edge0(): NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the second edge operand input component
  57864. */
  57865. get edge1(): NodeMaterialConnectionPoint;
  57866. /**
  57867. * Gets the output component
  57868. */
  57869. get output(): NodeMaterialConnectionPoint;
  57870. protected _buildBlock(state: NodeMaterialBuildState): this;
  57871. }
  57872. }
  57873. declare module BABYLON {
  57874. /**
  57875. * Block used to get the reciprocal (1 / x) of a value
  57876. */
  57877. export class ReciprocalBlock extends NodeMaterialBlock {
  57878. /**
  57879. * Creates a new ReciprocalBlock
  57880. * @param name defines the block name
  57881. */
  57882. constructor(name: string);
  57883. /**
  57884. * Gets the current class name
  57885. * @returns the class name
  57886. */
  57887. getClassName(): string;
  57888. /**
  57889. * Gets the input component
  57890. */
  57891. get input(): NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the output component
  57894. */
  57895. get output(): NodeMaterialConnectionPoint;
  57896. protected _buildBlock(state: NodeMaterialBuildState): this;
  57897. }
  57898. }
  57899. declare module BABYLON {
  57900. /**
  57901. * Block used to replace a color by another one
  57902. */
  57903. export class ReplaceColorBlock extends NodeMaterialBlock {
  57904. /**
  57905. * Creates a new ReplaceColorBlock
  57906. * @param name defines the block name
  57907. */
  57908. constructor(name: string);
  57909. /**
  57910. * Gets the current class name
  57911. * @returns the class name
  57912. */
  57913. getClassName(): string;
  57914. /**
  57915. * Gets the value input component
  57916. */
  57917. get value(): NodeMaterialConnectionPoint;
  57918. /**
  57919. * Gets the reference input component
  57920. */
  57921. get reference(): NodeMaterialConnectionPoint;
  57922. /**
  57923. * Gets the distance input component
  57924. */
  57925. get distance(): NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the replacement input component
  57928. */
  57929. get replacement(): NodeMaterialConnectionPoint;
  57930. /**
  57931. * Gets the output component
  57932. */
  57933. get output(): NodeMaterialConnectionPoint;
  57934. protected _buildBlock(state: NodeMaterialBuildState): this;
  57935. }
  57936. }
  57937. declare module BABYLON {
  57938. /**
  57939. * Block used to posterize a value
  57940. * @see https://en.wikipedia.org/wiki/Posterization
  57941. */
  57942. export class PosterizeBlock extends NodeMaterialBlock {
  57943. /**
  57944. * Creates a new PosterizeBlock
  57945. * @param name defines the block name
  57946. */
  57947. constructor(name: string);
  57948. /**
  57949. * Gets the current class name
  57950. * @returns the class name
  57951. */
  57952. getClassName(): string;
  57953. /**
  57954. * Gets the value input component
  57955. */
  57956. get value(): NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the steps input component
  57959. */
  57960. get steps(): NodeMaterialConnectionPoint;
  57961. /**
  57962. * Gets the output component
  57963. */
  57964. get output(): NodeMaterialConnectionPoint;
  57965. protected _buildBlock(state: NodeMaterialBuildState): this;
  57966. }
  57967. }
  57968. declare module BABYLON {
  57969. /**
  57970. * Operations supported by the Wave block
  57971. */
  57972. export enum WaveBlockKind {
  57973. /** SawTooth */
  57974. SawTooth = 0,
  57975. /** Square */
  57976. Square = 1,
  57977. /** Triangle */
  57978. Triangle = 2
  57979. }
  57980. /**
  57981. * Block used to apply wave operation to floats
  57982. */
  57983. export class WaveBlock extends NodeMaterialBlock {
  57984. /**
  57985. * Gets or sets the kibnd of wave to be applied by the block
  57986. */
  57987. kind: WaveBlockKind;
  57988. /**
  57989. * Creates a new WaveBlock
  57990. * @param name defines the block name
  57991. */
  57992. constructor(name: string);
  57993. /**
  57994. * Gets the current class name
  57995. * @returns the class name
  57996. */
  57997. getClassName(): string;
  57998. /**
  57999. * Gets the input component
  58000. */
  58001. get input(): NodeMaterialConnectionPoint;
  58002. /**
  58003. * Gets the output component
  58004. */
  58005. get output(): NodeMaterialConnectionPoint;
  58006. protected _buildBlock(state: NodeMaterialBuildState): this;
  58007. serialize(): any;
  58008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58009. }
  58010. }
  58011. declare module BABYLON {
  58012. /**
  58013. * Class used to store a color step for the GradientBlock
  58014. */
  58015. export class GradientBlockColorStep {
  58016. /**
  58017. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58018. */
  58019. step: number;
  58020. /**
  58021. * Gets or sets the color associated with this step
  58022. */
  58023. color: Color3;
  58024. /**
  58025. * Creates a new GradientBlockColorStep
  58026. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58027. * @param color defines the color associated with this step
  58028. */
  58029. constructor(
  58030. /**
  58031. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58032. */
  58033. step: number,
  58034. /**
  58035. * Gets or sets the color associated with this step
  58036. */
  58037. color: Color3);
  58038. }
  58039. /**
  58040. * Block used to return a color from a gradient based on an input value between 0 and 1
  58041. */
  58042. export class GradientBlock extends NodeMaterialBlock {
  58043. /**
  58044. * Gets or sets the list of color steps
  58045. */
  58046. colorSteps: GradientBlockColorStep[];
  58047. /**
  58048. * Creates a new GradientBlock
  58049. * @param name defines the block name
  58050. */
  58051. constructor(name: string);
  58052. /**
  58053. * Gets the current class name
  58054. * @returns the class name
  58055. */
  58056. getClassName(): string;
  58057. /**
  58058. * Gets the gradient input component
  58059. */
  58060. get gradient(): NodeMaterialConnectionPoint;
  58061. /**
  58062. * Gets the output component
  58063. */
  58064. get output(): NodeMaterialConnectionPoint;
  58065. private _writeColorConstant;
  58066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58067. serialize(): any;
  58068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58069. protected _dumpPropertiesCode(): string;
  58070. }
  58071. }
  58072. declare module BABYLON {
  58073. /**
  58074. * Block used to normalize lerp between 2 values
  58075. */
  58076. export class NLerpBlock extends NodeMaterialBlock {
  58077. /**
  58078. * Creates a new NLerpBlock
  58079. * @param name defines the block name
  58080. */
  58081. constructor(name: string);
  58082. /**
  58083. * Gets the current class name
  58084. * @returns the class name
  58085. */
  58086. getClassName(): string;
  58087. /**
  58088. * Gets the left operand input component
  58089. */
  58090. get left(): NodeMaterialConnectionPoint;
  58091. /**
  58092. * Gets the right operand input component
  58093. */
  58094. get right(): NodeMaterialConnectionPoint;
  58095. /**
  58096. * Gets the gradient operand input component
  58097. */
  58098. get gradient(): NodeMaterialConnectionPoint;
  58099. /**
  58100. * Gets the output component
  58101. */
  58102. get output(): NodeMaterialConnectionPoint;
  58103. protected _buildBlock(state: NodeMaterialBuildState): this;
  58104. }
  58105. }
  58106. declare module BABYLON {
  58107. /**
  58108. * block used to Generate a Worley Noise 3D Noise Pattern
  58109. */
  58110. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58111. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58112. manhattanDistance: boolean;
  58113. /**
  58114. * Creates a new WorleyNoise3DBlock
  58115. * @param name defines the block name
  58116. */
  58117. constructor(name: string);
  58118. /**
  58119. * Gets the current class name
  58120. * @returns the class name
  58121. */
  58122. getClassName(): string;
  58123. /**
  58124. * Gets the seed input component
  58125. */
  58126. get seed(): NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the jitter input component
  58129. */
  58130. get jitter(): NodeMaterialConnectionPoint;
  58131. /**
  58132. * Gets the output component
  58133. */
  58134. get output(): NodeMaterialConnectionPoint;
  58135. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58136. /**
  58137. * Exposes the properties to the UI?
  58138. */
  58139. protected _dumpPropertiesCode(): string;
  58140. /**
  58141. * Exposes the properties to the Seralize?
  58142. */
  58143. serialize(): any;
  58144. /**
  58145. * Exposes the properties to the deseralize?
  58146. */
  58147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58148. }
  58149. }
  58150. declare module BABYLON {
  58151. /**
  58152. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58153. */
  58154. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Creates a new SimplexPerlin3DBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the seed operand input component
  58167. */
  58168. get seed(): NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the output component
  58171. */
  58172. get output(): NodeMaterialConnectionPoint;
  58173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58174. }
  58175. }
  58176. declare module BABYLON {
  58177. /**
  58178. * Block used to blend normals
  58179. */
  58180. export class NormalBlendBlock extends NodeMaterialBlock {
  58181. /**
  58182. * Creates a new NormalBlendBlock
  58183. * @param name defines the block name
  58184. */
  58185. constructor(name: string);
  58186. /**
  58187. * Gets the current class name
  58188. * @returns the class name
  58189. */
  58190. getClassName(): string;
  58191. /**
  58192. * Gets the first input component
  58193. */
  58194. get normalMap0(): NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the second input component
  58197. */
  58198. get normalMap1(): NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the output component
  58201. */
  58202. get output(): NodeMaterialConnectionPoint;
  58203. protected _buildBlock(state: NodeMaterialBuildState): this;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. /**
  58208. * Block used to rotate a 2d vector by a given angle
  58209. */
  58210. export class Rotate2dBlock extends NodeMaterialBlock {
  58211. /**
  58212. * Creates a new Rotate2dBlock
  58213. * @param name defines the block name
  58214. */
  58215. constructor(name: string);
  58216. /**
  58217. * Gets the current class name
  58218. * @returns the class name
  58219. */
  58220. getClassName(): string;
  58221. /**
  58222. * Gets the input vector
  58223. */
  58224. get input(): NodeMaterialConnectionPoint;
  58225. /**
  58226. * Gets the input angle
  58227. */
  58228. get angle(): NodeMaterialConnectionPoint;
  58229. /**
  58230. * Gets the output component
  58231. */
  58232. get output(): NodeMaterialConnectionPoint;
  58233. autoConfigure(material: NodeMaterial): void;
  58234. protected _buildBlock(state: NodeMaterialBuildState): this;
  58235. }
  58236. }
  58237. declare module BABYLON {
  58238. /**
  58239. * Block used to get the reflected vector from a direction and a normal
  58240. */
  58241. export class ReflectBlock extends NodeMaterialBlock {
  58242. /**
  58243. * Creates a new ReflectBlock
  58244. * @param name defines the block name
  58245. */
  58246. constructor(name: string);
  58247. /**
  58248. * Gets the current class name
  58249. * @returns the class name
  58250. */
  58251. getClassName(): string;
  58252. /**
  58253. * Gets the incident component
  58254. */
  58255. get incident(): NodeMaterialConnectionPoint;
  58256. /**
  58257. * Gets the normal component
  58258. */
  58259. get normal(): NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the output component
  58262. */
  58263. get output(): NodeMaterialConnectionPoint;
  58264. protected _buildBlock(state: NodeMaterialBuildState): this;
  58265. }
  58266. }
  58267. declare module BABYLON {
  58268. /**
  58269. * Block used to get the refracted vector from a direction and a normal
  58270. */
  58271. export class RefractBlock extends NodeMaterialBlock {
  58272. /**
  58273. * Creates a new RefractBlock
  58274. * @param name defines the block name
  58275. */
  58276. constructor(name: string);
  58277. /**
  58278. * Gets the current class name
  58279. * @returns the class name
  58280. */
  58281. getClassName(): string;
  58282. /**
  58283. * Gets the incident component
  58284. */
  58285. get incident(): NodeMaterialConnectionPoint;
  58286. /**
  58287. * Gets the normal component
  58288. */
  58289. get normal(): NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the index of refraction component
  58292. */
  58293. get ior(): NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the output component
  58296. */
  58297. get output(): NodeMaterialConnectionPoint;
  58298. protected _buildBlock(state: NodeMaterialBuildState): this;
  58299. }
  58300. }
  58301. declare module BABYLON {
  58302. /**
  58303. * Block used to desaturate a color
  58304. */
  58305. export class DesaturateBlock extends NodeMaterialBlock {
  58306. /**
  58307. * Creates a new DesaturateBlock
  58308. * @param name defines the block name
  58309. */
  58310. constructor(name: string);
  58311. /**
  58312. * Gets the current class name
  58313. * @returns the class name
  58314. */
  58315. getClassName(): string;
  58316. /**
  58317. * Gets the color operand input component
  58318. */
  58319. get color(): NodeMaterialConnectionPoint;
  58320. /**
  58321. * Gets the level operand input component
  58322. */
  58323. get level(): NodeMaterialConnectionPoint;
  58324. /**
  58325. * Gets the output component
  58326. */
  58327. get output(): NodeMaterialConnectionPoint;
  58328. protected _buildBlock(state: NodeMaterialBuildState): this;
  58329. }
  58330. }
  58331. declare module BABYLON {
  58332. /**
  58333. * Effect Render Options
  58334. */
  58335. export interface IEffectRendererOptions {
  58336. /**
  58337. * Defines the vertices positions.
  58338. */
  58339. positions?: number[];
  58340. /**
  58341. * Defines the indices.
  58342. */
  58343. indices?: number[];
  58344. }
  58345. /**
  58346. * Helper class to render one or more effects
  58347. */
  58348. export class EffectRenderer {
  58349. private engine;
  58350. private static _DefaultOptions;
  58351. private _vertexBuffers;
  58352. private _indexBuffer;
  58353. private _ringBufferIndex;
  58354. private _ringScreenBuffer;
  58355. private _fullscreenViewport;
  58356. private _getNextFrameBuffer;
  58357. /**
  58358. * Creates an effect renderer
  58359. * @param engine the engine to use for rendering
  58360. * @param options defines the options of the effect renderer
  58361. */
  58362. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58363. /**
  58364. * Sets the current viewport in normalized coordinates 0-1
  58365. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58366. */
  58367. setViewport(viewport?: Viewport): void;
  58368. /**
  58369. * Binds the embedded attributes buffer to the effect.
  58370. * @param effect Defines the effect to bind the attributes for
  58371. */
  58372. bindBuffers(effect: Effect): void;
  58373. /**
  58374. * Sets the current effect wrapper to use during draw.
  58375. * The effect needs to be ready before calling this api.
  58376. * This also sets the default full screen position attribute.
  58377. * @param effectWrapper Defines the effect to draw with
  58378. */
  58379. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58380. /**
  58381. * Draws a full screen quad.
  58382. */
  58383. draw(): void;
  58384. /**
  58385. * renders one or more effects to a specified texture
  58386. * @param effectWrappers list of effects to renderer
  58387. * @param outputTexture texture to draw to, if null it will render to the screen
  58388. */
  58389. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58390. /**
  58391. * Disposes of the effect renderer
  58392. */
  58393. dispose(): void;
  58394. }
  58395. /**
  58396. * Options to create an EffectWrapper
  58397. */
  58398. interface EffectWrapperCreationOptions {
  58399. /**
  58400. * Engine to use to create the effect
  58401. */
  58402. engine: ThinEngine;
  58403. /**
  58404. * Fragment shader for the effect
  58405. */
  58406. fragmentShader: string;
  58407. /**
  58408. * Vertex shader for the effect
  58409. */
  58410. vertexShader?: string;
  58411. /**
  58412. * Attributes to use in the shader
  58413. */
  58414. attributeNames?: Array<string>;
  58415. /**
  58416. * Uniforms to use in the shader
  58417. */
  58418. uniformNames?: Array<string>;
  58419. /**
  58420. * Texture sampler names to use in the shader
  58421. */
  58422. samplerNames?: Array<string>;
  58423. /**
  58424. * The friendly name of the effect displayed in Spector.
  58425. */
  58426. name?: string;
  58427. }
  58428. /**
  58429. * Wraps an effect to be used for rendering
  58430. */
  58431. export class EffectWrapper {
  58432. /**
  58433. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58434. */
  58435. onApplyObservable: Observable<{}>;
  58436. /**
  58437. * The underlying effect
  58438. */
  58439. effect: Effect;
  58440. /**
  58441. * Creates an effect to be renderer
  58442. * @param creationOptions options to create the effect
  58443. */
  58444. constructor(creationOptions: EffectWrapperCreationOptions);
  58445. /**
  58446. * Disposes of the effect wrapper
  58447. */
  58448. dispose(): void;
  58449. }
  58450. }
  58451. declare module BABYLON {
  58452. /**
  58453. * Helper class to push actions to a pool of workers.
  58454. */
  58455. export class WorkerPool implements IDisposable {
  58456. private _workerInfos;
  58457. private _pendingActions;
  58458. /**
  58459. * Constructor
  58460. * @param workers Array of workers to use for actions
  58461. */
  58462. constructor(workers: Array<Worker>);
  58463. /**
  58464. * Terminates all workers and clears any pending actions.
  58465. */
  58466. dispose(): void;
  58467. /**
  58468. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58469. * pended until a worker has completed its action.
  58470. * @param action The action to perform. Call onComplete when the action is complete.
  58471. */
  58472. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58473. private _execute;
  58474. }
  58475. }
  58476. declare module BABYLON {
  58477. /**
  58478. * Configuration for Draco compression
  58479. */
  58480. export interface IDracoCompressionConfiguration {
  58481. /**
  58482. * Configuration for the decoder.
  58483. */
  58484. decoder: {
  58485. /**
  58486. * The url to the WebAssembly module.
  58487. */
  58488. wasmUrl?: string;
  58489. /**
  58490. * The url to the WebAssembly binary.
  58491. */
  58492. wasmBinaryUrl?: string;
  58493. /**
  58494. * The url to the fallback JavaScript module.
  58495. */
  58496. fallbackUrl?: string;
  58497. };
  58498. }
  58499. /**
  58500. * Draco compression (https://google.github.io/draco/)
  58501. *
  58502. * This class wraps the Draco module.
  58503. *
  58504. * **Encoder**
  58505. *
  58506. * The encoder is not currently implemented.
  58507. *
  58508. * **Decoder**
  58509. *
  58510. * 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.
  58511. *
  58512. * To update the configuration, use the following code:
  58513. * ```javascript
  58514. * DracoCompression.Configuration = {
  58515. * decoder: {
  58516. * wasmUrl: "<url to the WebAssembly library>",
  58517. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58518. * fallbackUrl: "<url to the fallback JavaScript library>",
  58519. * }
  58520. * };
  58521. * ```
  58522. *
  58523. * 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.
  58524. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58525. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58526. *
  58527. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58528. * ```javascript
  58529. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58530. * ```
  58531. *
  58532. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58533. */
  58534. export class DracoCompression implements IDisposable {
  58535. private _workerPoolPromise?;
  58536. private _decoderModulePromise?;
  58537. /**
  58538. * The configuration. Defaults to the following urls:
  58539. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58540. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58541. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58542. */
  58543. static Configuration: IDracoCompressionConfiguration;
  58544. /**
  58545. * Returns true if the decoder configuration is available.
  58546. */
  58547. static get DecoderAvailable(): boolean;
  58548. /**
  58549. * Default number of workers to create when creating the draco compression object.
  58550. */
  58551. static DefaultNumWorkers: number;
  58552. private static GetDefaultNumWorkers;
  58553. private static _Default;
  58554. /**
  58555. * Default instance for the draco compression object.
  58556. */
  58557. static get Default(): DracoCompression;
  58558. /**
  58559. * Constructor
  58560. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58561. */
  58562. constructor(numWorkers?: number);
  58563. /**
  58564. * Stop all async operations and release resources.
  58565. */
  58566. dispose(): void;
  58567. /**
  58568. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58569. * @returns a promise that resolves when ready
  58570. */
  58571. whenReadyAsync(): Promise<void>;
  58572. /**
  58573. * Decode Draco compressed mesh data to vertex data.
  58574. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58575. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58576. * @returns A promise that resolves with the decoded vertex data
  58577. */
  58578. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58579. [kind: string]: number;
  58580. }): Promise<VertexData>;
  58581. }
  58582. }
  58583. declare module BABYLON {
  58584. /**
  58585. * Class for building Constructive Solid Geometry
  58586. */
  58587. export class CSG {
  58588. private polygons;
  58589. /**
  58590. * The world matrix
  58591. */
  58592. matrix: Matrix;
  58593. /**
  58594. * Stores the position
  58595. */
  58596. position: Vector3;
  58597. /**
  58598. * Stores the rotation
  58599. */
  58600. rotation: Vector3;
  58601. /**
  58602. * Stores the rotation quaternion
  58603. */
  58604. rotationQuaternion: Nullable<Quaternion>;
  58605. /**
  58606. * Stores the scaling vector
  58607. */
  58608. scaling: Vector3;
  58609. /**
  58610. * Convert the Mesh to CSG
  58611. * @param mesh The Mesh to convert to CSG
  58612. * @returns A new CSG from the Mesh
  58613. */
  58614. static FromMesh(mesh: Mesh): CSG;
  58615. /**
  58616. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58617. * @param polygons Polygons used to construct a CSG solid
  58618. */
  58619. private static FromPolygons;
  58620. /**
  58621. * Clones, or makes a deep copy, of the CSG
  58622. * @returns A new CSG
  58623. */
  58624. clone(): CSG;
  58625. /**
  58626. * Unions this CSG with another CSG
  58627. * @param csg The CSG to union against this CSG
  58628. * @returns The unioned CSG
  58629. */
  58630. union(csg: CSG): CSG;
  58631. /**
  58632. * Unions this CSG with another CSG in place
  58633. * @param csg The CSG to union against this CSG
  58634. */
  58635. unionInPlace(csg: CSG): void;
  58636. /**
  58637. * Subtracts this CSG with another CSG
  58638. * @param csg The CSG to subtract against this CSG
  58639. * @returns A new CSG
  58640. */
  58641. subtract(csg: CSG): CSG;
  58642. /**
  58643. * Subtracts this CSG with another CSG in place
  58644. * @param csg The CSG to subtact against this CSG
  58645. */
  58646. subtractInPlace(csg: CSG): void;
  58647. /**
  58648. * Intersect this CSG with another CSG
  58649. * @param csg The CSG to intersect against this CSG
  58650. * @returns A new CSG
  58651. */
  58652. intersect(csg: CSG): CSG;
  58653. /**
  58654. * Intersects this CSG with another CSG in place
  58655. * @param csg The CSG to intersect against this CSG
  58656. */
  58657. intersectInPlace(csg: CSG): void;
  58658. /**
  58659. * Return a new CSG solid with solid and empty space switched. This solid is
  58660. * not modified.
  58661. * @returns A new CSG solid with solid and empty space switched
  58662. */
  58663. inverse(): CSG;
  58664. /**
  58665. * Inverses the CSG in place
  58666. */
  58667. inverseInPlace(): void;
  58668. /**
  58669. * This is used to keep meshes transformations so they can be restored
  58670. * when we build back a Babylon Mesh
  58671. * NB : All CSG operations are performed in world coordinates
  58672. * @param csg The CSG to copy the transform attributes from
  58673. * @returns This CSG
  58674. */
  58675. copyTransformAttributes(csg: CSG): CSG;
  58676. /**
  58677. * Build Raw mesh from CSG
  58678. * Coordinates here are in world space
  58679. * @param name The name of the mesh geometry
  58680. * @param scene The Scene
  58681. * @param keepSubMeshes Specifies if the submeshes should be kept
  58682. * @returns A new Mesh
  58683. */
  58684. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58685. /**
  58686. * Build Mesh from CSG taking material and transforms into account
  58687. * @param name The name of the Mesh
  58688. * @param material The material of the Mesh
  58689. * @param scene The Scene
  58690. * @param keepSubMeshes Specifies if submeshes should be kept
  58691. * @returns The new Mesh
  58692. */
  58693. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58694. }
  58695. }
  58696. declare module BABYLON {
  58697. /**
  58698. * Class used to create a trail following a mesh
  58699. */
  58700. export class TrailMesh extends Mesh {
  58701. private _generator;
  58702. private _autoStart;
  58703. private _running;
  58704. private _diameter;
  58705. private _length;
  58706. private _sectionPolygonPointsCount;
  58707. private _sectionVectors;
  58708. private _sectionNormalVectors;
  58709. private _beforeRenderObserver;
  58710. /**
  58711. * @constructor
  58712. * @param name The value used by scene.getMeshByName() to do a lookup.
  58713. * @param generator The mesh to generate a trail.
  58714. * @param scene The scene to add this mesh to.
  58715. * @param diameter Diameter of trailing mesh. Default is 1.
  58716. * @param length Length of trailing mesh. Default is 60.
  58717. * @param autoStart Automatically start trailing mesh. Default true.
  58718. */
  58719. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58720. /**
  58721. * "TrailMesh"
  58722. * @returns "TrailMesh"
  58723. */
  58724. getClassName(): string;
  58725. private _createMesh;
  58726. /**
  58727. * Start trailing mesh.
  58728. */
  58729. start(): void;
  58730. /**
  58731. * Stop trailing mesh.
  58732. */
  58733. stop(): void;
  58734. /**
  58735. * Update trailing mesh geometry.
  58736. */
  58737. update(): void;
  58738. /**
  58739. * Returns a new TrailMesh object.
  58740. * @param name is a string, the name given to the new mesh
  58741. * @param newGenerator use new generator object for cloned trail mesh
  58742. * @returns a new mesh
  58743. */
  58744. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58745. /**
  58746. * Serializes this trail mesh
  58747. * @param serializationObject object to write serialization to
  58748. */
  58749. serialize(serializationObject: any): void;
  58750. /**
  58751. * Parses a serialized trail mesh
  58752. * @param parsedMesh the serialized mesh
  58753. * @param scene the scene to create the trail mesh in
  58754. * @returns the created trail mesh
  58755. */
  58756. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58757. }
  58758. }
  58759. declare module BABYLON {
  58760. /**
  58761. * Class containing static functions to help procedurally build meshes
  58762. */
  58763. export class TiledBoxBuilder {
  58764. /**
  58765. * Creates a box mesh
  58766. * 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)
  58767. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58769. * * 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
  58770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58771. * @param name defines the name of the mesh
  58772. * @param options defines the options used to create the mesh
  58773. * @param scene defines the hosting scene
  58774. * @returns the box mesh
  58775. */
  58776. static CreateTiledBox(name: string, options: {
  58777. pattern?: number;
  58778. width?: number;
  58779. height?: number;
  58780. depth?: number;
  58781. tileSize?: number;
  58782. tileWidth?: number;
  58783. tileHeight?: number;
  58784. alignHorizontal?: number;
  58785. alignVertical?: number;
  58786. faceUV?: Vector4[];
  58787. faceColors?: Color4[];
  58788. sideOrientation?: number;
  58789. updatable?: boolean;
  58790. }, scene?: Nullable<Scene>): Mesh;
  58791. }
  58792. }
  58793. declare module BABYLON {
  58794. /**
  58795. * Class containing static functions to help procedurally build meshes
  58796. */
  58797. export class TorusKnotBuilder {
  58798. /**
  58799. * Creates a torus knot mesh
  58800. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58801. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58802. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58803. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58805. * * 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
  58806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58807. * @param name defines the name of the mesh
  58808. * @param options defines the options used to create the mesh
  58809. * @param scene defines the hosting scene
  58810. * @returns the torus knot mesh
  58811. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58812. */
  58813. static CreateTorusKnot(name: string, options: {
  58814. radius?: number;
  58815. tube?: number;
  58816. radialSegments?: number;
  58817. tubularSegments?: number;
  58818. p?: number;
  58819. q?: number;
  58820. updatable?: boolean;
  58821. sideOrientation?: number;
  58822. frontUVs?: Vector4;
  58823. backUVs?: Vector4;
  58824. }, scene: any): Mesh;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /**
  58829. * Polygon
  58830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58831. */
  58832. export class Polygon {
  58833. /**
  58834. * Creates a rectangle
  58835. * @param xmin bottom X coord
  58836. * @param ymin bottom Y coord
  58837. * @param xmax top X coord
  58838. * @param ymax top Y coord
  58839. * @returns points that make the resulting rectation
  58840. */
  58841. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58842. /**
  58843. * Creates a circle
  58844. * @param radius radius of circle
  58845. * @param cx scale in x
  58846. * @param cy scale in y
  58847. * @param numberOfSides number of sides that make up the circle
  58848. * @returns points that make the resulting circle
  58849. */
  58850. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58851. /**
  58852. * Creates a polygon from input string
  58853. * @param input Input polygon data
  58854. * @returns the parsed points
  58855. */
  58856. static Parse(input: string): Vector2[];
  58857. /**
  58858. * Starts building a polygon from x and y coordinates
  58859. * @param x x coordinate
  58860. * @param y y coordinate
  58861. * @returns the started path2
  58862. */
  58863. static StartingAt(x: number, y: number): Path2;
  58864. }
  58865. /**
  58866. * Builds a polygon
  58867. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58868. */
  58869. export class PolygonMeshBuilder {
  58870. private _points;
  58871. private _outlinepoints;
  58872. private _holes;
  58873. private _name;
  58874. private _scene;
  58875. private _epoints;
  58876. private _eholes;
  58877. private _addToepoint;
  58878. /**
  58879. * Babylon reference to the earcut plugin.
  58880. */
  58881. bjsEarcut: any;
  58882. /**
  58883. * Creates a PolygonMeshBuilder
  58884. * @param name name of the builder
  58885. * @param contours Path of the polygon
  58886. * @param scene scene to add to when creating the mesh
  58887. * @param earcutInjection can be used to inject your own earcut reference
  58888. */
  58889. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58890. /**
  58891. * Adds a whole within the polygon
  58892. * @param hole Array of points defining the hole
  58893. * @returns this
  58894. */
  58895. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58896. /**
  58897. * Creates the polygon
  58898. * @param updatable If the mesh should be updatable
  58899. * @param depth The depth of the mesh created
  58900. * @returns the created mesh
  58901. */
  58902. build(updatable?: boolean, depth?: number): Mesh;
  58903. /**
  58904. * Creates the polygon
  58905. * @param depth The depth of the mesh created
  58906. * @returns the created VertexData
  58907. */
  58908. buildVertexData(depth?: number): VertexData;
  58909. /**
  58910. * Adds a side to the polygon
  58911. * @param positions points that make the polygon
  58912. * @param normals normals of the polygon
  58913. * @param uvs uvs of the polygon
  58914. * @param indices indices of the polygon
  58915. * @param bounds bounds of the polygon
  58916. * @param points points of the polygon
  58917. * @param depth depth of the polygon
  58918. * @param flip flip of the polygon
  58919. */
  58920. private addSide;
  58921. }
  58922. }
  58923. declare module BABYLON {
  58924. /**
  58925. * Class containing static functions to help procedurally build meshes
  58926. */
  58927. export class PolygonBuilder {
  58928. /**
  58929. * Creates a polygon mesh
  58930. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58931. * * 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
  58932. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58934. * * 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)
  58935. * * Remember you can only change the shape positions, not their number when updating a polygon
  58936. * @param name defines the name of the mesh
  58937. * @param options defines the options used to create the mesh
  58938. * @param scene defines the hosting scene
  58939. * @param earcutInjection can be used to inject your own earcut reference
  58940. * @returns the polygon mesh
  58941. */
  58942. static CreatePolygon(name: string, options: {
  58943. shape: Vector3[];
  58944. holes?: Vector3[][];
  58945. depth?: number;
  58946. faceUV?: Vector4[];
  58947. faceColors?: Color4[];
  58948. updatable?: boolean;
  58949. sideOrientation?: number;
  58950. frontUVs?: Vector4;
  58951. backUVs?: Vector4;
  58952. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58953. /**
  58954. * Creates an extruded polygon mesh, with depth in the Y direction.
  58955. * * 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)
  58956. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58957. * @param name defines the name of the mesh
  58958. * @param options defines the options used to create the mesh
  58959. * @param scene defines the hosting scene
  58960. * @param earcutInjection can be used to inject your own earcut reference
  58961. * @returns the polygon mesh
  58962. */
  58963. static ExtrudePolygon(name: string, options: {
  58964. shape: Vector3[];
  58965. holes?: Vector3[][];
  58966. depth?: number;
  58967. faceUV?: Vector4[];
  58968. faceColors?: Color4[];
  58969. updatable?: boolean;
  58970. sideOrientation?: number;
  58971. frontUVs?: Vector4;
  58972. backUVs?: Vector4;
  58973. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58974. }
  58975. }
  58976. declare module BABYLON {
  58977. /**
  58978. * Class containing static functions to help procedurally build meshes
  58979. */
  58980. export class LatheBuilder {
  58981. /**
  58982. * Creates lathe mesh.
  58983. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58984. * * 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
  58985. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58986. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58987. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58988. * * 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
  58989. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58990. * * 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
  58991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58992. * * 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
  58993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58995. * @param name defines the name of the mesh
  58996. * @param options defines the options used to create the mesh
  58997. * @param scene defines the hosting scene
  58998. * @returns the lathe mesh
  58999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59000. */
  59001. static CreateLathe(name: string, options: {
  59002. shape: Vector3[];
  59003. radius?: number;
  59004. tessellation?: number;
  59005. clip?: number;
  59006. arc?: number;
  59007. closed?: boolean;
  59008. updatable?: boolean;
  59009. sideOrientation?: number;
  59010. frontUVs?: Vector4;
  59011. backUVs?: Vector4;
  59012. cap?: number;
  59013. invertUV?: boolean;
  59014. }, scene?: Nullable<Scene>): Mesh;
  59015. }
  59016. }
  59017. declare module BABYLON {
  59018. /**
  59019. * Class containing static functions to help procedurally build meshes
  59020. */
  59021. export class TiledPlaneBuilder {
  59022. /**
  59023. * Creates a tiled plane mesh
  59024. * * The parameter `pattern` will, depending on value, do nothing or
  59025. * * * flip (reflect about central vertical) alternate tiles across and up
  59026. * * * flip every tile on alternate rows
  59027. * * * rotate (180 degs) alternate tiles across and up
  59028. * * * rotate every tile on alternate rows
  59029. * * * flip and rotate alternate tiles across and up
  59030. * * * flip and rotate every tile on alternate rows
  59031. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59032. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59033. * * 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
  59034. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59035. * * 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)
  59036. * * 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)
  59037. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59038. * @param name defines the name of the mesh
  59039. * @param options defines the options used to create the mesh
  59040. * @param scene defines the hosting scene
  59041. * @returns the box mesh
  59042. */
  59043. static CreateTiledPlane(name: string, options: {
  59044. pattern?: number;
  59045. tileSize?: number;
  59046. tileWidth?: number;
  59047. tileHeight?: number;
  59048. size?: number;
  59049. width?: number;
  59050. height?: number;
  59051. alignHorizontal?: number;
  59052. alignVertical?: number;
  59053. sideOrientation?: number;
  59054. frontUVs?: Vector4;
  59055. backUVs?: Vector4;
  59056. updatable?: boolean;
  59057. }, scene?: Nullable<Scene>): Mesh;
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /**
  59062. * Class containing static functions to help procedurally build meshes
  59063. */
  59064. export class TubeBuilder {
  59065. /**
  59066. * Creates a tube mesh.
  59067. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59068. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59069. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59070. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59071. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59072. * * 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)
  59073. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59074. * * 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
  59075. * * 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
  59076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59077. * * 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
  59078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59080. * @param name defines the name of the mesh
  59081. * @param options defines the options used to create the mesh
  59082. * @param scene defines the hosting scene
  59083. * @returns the tube mesh
  59084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59085. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59086. */
  59087. static CreateTube(name: string, options: {
  59088. path: Vector3[];
  59089. radius?: number;
  59090. tessellation?: number;
  59091. radiusFunction?: {
  59092. (i: number, distance: number): number;
  59093. };
  59094. cap?: number;
  59095. arc?: number;
  59096. updatable?: boolean;
  59097. sideOrientation?: number;
  59098. frontUVs?: Vector4;
  59099. backUVs?: Vector4;
  59100. instance?: Mesh;
  59101. invertUV?: boolean;
  59102. }, scene?: Nullable<Scene>): Mesh;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Class containing static functions to help procedurally build meshes
  59108. */
  59109. export class IcoSphereBuilder {
  59110. /**
  59111. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59112. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59113. * * 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`)
  59114. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59115. * * 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
  59116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59117. * * 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
  59118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59119. * @param name defines the name of the mesh
  59120. * @param options defines the options used to create the mesh
  59121. * @param scene defines the hosting scene
  59122. * @returns the icosahedron mesh
  59123. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59124. */
  59125. static CreateIcoSphere(name: string, options: {
  59126. radius?: number;
  59127. radiusX?: number;
  59128. radiusY?: number;
  59129. radiusZ?: number;
  59130. flat?: boolean;
  59131. subdivisions?: number;
  59132. sideOrientation?: number;
  59133. frontUVs?: Vector4;
  59134. backUVs?: Vector4;
  59135. updatable?: boolean;
  59136. }, scene?: Nullable<Scene>): Mesh;
  59137. }
  59138. }
  59139. declare module BABYLON {
  59140. /**
  59141. * Class containing static functions to help procedurally build meshes
  59142. */
  59143. export class DecalBuilder {
  59144. /**
  59145. * Creates a decal mesh.
  59146. * 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
  59147. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59148. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59149. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59150. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59151. * @param name defines the name of the mesh
  59152. * @param sourceMesh defines the mesh where the decal must be applied
  59153. * @param options defines the options used to create the mesh
  59154. * @param scene defines the hosting scene
  59155. * @returns the decal mesh
  59156. * @see https://doc.babylonjs.com/how_to/decals
  59157. */
  59158. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59159. position?: Vector3;
  59160. normal?: Vector3;
  59161. size?: Vector3;
  59162. angle?: number;
  59163. }): Mesh;
  59164. }
  59165. }
  59166. declare module BABYLON {
  59167. /**
  59168. * Class containing static functions to help procedurally build meshes
  59169. */
  59170. export class MeshBuilder {
  59171. /**
  59172. * Creates a box mesh
  59173. * * The parameter `size` sets the size (float) of each box side (default 1)
  59174. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59175. * * 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)
  59176. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59178. * * 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
  59179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59180. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59181. * @param name defines the name of the mesh
  59182. * @param options defines the options used to create the mesh
  59183. * @param scene defines the hosting scene
  59184. * @returns the box mesh
  59185. */
  59186. static CreateBox(name: string, options: {
  59187. size?: number;
  59188. width?: number;
  59189. height?: number;
  59190. depth?: number;
  59191. faceUV?: Vector4[];
  59192. faceColors?: Color4[];
  59193. sideOrientation?: number;
  59194. frontUVs?: Vector4;
  59195. backUVs?: Vector4;
  59196. updatable?: boolean;
  59197. }, scene?: Nullable<Scene>): Mesh;
  59198. /**
  59199. * Creates a tiled box mesh
  59200. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59202. * @param name defines the name of the mesh
  59203. * @param options defines the options used to create the mesh
  59204. * @param scene defines the hosting scene
  59205. * @returns the tiled box mesh
  59206. */
  59207. static CreateTiledBox(name: string, options: {
  59208. pattern?: number;
  59209. size?: number;
  59210. width?: number;
  59211. height?: number;
  59212. depth: number;
  59213. tileSize?: number;
  59214. tileWidth?: number;
  59215. tileHeight?: number;
  59216. faceUV?: Vector4[];
  59217. faceColors?: Color4[];
  59218. alignHorizontal?: number;
  59219. alignVertical?: number;
  59220. sideOrientation?: number;
  59221. updatable?: boolean;
  59222. }, scene?: Nullable<Scene>): Mesh;
  59223. /**
  59224. * Creates a sphere mesh
  59225. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59226. * * 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`)
  59227. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59228. * * 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
  59229. * * 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)
  59230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59231. * * 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
  59232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59233. * @param name defines the name of the mesh
  59234. * @param options defines the options used to create the mesh
  59235. * @param scene defines the hosting scene
  59236. * @returns the sphere mesh
  59237. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59238. */
  59239. static CreateSphere(name: string, options: {
  59240. segments?: number;
  59241. diameter?: number;
  59242. diameterX?: number;
  59243. diameterY?: number;
  59244. diameterZ?: number;
  59245. arc?: number;
  59246. slice?: number;
  59247. sideOrientation?: number;
  59248. frontUVs?: Vector4;
  59249. backUVs?: Vector4;
  59250. updatable?: boolean;
  59251. }, scene?: Nullable<Scene>): Mesh;
  59252. /**
  59253. * Creates a plane polygonal mesh. By default, this is a disc
  59254. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59255. * * 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
  59256. * * 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
  59257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59258. * * 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
  59259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59260. * @param name defines the name of the mesh
  59261. * @param options defines the options used to create the mesh
  59262. * @param scene defines the hosting scene
  59263. * @returns the plane polygonal mesh
  59264. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59265. */
  59266. static CreateDisc(name: string, options: {
  59267. radius?: number;
  59268. tessellation?: number;
  59269. arc?: number;
  59270. updatable?: boolean;
  59271. sideOrientation?: number;
  59272. frontUVs?: Vector4;
  59273. backUVs?: Vector4;
  59274. }, scene?: Nullable<Scene>): Mesh;
  59275. /**
  59276. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59277. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59278. * * 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`)
  59279. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59280. * * 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
  59281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59282. * * 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
  59283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59284. * @param name defines the name of the mesh
  59285. * @param options defines the options used to create the mesh
  59286. * @param scene defines the hosting scene
  59287. * @returns the icosahedron mesh
  59288. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59289. */
  59290. static CreateIcoSphere(name: string, options: {
  59291. radius?: number;
  59292. radiusX?: number;
  59293. radiusY?: number;
  59294. radiusZ?: number;
  59295. flat?: boolean;
  59296. subdivisions?: number;
  59297. sideOrientation?: number;
  59298. frontUVs?: Vector4;
  59299. backUVs?: Vector4;
  59300. updatable?: boolean;
  59301. }, scene?: Nullable<Scene>): Mesh;
  59302. /**
  59303. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59304. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59305. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59306. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59307. * * 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
  59308. * * 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
  59309. * * 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
  59310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59311. * * 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
  59312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59313. * * 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
  59314. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59315. * * 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
  59316. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59318. * @param name defines the name of the mesh
  59319. * @param options defines the options used to create the mesh
  59320. * @param scene defines the hosting scene
  59321. * @returns the ribbon mesh
  59322. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59324. */
  59325. static CreateRibbon(name: string, options: {
  59326. pathArray: Vector3[][];
  59327. closeArray?: boolean;
  59328. closePath?: boolean;
  59329. offset?: number;
  59330. updatable?: boolean;
  59331. sideOrientation?: number;
  59332. frontUVs?: Vector4;
  59333. backUVs?: Vector4;
  59334. instance?: Mesh;
  59335. invertUV?: boolean;
  59336. uvs?: Vector2[];
  59337. colors?: Color4[];
  59338. }, scene?: Nullable<Scene>): Mesh;
  59339. /**
  59340. * Creates a cylinder or a cone mesh
  59341. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59342. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59343. * * 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.
  59344. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59345. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59346. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59347. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59348. * * 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).
  59349. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59350. * * 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).
  59351. * * 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
  59352. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59353. * * 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
  59354. * * 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.
  59355. * * If `enclose` is false, a ring surface is one element.
  59356. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59357. * * 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
  59358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59359. * * 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
  59360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59361. * @param name defines the name of the mesh
  59362. * @param options defines the options used to create the mesh
  59363. * @param scene defines the hosting scene
  59364. * @returns the cylinder mesh
  59365. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59366. */
  59367. static CreateCylinder(name: string, options: {
  59368. height?: number;
  59369. diameterTop?: number;
  59370. diameterBottom?: number;
  59371. diameter?: number;
  59372. tessellation?: number;
  59373. subdivisions?: number;
  59374. arc?: number;
  59375. faceColors?: Color4[];
  59376. faceUV?: Vector4[];
  59377. updatable?: boolean;
  59378. hasRings?: boolean;
  59379. enclose?: boolean;
  59380. cap?: number;
  59381. sideOrientation?: number;
  59382. frontUVs?: Vector4;
  59383. backUVs?: Vector4;
  59384. }, scene?: Nullable<Scene>): Mesh;
  59385. /**
  59386. * Creates a torus mesh
  59387. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59388. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59389. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59391. * * 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
  59392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59393. * @param name defines the name of the mesh
  59394. * @param options defines the options used to create the mesh
  59395. * @param scene defines the hosting scene
  59396. * @returns the torus mesh
  59397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59398. */
  59399. static CreateTorus(name: string, options: {
  59400. diameter?: number;
  59401. thickness?: number;
  59402. tessellation?: number;
  59403. updatable?: boolean;
  59404. sideOrientation?: number;
  59405. frontUVs?: Vector4;
  59406. backUVs?: Vector4;
  59407. }, scene?: Nullable<Scene>): Mesh;
  59408. /**
  59409. * Creates a torus knot mesh
  59410. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59411. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59412. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59413. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59415. * * 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
  59416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59417. * @param name defines the name of the mesh
  59418. * @param options defines the options used to create the mesh
  59419. * @param scene defines the hosting scene
  59420. * @returns the torus knot mesh
  59421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59422. */
  59423. static CreateTorusKnot(name: string, options: {
  59424. radius?: number;
  59425. tube?: number;
  59426. radialSegments?: number;
  59427. tubularSegments?: number;
  59428. p?: number;
  59429. q?: number;
  59430. updatable?: boolean;
  59431. sideOrientation?: number;
  59432. frontUVs?: Vector4;
  59433. backUVs?: Vector4;
  59434. }, scene?: Nullable<Scene>): Mesh;
  59435. /**
  59436. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59437. * * 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
  59438. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59439. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59440. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59441. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59442. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59443. * * 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
  59444. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59447. * @param name defines the name of the new line system
  59448. * @param options defines the options used to create the line system
  59449. * @param scene defines the hosting scene
  59450. * @returns a new line system mesh
  59451. */
  59452. static CreateLineSystem(name: string, options: {
  59453. lines: Vector3[][];
  59454. updatable?: boolean;
  59455. instance?: Nullable<LinesMesh>;
  59456. colors?: Nullable<Color4[][]>;
  59457. useVertexAlpha?: boolean;
  59458. }, scene: Nullable<Scene>): LinesMesh;
  59459. /**
  59460. * Creates a line mesh
  59461. * 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
  59462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59463. * * The parameter `points` is an array successive Vector3
  59464. * * 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
  59465. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59467. * * When updating an instance, remember that only point positions can change, not the number of points
  59468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59470. * @param name defines the name of the new line system
  59471. * @param options defines the options used to create the line system
  59472. * @param scene defines the hosting scene
  59473. * @returns a new line mesh
  59474. */
  59475. static CreateLines(name: string, options: {
  59476. points: Vector3[];
  59477. updatable?: boolean;
  59478. instance?: Nullable<LinesMesh>;
  59479. colors?: Color4[];
  59480. useVertexAlpha?: boolean;
  59481. }, scene?: Nullable<Scene>): LinesMesh;
  59482. /**
  59483. * Creates a dashed line mesh
  59484. * * 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
  59485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59486. * * The parameter `points` is an array successive Vector3
  59487. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59488. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59489. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59490. * * 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
  59491. * * When updating an instance, remember that only point positions can change, not the number of points
  59492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59493. * @param name defines the name of the mesh
  59494. * @param options defines the options used to create the mesh
  59495. * @param scene defines the hosting scene
  59496. * @returns the dashed line mesh
  59497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59498. */
  59499. static CreateDashedLines(name: string, options: {
  59500. points: Vector3[];
  59501. dashSize?: number;
  59502. gapSize?: number;
  59503. dashNb?: number;
  59504. updatable?: boolean;
  59505. instance?: LinesMesh;
  59506. }, scene?: Nullable<Scene>): LinesMesh;
  59507. /**
  59508. * 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.
  59509. * * 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.
  59510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59511. * * 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.
  59512. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59513. * * 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
  59514. * * 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
  59515. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59517. * * 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
  59518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59520. * @param name defines the name of the mesh
  59521. * @param options defines the options used to create the mesh
  59522. * @param scene defines the hosting scene
  59523. * @returns the extruded shape mesh
  59524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59526. */
  59527. static ExtrudeShape(name: string, options: {
  59528. shape: Vector3[];
  59529. path: Vector3[];
  59530. scale?: number;
  59531. rotation?: number;
  59532. cap?: number;
  59533. updatable?: boolean;
  59534. sideOrientation?: number;
  59535. frontUVs?: Vector4;
  59536. backUVs?: Vector4;
  59537. instance?: Mesh;
  59538. invertUV?: boolean;
  59539. }, scene?: Nullable<Scene>): Mesh;
  59540. /**
  59541. * Creates an custom extruded shape mesh.
  59542. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59543. * * 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.
  59544. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59545. * * 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
  59546. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59547. * * 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
  59548. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59549. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59550. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59551. * * 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
  59552. * * 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
  59553. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59555. * * 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
  59556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59558. * @param name defines the name of the mesh
  59559. * @param options defines the options used to create the mesh
  59560. * @param scene defines the hosting scene
  59561. * @returns the custom extruded shape mesh
  59562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59565. */
  59566. static ExtrudeShapeCustom(name: string, options: {
  59567. shape: Vector3[];
  59568. path: Vector3[];
  59569. scaleFunction?: any;
  59570. rotationFunction?: any;
  59571. ribbonCloseArray?: boolean;
  59572. ribbonClosePath?: boolean;
  59573. cap?: number;
  59574. updatable?: boolean;
  59575. sideOrientation?: number;
  59576. frontUVs?: Vector4;
  59577. backUVs?: Vector4;
  59578. instance?: Mesh;
  59579. invertUV?: boolean;
  59580. }, scene?: Nullable<Scene>): Mesh;
  59581. /**
  59582. * Creates lathe mesh.
  59583. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59584. * * 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
  59585. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59586. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59587. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59588. * * 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
  59589. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59590. * * 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
  59591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59592. * * 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
  59593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59595. * @param name defines the name of the mesh
  59596. * @param options defines the options used to create the mesh
  59597. * @param scene defines the hosting scene
  59598. * @returns the lathe mesh
  59599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59600. */
  59601. static CreateLathe(name: string, options: {
  59602. shape: Vector3[];
  59603. radius?: number;
  59604. tessellation?: number;
  59605. clip?: number;
  59606. arc?: number;
  59607. closed?: boolean;
  59608. updatable?: boolean;
  59609. sideOrientation?: number;
  59610. frontUVs?: Vector4;
  59611. backUVs?: Vector4;
  59612. cap?: number;
  59613. invertUV?: boolean;
  59614. }, scene?: Nullable<Scene>): Mesh;
  59615. /**
  59616. * Creates a tiled plane mesh
  59617. * * You can set a limited pattern arrangement with the tiles
  59618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59619. * * 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
  59620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59621. * @param name defines the name of the mesh
  59622. * @param options defines the options used to create the mesh
  59623. * @param scene defines the hosting scene
  59624. * @returns the plane mesh
  59625. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59626. */
  59627. static CreateTiledPlane(name: string, options: {
  59628. pattern?: number;
  59629. tileSize?: number;
  59630. tileWidth?: number;
  59631. tileHeight?: number;
  59632. size?: number;
  59633. width?: number;
  59634. height?: number;
  59635. alignHorizontal?: number;
  59636. alignVertical?: number;
  59637. sideOrientation?: number;
  59638. frontUVs?: Vector4;
  59639. backUVs?: Vector4;
  59640. updatable?: boolean;
  59641. }, scene?: Nullable<Scene>): Mesh;
  59642. /**
  59643. * Creates a plane mesh
  59644. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59645. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59646. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59648. * * 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
  59649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59650. * @param name defines the name of the mesh
  59651. * @param options defines the options used to create the mesh
  59652. * @param scene defines the hosting scene
  59653. * @returns the plane mesh
  59654. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59655. */
  59656. static CreatePlane(name: string, options: {
  59657. size?: number;
  59658. width?: number;
  59659. height?: number;
  59660. sideOrientation?: number;
  59661. frontUVs?: Vector4;
  59662. backUVs?: Vector4;
  59663. updatable?: boolean;
  59664. sourcePlane?: Plane;
  59665. }, scene?: Nullable<Scene>): Mesh;
  59666. /**
  59667. * Creates a ground mesh
  59668. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59669. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59671. * @param name defines the name of the mesh
  59672. * @param options defines the options used to create the mesh
  59673. * @param scene defines the hosting scene
  59674. * @returns the ground mesh
  59675. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59676. */
  59677. static CreateGround(name: string, options: {
  59678. width?: number;
  59679. height?: number;
  59680. subdivisions?: number;
  59681. subdivisionsX?: number;
  59682. subdivisionsY?: number;
  59683. updatable?: boolean;
  59684. }, scene?: Nullable<Scene>): Mesh;
  59685. /**
  59686. * Creates a tiled ground mesh
  59687. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59688. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59689. * * 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
  59690. * * 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
  59691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59692. * @param name defines the name of the mesh
  59693. * @param options defines the options used to create the mesh
  59694. * @param scene defines the hosting scene
  59695. * @returns the tiled ground mesh
  59696. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59697. */
  59698. static CreateTiledGround(name: string, options: {
  59699. xmin: number;
  59700. zmin: number;
  59701. xmax: number;
  59702. zmax: number;
  59703. subdivisions?: {
  59704. w: number;
  59705. h: number;
  59706. };
  59707. precision?: {
  59708. w: number;
  59709. h: number;
  59710. };
  59711. updatable?: boolean;
  59712. }, scene?: Nullable<Scene>): Mesh;
  59713. /**
  59714. * Creates a ground mesh from a height map
  59715. * * The parameter `url` sets the URL of the height map image resource.
  59716. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59717. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59718. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59719. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59720. * * 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.
  59721. * * 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).
  59722. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59724. * @param name defines the name of the mesh
  59725. * @param url defines the url to the height map
  59726. * @param options defines the options used to create the mesh
  59727. * @param scene defines the hosting scene
  59728. * @returns the ground mesh
  59729. * @see https://doc.babylonjs.com/babylon101/height_map
  59730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59731. */
  59732. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59733. width?: number;
  59734. height?: number;
  59735. subdivisions?: number;
  59736. minHeight?: number;
  59737. maxHeight?: number;
  59738. colorFilter?: Color3;
  59739. alphaFilter?: number;
  59740. updatable?: boolean;
  59741. onReady?: (mesh: GroundMesh) => void;
  59742. }, scene?: Nullable<Scene>): GroundMesh;
  59743. /**
  59744. * Creates a polygon mesh
  59745. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59746. * * 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
  59747. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59749. * * 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)
  59750. * * Remember you can only change the shape positions, not their number when updating a polygon
  59751. * @param name defines the name of the mesh
  59752. * @param options defines the options used to create the mesh
  59753. * @param scene defines the hosting scene
  59754. * @param earcutInjection can be used to inject your own earcut reference
  59755. * @returns the polygon mesh
  59756. */
  59757. static CreatePolygon(name: string, options: {
  59758. shape: Vector3[];
  59759. holes?: Vector3[][];
  59760. depth?: number;
  59761. faceUV?: Vector4[];
  59762. faceColors?: Color4[];
  59763. updatable?: boolean;
  59764. sideOrientation?: number;
  59765. frontUVs?: Vector4;
  59766. backUVs?: Vector4;
  59767. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59768. /**
  59769. * Creates an extruded polygon mesh, with depth in the Y direction.
  59770. * * 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)
  59771. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59772. * @param name defines the name of the mesh
  59773. * @param options defines the options used to create the mesh
  59774. * @param scene defines the hosting scene
  59775. * @param earcutInjection can be used to inject your own earcut reference
  59776. * @returns the polygon mesh
  59777. */
  59778. static ExtrudePolygon(name: string, options: {
  59779. shape: Vector3[];
  59780. holes?: Vector3[][];
  59781. depth?: number;
  59782. faceUV?: Vector4[];
  59783. faceColors?: Color4[];
  59784. updatable?: boolean;
  59785. sideOrientation?: number;
  59786. frontUVs?: Vector4;
  59787. backUVs?: Vector4;
  59788. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59789. /**
  59790. * Creates a tube mesh.
  59791. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59792. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59793. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59794. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59795. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59796. * * 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)
  59797. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59798. * * 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
  59799. * * 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
  59800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59801. * * 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
  59802. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59804. * @param name defines the name of the mesh
  59805. * @param options defines the options used to create the mesh
  59806. * @param scene defines the hosting scene
  59807. * @returns the tube mesh
  59808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59809. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59810. */
  59811. static CreateTube(name: string, options: {
  59812. path: Vector3[];
  59813. radius?: number;
  59814. tessellation?: number;
  59815. radiusFunction?: {
  59816. (i: number, distance: number): number;
  59817. };
  59818. cap?: number;
  59819. arc?: number;
  59820. updatable?: boolean;
  59821. sideOrientation?: number;
  59822. frontUVs?: Vector4;
  59823. backUVs?: Vector4;
  59824. instance?: Mesh;
  59825. invertUV?: boolean;
  59826. }, scene?: Nullable<Scene>): Mesh;
  59827. /**
  59828. * Creates a polyhedron mesh
  59829. * * 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
  59830. * * The parameter `size` (positive float, default 1) sets the polygon size
  59831. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59832. * * 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`
  59833. * * 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
  59834. * * 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)`)
  59835. * * 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
  59836. * * 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
  59837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59838. * * 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
  59839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59840. * @param name defines the name of the mesh
  59841. * @param options defines the options used to create the mesh
  59842. * @param scene defines the hosting scene
  59843. * @returns the polyhedron mesh
  59844. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59845. */
  59846. static CreatePolyhedron(name: string, options: {
  59847. type?: number;
  59848. size?: number;
  59849. sizeX?: number;
  59850. sizeY?: number;
  59851. sizeZ?: number;
  59852. custom?: any;
  59853. faceUV?: Vector4[];
  59854. faceColors?: Color4[];
  59855. flat?: boolean;
  59856. updatable?: boolean;
  59857. sideOrientation?: number;
  59858. frontUVs?: Vector4;
  59859. backUVs?: Vector4;
  59860. }, scene?: Nullable<Scene>): Mesh;
  59861. /**
  59862. * Creates a decal mesh.
  59863. * 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
  59864. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59865. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59866. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59867. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59868. * @param name defines the name of the mesh
  59869. * @param sourceMesh defines the mesh where the decal must be applied
  59870. * @param options defines the options used to create the mesh
  59871. * @param scene defines the hosting scene
  59872. * @returns the decal mesh
  59873. * @see https://doc.babylonjs.com/how_to/decals
  59874. */
  59875. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59876. position?: Vector3;
  59877. normal?: Vector3;
  59878. size?: Vector3;
  59879. angle?: number;
  59880. }): Mesh;
  59881. }
  59882. }
  59883. declare module BABYLON {
  59884. /**
  59885. * A simplifier interface for future simplification implementations
  59886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59887. */
  59888. export interface ISimplifier {
  59889. /**
  59890. * Simplification of a given mesh according to the given settings.
  59891. * Since this requires computation, it is assumed that the function runs async.
  59892. * @param settings The settings of the simplification, including quality and distance
  59893. * @param successCallback A callback that will be called after the mesh was simplified.
  59894. * @param errorCallback in case of an error, this callback will be called. optional.
  59895. */
  59896. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59897. }
  59898. /**
  59899. * Expected simplification settings.
  59900. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59902. */
  59903. export interface ISimplificationSettings {
  59904. /**
  59905. * Gets or sets the expected quality
  59906. */
  59907. quality: number;
  59908. /**
  59909. * Gets or sets the distance when this optimized version should be used
  59910. */
  59911. distance: number;
  59912. /**
  59913. * Gets an already optimized mesh
  59914. */
  59915. optimizeMesh?: boolean;
  59916. }
  59917. /**
  59918. * Class used to specify simplification options
  59919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59920. */
  59921. export class SimplificationSettings implements ISimplificationSettings {
  59922. /** expected quality */
  59923. quality: number;
  59924. /** distance when this optimized version should be used */
  59925. distance: number;
  59926. /** already optimized mesh */
  59927. optimizeMesh?: boolean | undefined;
  59928. /**
  59929. * Creates a SimplificationSettings
  59930. * @param quality expected quality
  59931. * @param distance distance when this optimized version should be used
  59932. * @param optimizeMesh already optimized mesh
  59933. */
  59934. constructor(
  59935. /** expected quality */
  59936. quality: number,
  59937. /** distance when this optimized version should be used */
  59938. distance: number,
  59939. /** already optimized mesh */
  59940. optimizeMesh?: boolean | undefined);
  59941. }
  59942. /**
  59943. * Interface used to define a simplification task
  59944. */
  59945. export interface ISimplificationTask {
  59946. /**
  59947. * Array of settings
  59948. */
  59949. settings: Array<ISimplificationSettings>;
  59950. /**
  59951. * Simplification type
  59952. */
  59953. simplificationType: SimplificationType;
  59954. /**
  59955. * Mesh to simplify
  59956. */
  59957. mesh: Mesh;
  59958. /**
  59959. * Callback called on success
  59960. */
  59961. successCallback?: () => void;
  59962. /**
  59963. * Defines if parallel processing can be used
  59964. */
  59965. parallelProcessing: boolean;
  59966. }
  59967. /**
  59968. * Queue used to order the simplification tasks
  59969. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59970. */
  59971. export class SimplificationQueue {
  59972. private _simplificationArray;
  59973. /**
  59974. * Gets a boolean indicating that the process is still running
  59975. */
  59976. running: boolean;
  59977. /**
  59978. * Creates a new queue
  59979. */
  59980. constructor();
  59981. /**
  59982. * Adds a new simplification task
  59983. * @param task defines a task to add
  59984. */
  59985. addTask(task: ISimplificationTask): void;
  59986. /**
  59987. * Execute next task
  59988. */
  59989. executeNext(): void;
  59990. /**
  59991. * Execute a simplification task
  59992. * @param task defines the task to run
  59993. */
  59994. runSimplification(task: ISimplificationTask): void;
  59995. private getSimplifier;
  59996. }
  59997. /**
  59998. * The implemented types of simplification
  59999. * At the moment only Quadratic Error Decimation is implemented
  60000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60001. */
  60002. export enum SimplificationType {
  60003. /** Quadratic error decimation */
  60004. QUADRATIC = 0
  60005. }
  60006. }
  60007. declare module BABYLON {
  60008. interface Scene {
  60009. /** @hidden (Backing field) */
  60010. _simplificationQueue: SimplificationQueue;
  60011. /**
  60012. * Gets or sets the simplification queue attached to the scene
  60013. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60014. */
  60015. simplificationQueue: SimplificationQueue;
  60016. }
  60017. interface Mesh {
  60018. /**
  60019. * Simplify the mesh according to the given array of settings.
  60020. * Function will return immediately and will simplify async
  60021. * @param settings a collection of simplification settings
  60022. * @param parallelProcessing should all levels calculate parallel or one after the other
  60023. * @param simplificationType the type of simplification to run
  60024. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60025. * @returns the current mesh
  60026. */
  60027. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60028. }
  60029. /**
  60030. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60031. * created in a scene
  60032. */
  60033. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60034. /**
  60035. * The component name helpfull to identify the component in the list of scene components.
  60036. */
  60037. readonly name: string;
  60038. /**
  60039. * The scene the component belongs to.
  60040. */
  60041. scene: Scene;
  60042. /**
  60043. * Creates a new instance of the component for the given scene
  60044. * @param scene Defines the scene to register the component in
  60045. */
  60046. constructor(scene: Scene);
  60047. /**
  60048. * Registers the component in a given scene
  60049. */
  60050. register(): void;
  60051. /**
  60052. * Rebuilds the elements related to this component in case of
  60053. * context lost for instance.
  60054. */
  60055. rebuild(): void;
  60056. /**
  60057. * Disposes the component and the associated ressources
  60058. */
  60059. dispose(): void;
  60060. private _beforeCameraUpdate;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60066. */
  60067. export interface INavigationEnginePlugin {
  60068. /**
  60069. * plugin name
  60070. */
  60071. name: string;
  60072. /**
  60073. * Creates a navigation mesh
  60074. * @param meshes array of all the geometry used to compute the navigatio mesh
  60075. * @param parameters bunch of parameters used to filter geometry
  60076. */
  60077. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60078. /**
  60079. * Create a navigation mesh debug mesh
  60080. * @param scene is where the mesh will be added
  60081. * @returns debug display mesh
  60082. */
  60083. createDebugNavMesh(scene: Scene): Mesh;
  60084. /**
  60085. * Get a navigation mesh constrained position, closest to the parameter position
  60086. * @param position world position
  60087. * @returns the closest point to position constrained by the navigation mesh
  60088. */
  60089. getClosestPoint(position: Vector3): Vector3;
  60090. /**
  60091. * Get a navigation mesh constrained position, within a particular radius
  60092. * @param position world position
  60093. * @param maxRadius the maximum distance to the constrained world position
  60094. * @returns the closest point to position constrained by the navigation mesh
  60095. */
  60096. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60097. /**
  60098. * Compute the final position from a segment made of destination-position
  60099. * @param position world position
  60100. * @param destination world position
  60101. * @returns the resulting point along the navmesh
  60102. */
  60103. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60104. /**
  60105. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60106. * @param start world position
  60107. * @param end world position
  60108. * @returns array containing world position composing the path
  60109. */
  60110. computePath(start: Vector3, end: Vector3): Vector3[];
  60111. /**
  60112. * If this plugin is supported
  60113. * @returns true if plugin is supported
  60114. */
  60115. isSupported(): boolean;
  60116. /**
  60117. * Create a new Crowd so you can add agents
  60118. * @param maxAgents the maximum agent count in the crowd
  60119. * @param maxAgentRadius the maximum radius an agent can have
  60120. * @param scene to attach the crowd to
  60121. * @returns the crowd you can add agents to
  60122. */
  60123. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60124. /**
  60125. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60126. * The queries will try to find a solution within those bounds
  60127. * default is (1,1,1)
  60128. * @param extent x,y,z value that define the extent around the queries point of reference
  60129. */
  60130. setDefaultQueryExtent(extent: Vector3): void;
  60131. /**
  60132. * Get the Bounding box extent specified by setDefaultQueryExtent
  60133. * @returns the box extent values
  60134. */
  60135. getDefaultQueryExtent(): Vector3;
  60136. /**
  60137. * Release all resources
  60138. */
  60139. dispose(): void;
  60140. }
  60141. /**
  60142. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60143. */
  60144. export interface ICrowd {
  60145. /**
  60146. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60147. * You can attach anything to that node. The node position is updated in the scene update tick.
  60148. * @param pos world position that will be constrained by the navigation mesh
  60149. * @param parameters agent parameters
  60150. * @param transform hooked to the agent that will be update by the scene
  60151. * @returns agent index
  60152. */
  60153. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60154. /**
  60155. * Returns the agent position in world space
  60156. * @param index agent index returned by addAgent
  60157. * @returns world space position
  60158. */
  60159. getAgentPosition(index: number): Vector3;
  60160. /**
  60161. * Gets the agent velocity in world space
  60162. * @param index agent index returned by addAgent
  60163. * @returns world space velocity
  60164. */
  60165. getAgentVelocity(index: number): Vector3;
  60166. /**
  60167. * remove a particular agent previously created
  60168. * @param index agent index returned by addAgent
  60169. */
  60170. removeAgent(index: number): void;
  60171. /**
  60172. * get the list of all agents attached to this crowd
  60173. * @returns list of agent indices
  60174. */
  60175. getAgents(): number[];
  60176. /**
  60177. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60178. * @param deltaTime in seconds
  60179. */
  60180. update(deltaTime: number): void;
  60181. /**
  60182. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60183. * @param index agent index returned by addAgent
  60184. * @param destination targeted world position
  60185. */
  60186. agentGoto(index: number, destination: Vector3): void;
  60187. /**
  60188. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60189. * The queries will try to find a solution within those bounds
  60190. * default is (1,1,1)
  60191. * @param extent x,y,z value that define the extent around the queries point of reference
  60192. */
  60193. setDefaultQueryExtent(extent: Vector3): void;
  60194. /**
  60195. * Get the Bounding box extent specified by setDefaultQueryExtent
  60196. * @returns the box extent values
  60197. */
  60198. getDefaultQueryExtent(): Vector3;
  60199. /**
  60200. * Release all resources
  60201. */
  60202. dispose(): void;
  60203. }
  60204. /**
  60205. * Configures an agent
  60206. */
  60207. export interface IAgentParameters {
  60208. /**
  60209. * Agent radius. [Limit: >= 0]
  60210. */
  60211. radius: number;
  60212. /**
  60213. * Agent height. [Limit: > 0]
  60214. */
  60215. height: number;
  60216. /**
  60217. * Maximum allowed acceleration. [Limit: >= 0]
  60218. */
  60219. maxAcceleration: number;
  60220. /**
  60221. * Maximum allowed speed. [Limit: >= 0]
  60222. */
  60223. maxSpeed: number;
  60224. /**
  60225. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60226. */
  60227. collisionQueryRange: number;
  60228. /**
  60229. * The path visibility optimization range. [Limit: > 0]
  60230. */
  60231. pathOptimizationRange: number;
  60232. /**
  60233. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60234. */
  60235. separationWeight: number;
  60236. }
  60237. /**
  60238. * Configures the navigation mesh creation
  60239. */
  60240. export interface INavMeshParameters {
  60241. /**
  60242. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60243. */
  60244. cs: number;
  60245. /**
  60246. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60247. */
  60248. ch: number;
  60249. /**
  60250. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60251. */
  60252. walkableSlopeAngle: number;
  60253. /**
  60254. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60255. * be considered walkable. [Limit: >= 3] [Units: vx]
  60256. */
  60257. walkableHeight: number;
  60258. /**
  60259. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60260. */
  60261. walkableClimb: number;
  60262. /**
  60263. * The distance to erode/shrink the walkable area of the heightfield away from
  60264. * obstructions. [Limit: >=0] [Units: vx]
  60265. */
  60266. walkableRadius: number;
  60267. /**
  60268. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60269. */
  60270. maxEdgeLen: number;
  60271. /**
  60272. * The maximum distance a simplfied contour's border edges should deviate
  60273. * the original raw contour. [Limit: >=0] [Units: vx]
  60274. */
  60275. maxSimplificationError: number;
  60276. /**
  60277. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60278. */
  60279. minRegionArea: number;
  60280. /**
  60281. * Any regions with a span count smaller than this value will, if possible,
  60282. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60283. */
  60284. mergeRegionArea: number;
  60285. /**
  60286. * The maximum number of vertices allowed for polygons generated during the
  60287. * contour to polygon conversion process. [Limit: >= 3]
  60288. */
  60289. maxVertsPerPoly: number;
  60290. /**
  60291. * Sets the sampling distance to use when generating the detail mesh.
  60292. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60293. */
  60294. detailSampleDist: number;
  60295. /**
  60296. * The maximum distance the detail mesh surface should deviate from heightfield
  60297. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60298. */
  60299. detailSampleMaxError: number;
  60300. }
  60301. }
  60302. declare module BABYLON {
  60303. /**
  60304. * RecastJS navigation plugin
  60305. */
  60306. export class RecastJSPlugin implements INavigationEnginePlugin {
  60307. /**
  60308. * Reference to the Recast library
  60309. */
  60310. bjsRECAST: any;
  60311. /**
  60312. * plugin name
  60313. */
  60314. name: string;
  60315. /**
  60316. * the first navmesh created. We might extend this to support multiple navmeshes
  60317. */
  60318. navMesh: any;
  60319. /**
  60320. * Initializes the recastJS plugin
  60321. * @param recastInjection can be used to inject your own recast reference
  60322. */
  60323. constructor(recastInjection?: any);
  60324. /**
  60325. * Creates a navigation mesh
  60326. * @param meshes array of all the geometry used to compute the navigatio mesh
  60327. * @param parameters bunch of parameters used to filter geometry
  60328. */
  60329. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60330. /**
  60331. * Create a navigation mesh debug mesh
  60332. * @param scene is where the mesh will be added
  60333. * @returns debug display mesh
  60334. */
  60335. createDebugNavMesh(scene: Scene): Mesh;
  60336. /**
  60337. * Get a navigation mesh constrained position, closest to the parameter position
  60338. * @param position world position
  60339. * @returns the closest point to position constrained by the navigation mesh
  60340. */
  60341. getClosestPoint(position: Vector3): Vector3;
  60342. /**
  60343. * Get a navigation mesh constrained position, within a particular radius
  60344. * @param position world position
  60345. * @param maxRadius the maximum distance to the constrained world position
  60346. * @returns the closest point to position constrained by the navigation mesh
  60347. */
  60348. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60349. /**
  60350. * Compute the final position from a segment made of destination-position
  60351. * @param position world position
  60352. * @param destination world position
  60353. * @returns the resulting point along the navmesh
  60354. */
  60355. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60356. /**
  60357. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60358. * @param start world position
  60359. * @param end world position
  60360. * @returns array containing world position composing the path
  60361. */
  60362. computePath(start: Vector3, end: Vector3): Vector3[];
  60363. /**
  60364. * Create a new Crowd so you can add agents
  60365. * @param maxAgents the maximum agent count in the crowd
  60366. * @param maxAgentRadius the maximum radius an agent can have
  60367. * @param scene to attach the crowd to
  60368. * @returns the crowd you can add agents to
  60369. */
  60370. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60371. /**
  60372. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60373. * The queries will try to find a solution within those bounds
  60374. * default is (1,1,1)
  60375. * @param extent x,y,z value that define the extent around the queries point of reference
  60376. */
  60377. setDefaultQueryExtent(extent: Vector3): void;
  60378. /**
  60379. * Get the Bounding box extent specified by setDefaultQueryExtent
  60380. * @returns the box extent values
  60381. */
  60382. getDefaultQueryExtent(): Vector3;
  60383. /**
  60384. * Disposes
  60385. */
  60386. dispose(): void;
  60387. /**
  60388. * If this plugin is supported
  60389. * @returns true if plugin is supported
  60390. */
  60391. isSupported(): boolean;
  60392. }
  60393. /**
  60394. * Recast detour crowd implementation
  60395. */
  60396. export class RecastJSCrowd implements ICrowd {
  60397. /**
  60398. * Recast/detour plugin
  60399. */
  60400. bjsRECASTPlugin: RecastJSPlugin;
  60401. /**
  60402. * Link to the detour crowd
  60403. */
  60404. recastCrowd: any;
  60405. /**
  60406. * One transform per agent
  60407. */
  60408. transforms: TransformNode[];
  60409. /**
  60410. * All agents created
  60411. */
  60412. agents: number[];
  60413. /**
  60414. * Link to the scene is kept to unregister the crowd from the scene
  60415. */
  60416. private _scene;
  60417. /**
  60418. * Observer for crowd updates
  60419. */
  60420. private _onBeforeAnimationsObserver;
  60421. /**
  60422. * Constructor
  60423. * @param plugin recastJS plugin
  60424. * @param maxAgents the maximum agent count in the crowd
  60425. * @param maxAgentRadius the maximum radius an agent can have
  60426. * @param scene to attach the crowd to
  60427. * @returns the crowd you can add agents to
  60428. */
  60429. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60430. /**
  60431. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60432. * You can attach anything to that node. The node position is updated in the scene update tick.
  60433. * @param pos world position that will be constrained by the navigation mesh
  60434. * @param parameters agent parameters
  60435. * @param transform hooked to the agent that will be update by the scene
  60436. * @returns agent index
  60437. */
  60438. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60439. /**
  60440. * Returns the agent position in world space
  60441. * @param index agent index returned by addAgent
  60442. * @returns world space position
  60443. */
  60444. getAgentPosition(index: number): Vector3;
  60445. /**
  60446. * Returns the agent velocity in world space
  60447. * @param index agent index returned by addAgent
  60448. * @returns world space velocity
  60449. */
  60450. getAgentVelocity(index: number): Vector3;
  60451. /**
  60452. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60453. * @param index agent index returned by addAgent
  60454. * @param destination targeted world position
  60455. */
  60456. agentGoto(index: number, destination: Vector3): void;
  60457. /**
  60458. * remove a particular agent previously created
  60459. * @param index agent index returned by addAgent
  60460. */
  60461. removeAgent(index: number): void;
  60462. /**
  60463. * get the list of all agents attached to this crowd
  60464. * @returns list of agent indices
  60465. */
  60466. getAgents(): number[];
  60467. /**
  60468. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60469. * @param deltaTime in seconds
  60470. */
  60471. update(deltaTime: number): void;
  60472. /**
  60473. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60474. * The queries will try to find a solution within those bounds
  60475. * default is (1,1,1)
  60476. * @param extent x,y,z value that define the extent around the queries point of reference
  60477. */
  60478. setDefaultQueryExtent(extent: Vector3): void;
  60479. /**
  60480. * Get the Bounding box extent specified by setDefaultQueryExtent
  60481. * @returns the box extent values
  60482. */
  60483. getDefaultQueryExtent(): Vector3;
  60484. /**
  60485. * Release all resources
  60486. */
  60487. dispose(): void;
  60488. }
  60489. }
  60490. declare module BABYLON {
  60491. /**
  60492. * Class used to enable access to IndexedDB
  60493. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60494. */
  60495. export class Database implements IOfflineProvider {
  60496. private _callbackManifestChecked;
  60497. private _currentSceneUrl;
  60498. private _db;
  60499. private _enableSceneOffline;
  60500. private _enableTexturesOffline;
  60501. private _manifestVersionFound;
  60502. private _mustUpdateRessources;
  60503. private _hasReachedQuota;
  60504. private _isSupported;
  60505. private _idbFactory;
  60506. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60507. private static IsUASupportingBlobStorage;
  60508. /**
  60509. * Gets a boolean indicating if Database storate is enabled (off by default)
  60510. */
  60511. static IDBStorageEnabled: boolean;
  60512. /**
  60513. * Gets a boolean indicating if scene must be saved in the database
  60514. */
  60515. get enableSceneOffline(): boolean;
  60516. /**
  60517. * Gets a boolean indicating if textures must be saved in the database
  60518. */
  60519. get enableTexturesOffline(): boolean;
  60520. /**
  60521. * Creates a new Database
  60522. * @param urlToScene defines the url to load the scene
  60523. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60524. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60525. */
  60526. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60527. private static _ParseURL;
  60528. private static _ReturnFullUrlLocation;
  60529. private _checkManifestFile;
  60530. /**
  60531. * Open the database and make it available
  60532. * @param successCallback defines the callback to call on success
  60533. * @param errorCallback defines the callback to call on error
  60534. */
  60535. open(successCallback: () => void, errorCallback: () => void): void;
  60536. /**
  60537. * Loads an image from the database
  60538. * @param url defines the url to load from
  60539. * @param image defines the target DOM image
  60540. */
  60541. loadImage(url: string, image: HTMLImageElement): void;
  60542. private _loadImageFromDBAsync;
  60543. private _saveImageIntoDBAsync;
  60544. private _checkVersionFromDB;
  60545. private _loadVersionFromDBAsync;
  60546. private _saveVersionIntoDBAsync;
  60547. /**
  60548. * Loads a file from database
  60549. * @param url defines the URL to load from
  60550. * @param sceneLoaded defines a callback to call on success
  60551. * @param progressCallBack defines a callback to call when progress changed
  60552. * @param errorCallback defines a callback to call on error
  60553. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60554. */
  60555. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60556. private _loadFileAsync;
  60557. private _saveFileAsync;
  60558. /**
  60559. * Validates if xhr data is correct
  60560. * @param xhr defines the request to validate
  60561. * @param dataType defines the expected data type
  60562. * @returns true if data is correct
  60563. */
  60564. private static _ValidateXHRData;
  60565. }
  60566. }
  60567. declare module BABYLON {
  60568. /** @hidden */
  60569. export var gpuUpdateParticlesPixelShader: {
  60570. name: string;
  60571. shader: string;
  60572. };
  60573. }
  60574. declare module BABYLON {
  60575. /** @hidden */
  60576. export var gpuUpdateParticlesVertexShader: {
  60577. name: string;
  60578. shader: string;
  60579. };
  60580. }
  60581. declare module BABYLON {
  60582. /** @hidden */
  60583. export var clipPlaneFragmentDeclaration2: {
  60584. name: string;
  60585. shader: string;
  60586. };
  60587. }
  60588. declare module BABYLON {
  60589. /** @hidden */
  60590. export var gpuRenderParticlesPixelShader: {
  60591. name: string;
  60592. shader: string;
  60593. };
  60594. }
  60595. declare module BABYLON {
  60596. /** @hidden */
  60597. export var clipPlaneVertexDeclaration2: {
  60598. name: string;
  60599. shader: string;
  60600. };
  60601. }
  60602. declare module BABYLON {
  60603. /** @hidden */
  60604. export var gpuRenderParticlesVertexShader: {
  60605. name: string;
  60606. shader: string;
  60607. };
  60608. }
  60609. declare module BABYLON {
  60610. /**
  60611. * This represents a GPU particle system in Babylon
  60612. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60613. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60614. */
  60615. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60616. /**
  60617. * The layer mask we are rendering the particles through.
  60618. */
  60619. layerMask: number;
  60620. private _capacity;
  60621. private _activeCount;
  60622. private _currentActiveCount;
  60623. private _accumulatedCount;
  60624. private _renderEffect;
  60625. private _updateEffect;
  60626. private _buffer0;
  60627. private _buffer1;
  60628. private _spriteBuffer;
  60629. private _updateVAO;
  60630. private _renderVAO;
  60631. private _targetIndex;
  60632. private _sourceBuffer;
  60633. private _targetBuffer;
  60634. private _engine;
  60635. private _currentRenderId;
  60636. private _started;
  60637. private _stopped;
  60638. private _timeDelta;
  60639. private _randomTexture;
  60640. private _randomTexture2;
  60641. private _attributesStrideSize;
  60642. private _updateEffectOptions;
  60643. private _randomTextureSize;
  60644. private _actualFrame;
  60645. private readonly _rawTextureWidth;
  60646. /**
  60647. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60648. */
  60649. static get IsSupported(): boolean;
  60650. /**
  60651. * An event triggered when the system is disposed.
  60652. */
  60653. onDisposeObservable: Observable<GPUParticleSystem>;
  60654. /**
  60655. * Gets the maximum number of particles active at the same time.
  60656. * @returns The max number of active particles.
  60657. */
  60658. getCapacity(): number;
  60659. /**
  60660. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60661. * to override the particles.
  60662. */
  60663. forceDepthWrite: boolean;
  60664. /**
  60665. * Gets or set the number of active particles
  60666. */
  60667. get activeParticleCount(): number;
  60668. set activeParticleCount(value: number);
  60669. private _preWarmDone;
  60670. /**
  60671. * Is this system ready to be used/rendered
  60672. * @return true if the system is ready
  60673. */
  60674. isReady(): boolean;
  60675. /**
  60676. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60677. * @returns True if it has been started, otherwise false.
  60678. */
  60679. isStarted(): boolean;
  60680. /**
  60681. * Starts the particle system and begins to emit
  60682. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60683. */
  60684. start(delay?: number): void;
  60685. /**
  60686. * Stops the particle system.
  60687. */
  60688. stop(): void;
  60689. /**
  60690. * Remove all active particles
  60691. */
  60692. reset(): void;
  60693. /**
  60694. * Returns the string "GPUParticleSystem"
  60695. * @returns a string containing the class name
  60696. */
  60697. getClassName(): string;
  60698. private _colorGradientsTexture;
  60699. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60700. /**
  60701. * Adds a new color gradient
  60702. * @param gradient defines the gradient to use (between 0 and 1)
  60703. * @param color1 defines the color to affect to the specified gradient
  60704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60705. * @returns the current particle system
  60706. */
  60707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60708. /**
  60709. * Remove a specific color gradient
  60710. * @param gradient defines the gradient to remove
  60711. * @returns the current particle system
  60712. */
  60713. removeColorGradient(gradient: number): GPUParticleSystem;
  60714. private _angularSpeedGradientsTexture;
  60715. private _sizeGradientsTexture;
  60716. private _velocityGradientsTexture;
  60717. private _limitVelocityGradientsTexture;
  60718. private _dragGradientsTexture;
  60719. private _addFactorGradient;
  60720. /**
  60721. * Adds a new size gradient
  60722. * @param gradient defines the gradient to use (between 0 and 1)
  60723. * @param factor defines the size factor to affect to the specified gradient
  60724. * @returns the current particle system
  60725. */
  60726. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60727. /**
  60728. * Remove a specific size gradient
  60729. * @param gradient defines the gradient to remove
  60730. * @returns the current particle system
  60731. */
  60732. removeSizeGradient(gradient: number): GPUParticleSystem;
  60733. /**
  60734. * Adds a new angular speed gradient
  60735. * @param gradient defines the gradient to use (between 0 and 1)
  60736. * @param factor defines the angular speed to affect to the specified gradient
  60737. * @returns the current particle system
  60738. */
  60739. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60740. /**
  60741. * Remove a specific angular speed gradient
  60742. * @param gradient defines the gradient to remove
  60743. * @returns the current particle system
  60744. */
  60745. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60746. /**
  60747. * Adds a new velocity gradient
  60748. * @param gradient defines the gradient to use (between 0 and 1)
  60749. * @param factor defines the velocity to affect to the specified gradient
  60750. * @returns the current particle system
  60751. */
  60752. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60753. /**
  60754. * Remove a specific velocity gradient
  60755. * @param gradient defines the gradient to remove
  60756. * @returns the current particle system
  60757. */
  60758. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60759. /**
  60760. * Adds a new limit velocity gradient
  60761. * @param gradient defines the gradient to use (between 0 and 1)
  60762. * @param factor defines the limit velocity value to affect to the specified gradient
  60763. * @returns the current particle system
  60764. */
  60765. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60766. /**
  60767. * Remove a specific limit velocity gradient
  60768. * @param gradient defines the gradient to remove
  60769. * @returns the current particle system
  60770. */
  60771. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60772. /**
  60773. * Adds a new drag gradient
  60774. * @param gradient defines the gradient to use (between 0 and 1)
  60775. * @param factor defines the drag value to affect to the specified gradient
  60776. * @returns the current particle system
  60777. */
  60778. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60779. /**
  60780. * Remove a specific drag gradient
  60781. * @param gradient defines the gradient to remove
  60782. * @returns the current particle system
  60783. */
  60784. removeDragGradient(gradient: number): GPUParticleSystem;
  60785. /**
  60786. * Not supported by GPUParticleSystem
  60787. * @param gradient defines the gradient to use (between 0 and 1)
  60788. * @param factor defines the emit rate value to affect to the specified gradient
  60789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60790. * @returns the current particle system
  60791. */
  60792. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60793. /**
  60794. * Not supported by GPUParticleSystem
  60795. * @param gradient defines the gradient to remove
  60796. * @returns the current particle system
  60797. */
  60798. removeEmitRateGradient(gradient: number): IParticleSystem;
  60799. /**
  60800. * Not supported by GPUParticleSystem
  60801. * @param gradient defines the gradient to use (between 0 and 1)
  60802. * @param factor defines the start size value to affect to the specified gradient
  60803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60804. * @returns the current particle system
  60805. */
  60806. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60807. /**
  60808. * Not supported by GPUParticleSystem
  60809. * @param gradient defines the gradient to remove
  60810. * @returns the current particle system
  60811. */
  60812. removeStartSizeGradient(gradient: number): IParticleSystem;
  60813. /**
  60814. * Not supported by GPUParticleSystem
  60815. * @param gradient defines the gradient to use (between 0 and 1)
  60816. * @param min defines the color remap minimal range
  60817. * @param max defines the color remap maximal range
  60818. * @returns the current particle system
  60819. */
  60820. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60821. /**
  60822. * Not supported by GPUParticleSystem
  60823. * @param gradient defines the gradient to remove
  60824. * @returns the current particle system
  60825. */
  60826. removeColorRemapGradient(): IParticleSystem;
  60827. /**
  60828. * Not supported by GPUParticleSystem
  60829. * @param gradient defines the gradient to use (between 0 and 1)
  60830. * @param min defines the alpha remap minimal range
  60831. * @param max defines the alpha remap maximal range
  60832. * @returns the current particle system
  60833. */
  60834. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60835. /**
  60836. * Not supported by GPUParticleSystem
  60837. * @param gradient defines the gradient to remove
  60838. * @returns the current particle system
  60839. */
  60840. removeAlphaRemapGradient(): IParticleSystem;
  60841. /**
  60842. * Not supported by GPUParticleSystem
  60843. * @param gradient defines the gradient to use (between 0 and 1)
  60844. * @param color defines the color to affect to the specified gradient
  60845. * @returns the current particle system
  60846. */
  60847. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60848. /**
  60849. * Not supported by GPUParticleSystem
  60850. * @param gradient defines the gradient to remove
  60851. * @returns the current particle system
  60852. */
  60853. removeRampGradient(): IParticleSystem;
  60854. /**
  60855. * Not supported by GPUParticleSystem
  60856. * @returns the list of ramp gradients
  60857. */
  60858. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60859. /**
  60860. * Not supported by GPUParticleSystem
  60861. * Gets or sets a boolean indicating that ramp gradients must be used
  60862. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60863. */
  60864. get useRampGradients(): boolean;
  60865. set useRampGradients(value: boolean);
  60866. /**
  60867. * Not supported by GPUParticleSystem
  60868. * @param gradient defines the gradient to use (between 0 and 1)
  60869. * @param factor defines the life time factor to affect to the specified gradient
  60870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60871. * @returns the current particle system
  60872. */
  60873. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60874. /**
  60875. * Not supported by GPUParticleSystem
  60876. * @param gradient defines the gradient to remove
  60877. * @returns the current particle system
  60878. */
  60879. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60880. /**
  60881. * Instantiates a GPU particle system.
  60882. * 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.
  60883. * @param name The name of the particle system
  60884. * @param options The options used to create the system
  60885. * @param scene The scene the particle system belongs to
  60886. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60887. */
  60888. constructor(name: string, options: Partial<{
  60889. capacity: number;
  60890. randomTextureSize: number;
  60891. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60892. protected _reset(): void;
  60893. private _createUpdateVAO;
  60894. private _createRenderVAO;
  60895. private _initialize;
  60896. /** @hidden */
  60897. _recreateUpdateEffect(): void;
  60898. /** @hidden */
  60899. _recreateRenderEffect(): void;
  60900. /**
  60901. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60902. * @param preWarm defines if we are in the pre-warmimg phase
  60903. */
  60904. animate(preWarm?: boolean): void;
  60905. private _createFactorGradientTexture;
  60906. private _createSizeGradientTexture;
  60907. private _createAngularSpeedGradientTexture;
  60908. private _createVelocityGradientTexture;
  60909. private _createLimitVelocityGradientTexture;
  60910. private _createDragGradientTexture;
  60911. private _createColorGradientTexture;
  60912. /**
  60913. * Renders the particle system in its current state
  60914. * @param preWarm defines if the system should only update the particles but not render them
  60915. * @returns the current number of particles
  60916. */
  60917. render(preWarm?: boolean): number;
  60918. /**
  60919. * Rebuilds the particle system
  60920. */
  60921. rebuild(): void;
  60922. private _releaseBuffers;
  60923. private _releaseVAOs;
  60924. /**
  60925. * Disposes the particle system and free the associated resources
  60926. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60927. */
  60928. dispose(disposeTexture?: boolean): void;
  60929. /**
  60930. * Clones the particle system.
  60931. * @param name The name of the cloned object
  60932. * @param newEmitter The new emitter to use
  60933. * @returns the cloned particle system
  60934. */
  60935. clone(name: string, newEmitter: any): GPUParticleSystem;
  60936. /**
  60937. * Serializes the particle system to a JSON object.
  60938. * @returns the JSON object
  60939. */
  60940. serialize(): any;
  60941. /**
  60942. * Parses a JSON object to create a GPU particle system.
  60943. * @param parsedParticleSystem The JSON object to parse
  60944. * @param scene The scene to create the particle system in
  60945. * @param rootUrl The root url to use to load external dependencies like texture
  60946. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60947. * @returns the parsed GPU particle system
  60948. */
  60949. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60950. }
  60951. }
  60952. declare module BABYLON {
  60953. /**
  60954. * Represents a set of particle systems working together to create a specific effect
  60955. */
  60956. export class ParticleSystemSet implements IDisposable {
  60957. /**
  60958. * Gets or sets base Assets URL
  60959. */
  60960. static BaseAssetsUrl: string;
  60961. private _emitterCreationOptions;
  60962. private _emitterNode;
  60963. /**
  60964. * Gets the particle system list
  60965. */
  60966. systems: IParticleSystem[];
  60967. /**
  60968. * Gets the emitter node used with this set
  60969. */
  60970. get emitterNode(): Nullable<TransformNode>;
  60971. /**
  60972. * Creates a new emitter mesh as a sphere
  60973. * @param options defines the options used to create the sphere
  60974. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60975. * @param scene defines the hosting scene
  60976. */
  60977. setEmitterAsSphere(options: {
  60978. diameter: number;
  60979. segments: number;
  60980. color: Color3;
  60981. }, renderingGroupId: number, scene: Scene): void;
  60982. /**
  60983. * Starts all particle systems of the set
  60984. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60985. */
  60986. start(emitter?: AbstractMesh): void;
  60987. /**
  60988. * Release all associated resources
  60989. */
  60990. dispose(): void;
  60991. /**
  60992. * Serialize the set into a JSON compatible object
  60993. * @returns a JSON compatible representation of the set
  60994. */
  60995. serialize(): any;
  60996. /**
  60997. * Parse a new ParticleSystemSet from a serialized source
  60998. * @param data defines a JSON compatible representation of the set
  60999. * @param scene defines the hosting scene
  61000. * @param gpu defines if we want GPU particles or CPU particles
  61001. * @returns a new ParticleSystemSet
  61002. */
  61003. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61004. }
  61005. }
  61006. declare module BABYLON {
  61007. /**
  61008. * This class is made for on one-liner static method to help creating particle system set.
  61009. */
  61010. export class ParticleHelper {
  61011. /**
  61012. * Gets or sets base Assets URL
  61013. */
  61014. static BaseAssetsUrl: string;
  61015. /**
  61016. * Create a default particle system that you can tweak
  61017. * @param emitter defines the emitter to use
  61018. * @param capacity defines the system capacity (default is 500 particles)
  61019. * @param scene defines the hosting scene
  61020. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61021. * @returns the new Particle system
  61022. */
  61023. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61024. /**
  61025. * This is the main static method (one-liner) of this helper to create different particle systems
  61026. * @param type This string represents the type to the particle system to create
  61027. * @param scene The scene where the particle system should live
  61028. * @param gpu If the system will use gpu
  61029. * @returns the ParticleSystemSet created
  61030. */
  61031. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61032. /**
  61033. * Static function used to export a particle system to a ParticleSystemSet variable.
  61034. * Please note that the emitter shape is not exported
  61035. * @param systems defines the particle systems to export
  61036. * @returns the created particle system set
  61037. */
  61038. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61039. }
  61040. }
  61041. declare module BABYLON {
  61042. interface Engine {
  61043. /**
  61044. * Create an effect to use with particle systems.
  61045. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61046. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61047. * @param uniformsNames defines a list of attribute names
  61048. * @param samplers defines an array of string used to represent textures
  61049. * @param defines defines the string containing the defines to use to compile the shaders
  61050. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61051. * @param onCompiled defines a function to call when the effect creation is successful
  61052. * @param onError defines a function to call when the effect creation has failed
  61053. * @returns the new Effect
  61054. */
  61055. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61056. }
  61057. interface Mesh {
  61058. /**
  61059. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61060. * @returns an array of IParticleSystem
  61061. */
  61062. getEmittedParticleSystems(): IParticleSystem[];
  61063. /**
  61064. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61065. * @returns an array of IParticleSystem
  61066. */
  61067. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61068. }
  61069. /**
  61070. * @hidden
  61071. */
  61072. export var _IDoNeedToBeInTheBuild: number;
  61073. }
  61074. declare module BABYLON {
  61075. /** Defines the 4 color options */
  61076. export enum PointColor {
  61077. /** color value */
  61078. Color = 2,
  61079. /** uv value */
  61080. UV = 1,
  61081. /** random value */
  61082. Random = 0,
  61083. /** stated value */
  61084. Stated = 3
  61085. }
  61086. /**
  61087. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61088. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61089. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61090. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61091. *
  61092. * Full documentation here : TO BE ENTERED
  61093. */
  61094. export class PointsCloudSystem implements IDisposable {
  61095. /**
  61096. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61097. * Example : var p = SPS.particles[i];
  61098. */
  61099. particles: CloudPoint[];
  61100. /**
  61101. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61102. */
  61103. nbParticles: number;
  61104. /**
  61105. * This a counter for your own usage. It's not set by any SPS functions.
  61106. */
  61107. counter: number;
  61108. /**
  61109. * The PCS name. This name is also given to the underlying mesh.
  61110. */
  61111. name: string;
  61112. /**
  61113. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61114. */
  61115. mesh: Mesh;
  61116. /**
  61117. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61118. * Please read :
  61119. */
  61120. vars: any;
  61121. /**
  61122. * @hidden
  61123. */
  61124. _size: number;
  61125. private _scene;
  61126. private _promises;
  61127. private _positions;
  61128. private _indices;
  61129. private _normals;
  61130. private _colors;
  61131. private _uvs;
  61132. private _indices32;
  61133. private _positions32;
  61134. private _colors32;
  61135. private _uvs32;
  61136. private _updatable;
  61137. private _isVisibilityBoxLocked;
  61138. private _alwaysVisible;
  61139. private _groups;
  61140. private _groupCounter;
  61141. private _computeParticleColor;
  61142. private _computeParticleTexture;
  61143. private _computeParticleRotation;
  61144. private _computeBoundingBox;
  61145. private _isReady;
  61146. /**
  61147. * Creates a PCS (Points Cloud System) object
  61148. * @param name (String) is the PCS name, this will be the underlying mesh name
  61149. * @param pointSize (number) is the size for each point
  61150. * @param scene (Scene) is the scene in which the PCS is added
  61151. * @param options defines the options of the PCS e.g.
  61152. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61153. */
  61154. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61155. updatable?: boolean;
  61156. });
  61157. /**
  61158. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61159. * If no points were added to the PCS, the returned mesh is just a single point.
  61160. * @returns a promise for the created mesh
  61161. */
  61162. buildMeshAsync(): Promise<Mesh>;
  61163. /**
  61164. * @hidden
  61165. */
  61166. private _buildMesh;
  61167. private _addParticle;
  61168. private _randomUnitVector;
  61169. private _getColorIndicesForCoord;
  61170. private _setPointsColorOrUV;
  61171. private _colorFromTexture;
  61172. private _calculateDensity;
  61173. /**
  61174. * Adds points to the PCS in random positions within a unit sphere
  61175. * @param nb (positive integer) the number of particles to be created from this model
  61176. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61177. * @returns the number of groups in the system
  61178. */
  61179. addPoints(nb: number, pointFunction?: any): number;
  61180. /**
  61181. * Adds points to the PCS from the surface of the model shape
  61182. * @param mesh is any Mesh object that will be used as a surface model for the points
  61183. * @param nb (positive integer) the number of particles to be created from this model
  61184. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61185. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61186. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61187. * @returns the number of groups in the system
  61188. */
  61189. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61190. /**
  61191. * Adds points to the PCS inside the model shape
  61192. * @param mesh is any Mesh object that will be used as a surface model for the points
  61193. * @param nb (positive integer) the number of particles to be created from this model
  61194. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61195. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61196. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61197. * @returns the number of groups in the system
  61198. */
  61199. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61200. /**
  61201. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61202. * This method calls `updateParticle()` for each particle of the SPS.
  61203. * For an animated SPS, it is usually called within the render loop.
  61204. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61205. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61206. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61207. * @returns the PCS.
  61208. */
  61209. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61210. /**
  61211. * Disposes the PCS.
  61212. */
  61213. dispose(): void;
  61214. /**
  61215. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61216. * doc :
  61217. * @returns the PCS.
  61218. */
  61219. refreshVisibleSize(): PointsCloudSystem;
  61220. /**
  61221. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61222. * @param size the size (float) of the visibility box
  61223. * note : this doesn't lock the PCS mesh bounding box.
  61224. * doc :
  61225. */
  61226. setVisibilityBox(size: number): void;
  61227. /**
  61228. * Gets whether the PCS is always visible or not
  61229. * doc :
  61230. */
  61231. get isAlwaysVisible(): boolean;
  61232. /**
  61233. * Sets the PCS as always visible or not
  61234. * doc :
  61235. */
  61236. set isAlwaysVisible(val: boolean);
  61237. /**
  61238. * Tells to `setParticles()` to compute the particle rotations or not
  61239. * Default value : false. The PCS is faster when it's set to false
  61240. * Note : particle rotations are only applied to parent particles
  61241. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61242. */
  61243. set computeParticleRotation(val: boolean);
  61244. /**
  61245. * Tells to `setParticles()` to compute the particle colors or not.
  61246. * Default value : true. The PCS is faster when it's set to false.
  61247. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61248. */
  61249. set computeParticleColor(val: boolean);
  61250. set computeParticleTexture(val: boolean);
  61251. /**
  61252. * Gets if `setParticles()` computes the particle colors or not.
  61253. * Default value : false. The PCS is faster when it's set to false.
  61254. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61255. */
  61256. get computeParticleColor(): boolean;
  61257. /**
  61258. * Gets if `setParticles()` computes the particle textures or not.
  61259. * Default value : false. The PCS is faster when it's set to false.
  61260. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61261. */
  61262. get computeParticleTexture(): boolean;
  61263. /**
  61264. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61265. */
  61266. set computeBoundingBox(val: boolean);
  61267. /**
  61268. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61269. */
  61270. get computeBoundingBox(): boolean;
  61271. /**
  61272. * This function does nothing. It may be overwritten to set all the particle first values.
  61273. * The PCS doesn't call this function, you may have to call it by your own.
  61274. * doc :
  61275. */
  61276. initParticles(): void;
  61277. /**
  61278. * This function does nothing. It may be overwritten to recycle a particle
  61279. * The PCS doesn't call this function, you can to call it
  61280. * doc :
  61281. * @param particle The particle to recycle
  61282. * @returns the recycled particle
  61283. */
  61284. recycleParticle(particle: CloudPoint): CloudPoint;
  61285. /**
  61286. * Updates a particle : this function should be overwritten by the user.
  61287. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61288. * doc :
  61289. * @example : just set a particle position or velocity and recycle conditions
  61290. * @param particle The particle to update
  61291. * @returns the updated particle
  61292. */
  61293. updateParticle(particle: CloudPoint): CloudPoint;
  61294. /**
  61295. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61296. * This does nothing and may be overwritten by the user.
  61297. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61298. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61299. * @param update the boolean update value actually passed to setParticles()
  61300. */
  61301. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61302. /**
  61303. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61304. * This will be passed three parameters.
  61305. * This does nothing and may be overwritten by the user.
  61306. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61307. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61308. * @param update the boolean update value actually passed to setParticles()
  61309. */
  61310. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61311. }
  61312. }
  61313. declare module BABYLON {
  61314. /**
  61315. * Represents one particle of a points cloud system.
  61316. */
  61317. export class CloudPoint {
  61318. /**
  61319. * particle global index
  61320. */
  61321. idx: number;
  61322. /**
  61323. * The color of the particle
  61324. */
  61325. color: Nullable<Color4>;
  61326. /**
  61327. * The world space position of the particle.
  61328. */
  61329. position: Vector3;
  61330. /**
  61331. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61332. */
  61333. rotation: Vector3;
  61334. /**
  61335. * The world space rotation quaternion of the particle.
  61336. */
  61337. rotationQuaternion: Nullable<Quaternion>;
  61338. /**
  61339. * The uv of the particle.
  61340. */
  61341. uv: Nullable<Vector2>;
  61342. /**
  61343. * The current speed of the particle.
  61344. */
  61345. velocity: Vector3;
  61346. /**
  61347. * The pivot point in the particle local space.
  61348. */
  61349. pivot: Vector3;
  61350. /**
  61351. * Must the particle be translated from its pivot point in its local space ?
  61352. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61353. * Default : false
  61354. */
  61355. translateFromPivot: boolean;
  61356. /**
  61357. * Index of this particle in the global "positions" array (Internal use)
  61358. * @hidden
  61359. */
  61360. _pos: number;
  61361. /**
  61362. * @hidden Index of this particle in the global "indices" array (Internal use)
  61363. */
  61364. _ind: number;
  61365. /**
  61366. * Group this particle belongs to
  61367. */
  61368. _group: PointsGroup;
  61369. /**
  61370. * Group id of this particle
  61371. */
  61372. groupId: number;
  61373. /**
  61374. * Index of the particle in its group id (Internal use)
  61375. */
  61376. idxInGroup: number;
  61377. /**
  61378. * @hidden Particle BoundingInfo object (Internal use)
  61379. */
  61380. _boundingInfo: BoundingInfo;
  61381. /**
  61382. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61383. */
  61384. _pcs: PointsCloudSystem;
  61385. /**
  61386. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61387. */
  61388. _stillInvisible: boolean;
  61389. /**
  61390. * @hidden Last computed particle rotation matrix
  61391. */
  61392. _rotationMatrix: number[];
  61393. /**
  61394. * Parent particle Id, if any.
  61395. * Default null.
  61396. */
  61397. parentId: Nullable<number>;
  61398. /**
  61399. * @hidden Internal global position in the PCS.
  61400. */
  61401. _globalPosition: Vector3;
  61402. /**
  61403. * Creates a Point Cloud object.
  61404. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61405. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61406. * @param group (PointsGroup) is the group the particle belongs to
  61407. * @param groupId (integer) is the group identifier in the PCS.
  61408. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61409. * @param pcs defines the PCS it is associated to
  61410. */
  61411. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61412. /**
  61413. * get point size
  61414. */
  61415. get size(): Vector3;
  61416. /**
  61417. * Set point size
  61418. */
  61419. set size(scale: Vector3);
  61420. /**
  61421. * Legacy support, changed quaternion to rotationQuaternion
  61422. */
  61423. get quaternion(): Nullable<Quaternion>;
  61424. /**
  61425. * Legacy support, changed quaternion to rotationQuaternion
  61426. */
  61427. set quaternion(q: Nullable<Quaternion>);
  61428. /**
  61429. * Returns a boolean. True if the particle intersects a mesh, else false
  61430. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61431. * @param target is the object (point or mesh) what the intersection is computed against
  61432. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61433. * @returns true if it intersects
  61434. */
  61435. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61436. /**
  61437. * get the rotation matrix of the particle
  61438. * @hidden
  61439. */
  61440. getRotationMatrix(m: Matrix): void;
  61441. }
  61442. /**
  61443. * Represents a group of points in a points cloud system
  61444. * * PCS internal tool, don't use it manually.
  61445. */
  61446. export class PointsGroup {
  61447. /**
  61448. * The group id
  61449. * @hidden
  61450. */
  61451. groupID: number;
  61452. /**
  61453. * image data for group (internal use)
  61454. * @hidden
  61455. */
  61456. _groupImageData: Nullable<ArrayBufferView>;
  61457. /**
  61458. * Image Width (internal use)
  61459. * @hidden
  61460. */
  61461. _groupImgWidth: number;
  61462. /**
  61463. * Image Height (internal use)
  61464. * @hidden
  61465. */
  61466. _groupImgHeight: number;
  61467. /**
  61468. * Custom position function (internal use)
  61469. * @hidden
  61470. */
  61471. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61472. /**
  61473. * density per facet for surface points
  61474. * @hidden
  61475. */
  61476. _groupDensity: number[];
  61477. /**
  61478. * Only when points are colored by texture carries pointer to texture list array
  61479. * @hidden
  61480. */
  61481. _textureNb: number;
  61482. /**
  61483. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61484. * PCS internal tool, don't use it manually.
  61485. * @hidden
  61486. */
  61487. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61488. }
  61489. }
  61490. declare module BABYLON {
  61491. interface Scene {
  61492. /** @hidden (Backing field) */
  61493. _physicsEngine: Nullable<IPhysicsEngine>;
  61494. /** @hidden */
  61495. _physicsTimeAccumulator: number;
  61496. /**
  61497. * Gets the current physics engine
  61498. * @returns a IPhysicsEngine or null if none attached
  61499. */
  61500. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61501. /**
  61502. * Enables physics to the current scene
  61503. * @param gravity defines the scene's gravity for the physics engine
  61504. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61505. * @return a boolean indicating if the physics engine was initialized
  61506. */
  61507. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61508. /**
  61509. * Disables and disposes the physics engine associated with the scene
  61510. */
  61511. disablePhysicsEngine(): void;
  61512. /**
  61513. * Gets a boolean indicating if there is an active physics engine
  61514. * @returns a boolean indicating if there is an active physics engine
  61515. */
  61516. isPhysicsEnabled(): boolean;
  61517. /**
  61518. * Deletes a physics compound impostor
  61519. * @param compound defines the compound to delete
  61520. */
  61521. deleteCompoundImpostor(compound: any): void;
  61522. /**
  61523. * An event triggered when physic simulation is about to be run
  61524. */
  61525. onBeforePhysicsObservable: Observable<Scene>;
  61526. /**
  61527. * An event triggered when physic simulation has been done
  61528. */
  61529. onAfterPhysicsObservable: Observable<Scene>;
  61530. }
  61531. interface AbstractMesh {
  61532. /** @hidden */
  61533. _physicsImpostor: Nullable<PhysicsImpostor>;
  61534. /**
  61535. * Gets or sets impostor used for physic simulation
  61536. * @see http://doc.babylonjs.com/features/physics_engine
  61537. */
  61538. physicsImpostor: Nullable<PhysicsImpostor>;
  61539. /**
  61540. * Gets the current physics impostor
  61541. * @see http://doc.babylonjs.com/features/physics_engine
  61542. * @returns a physics impostor or null
  61543. */
  61544. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61545. /** Apply a physic impulse to the mesh
  61546. * @param force defines the force to apply
  61547. * @param contactPoint defines where to apply the force
  61548. * @returns the current mesh
  61549. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61550. */
  61551. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61552. /**
  61553. * Creates a physic joint between two meshes
  61554. * @param otherMesh defines the other mesh to use
  61555. * @param pivot1 defines the pivot to use on this mesh
  61556. * @param pivot2 defines the pivot to use on the other mesh
  61557. * @param options defines additional options (can be plugin dependent)
  61558. * @returns the current mesh
  61559. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61560. */
  61561. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61562. /** @hidden */
  61563. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61564. }
  61565. /**
  61566. * Defines the physics engine scene component responsible to manage a physics engine
  61567. */
  61568. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61569. /**
  61570. * The component name helpful to identify the component in the list of scene components.
  61571. */
  61572. readonly name: string;
  61573. /**
  61574. * The scene the component belongs to.
  61575. */
  61576. scene: Scene;
  61577. /**
  61578. * Creates a new instance of the component for the given scene
  61579. * @param scene Defines the scene to register the component in
  61580. */
  61581. constructor(scene: Scene);
  61582. /**
  61583. * Registers the component in a given scene
  61584. */
  61585. register(): void;
  61586. /**
  61587. * Rebuilds the elements related to this component in case of
  61588. * context lost for instance.
  61589. */
  61590. rebuild(): void;
  61591. /**
  61592. * Disposes the component and the associated ressources
  61593. */
  61594. dispose(): void;
  61595. }
  61596. }
  61597. declare module BABYLON {
  61598. /**
  61599. * A helper for physics simulations
  61600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61601. */
  61602. export class PhysicsHelper {
  61603. private _scene;
  61604. private _physicsEngine;
  61605. /**
  61606. * Initializes the Physics helper
  61607. * @param scene Babylon.js scene
  61608. */
  61609. constructor(scene: Scene);
  61610. /**
  61611. * Applies a radial explosion impulse
  61612. * @param origin the origin of the explosion
  61613. * @param radiusOrEventOptions the radius or the options of radial explosion
  61614. * @param strength the explosion strength
  61615. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61616. * @returns A physics radial explosion event, or null
  61617. */
  61618. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61619. /**
  61620. * Applies a radial explosion force
  61621. * @param origin the origin of the explosion
  61622. * @param radiusOrEventOptions the radius or the options of radial explosion
  61623. * @param strength the explosion strength
  61624. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61625. * @returns A physics radial explosion event, or null
  61626. */
  61627. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61628. /**
  61629. * Creates a gravitational field
  61630. * @param origin the origin of the explosion
  61631. * @param radiusOrEventOptions the radius or the options of radial explosion
  61632. * @param strength the explosion strength
  61633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61634. * @returns A physics gravitational field event, or null
  61635. */
  61636. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61637. /**
  61638. * Creates a physics updraft event
  61639. * @param origin the origin of the updraft
  61640. * @param radiusOrEventOptions the radius or the options of the updraft
  61641. * @param strength the strength of the updraft
  61642. * @param height the height of the updraft
  61643. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61644. * @returns A physics updraft event, or null
  61645. */
  61646. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61647. /**
  61648. * Creates a physics vortex event
  61649. * @param origin the of the vortex
  61650. * @param radiusOrEventOptions the radius or the options of the vortex
  61651. * @param strength the strength of the vortex
  61652. * @param height the height of the vortex
  61653. * @returns a Physics vortex event, or null
  61654. * A physics vortex event or null
  61655. */
  61656. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61657. }
  61658. /**
  61659. * Represents a physics radial explosion event
  61660. */
  61661. class PhysicsRadialExplosionEvent {
  61662. private _scene;
  61663. private _options;
  61664. private _sphere;
  61665. private _dataFetched;
  61666. /**
  61667. * Initializes a radial explosioin event
  61668. * @param _scene BabylonJS scene
  61669. * @param _options The options for the vortex event
  61670. */
  61671. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61672. /**
  61673. * Returns the data related to the radial explosion event (sphere).
  61674. * @returns The radial explosion event data
  61675. */
  61676. getData(): PhysicsRadialExplosionEventData;
  61677. /**
  61678. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61679. * @param impostor A physics imposter
  61680. * @param origin the origin of the explosion
  61681. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61682. */
  61683. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61684. /**
  61685. * Triggers affecterd impostors callbacks
  61686. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61687. */
  61688. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61689. /**
  61690. * Disposes the sphere.
  61691. * @param force Specifies if the sphere should be disposed by force
  61692. */
  61693. dispose(force?: boolean): void;
  61694. /*** Helpers ***/
  61695. private _prepareSphere;
  61696. private _intersectsWithSphere;
  61697. }
  61698. /**
  61699. * Represents a gravitational field event
  61700. */
  61701. class PhysicsGravitationalFieldEvent {
  61702. private _physicsHelper;
  61703. private _scene;
  61704. private _origin;
  61705. private _options;
  61706. private _tickCallback;
  61707. private _sphere;
  61708. private _dataFetched;
  61709. /**
  61710. * Initializes the physics gravitational field event
  61711. * @param _physicsHelper A physics helper
  61712. * @param _scene BabylonJS scene
  61713. * @param _origin The origin position of the gravitational field event
  61714. * @param _options The options for the vortex event
  61715. */
  61716. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61717. /**
  61718. * Returns the data related to the gravitational field event (sphere).
  61719. * @returns A gravitational field event
  61720. */
  61721. getData(): PhysicsGravitationalFieldEventData;
  61722. /**
  61723. * Enables the gravitational field.
  61724. */
  61725. enable(): void;
  61726. /**
  61727. * Disables the gravitational field.
  61728. */
  61729. disable(): void;
  61730. /**
  61731. * Disposes the sphere.
  61732. * @param force The force to dispose from the gravitational field event
  61733. */
  61734. dispose(force?: boolean): void;
  61735. private _tick;
  61736. }
  61737. /**
  61738. * Represents a physics updraft event
  61739. */
  61740. class PhysicsUpdraftEvent {
  61741. private _scene;
  61742. private _origin;
  61743. private _options;
  61744. private _physicsEngine;
  61745. private _originTop;
  61746. private _originDirection;
  61747. private _tickCallback;
  61748. private _cylinder;
  61749. private _cylinderPosition;
  61750. private _dataFetched;
  61751. /**
  61752. * Initializes the physics updraft event
  61753. * @param _scene BabylonJS scene
  61754. * @param _origin The origin position of the updraft
  61755. * @param _options The options for the updraft event
  61756. */
  61757. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61758. /**
  61759. * Returns the data related to the updraft event (cylinder).
  61760. * @returns A physics updraft event
  61761. */
  61762. getData(): PhysicsUpdraftEventData;
  61763. /**
  61764. * Enables the updraft.
  61765. */
  61766. enable(): void;
  61767. /**
  61768. * Disables the updraft.
  61769. */
  61770. disable(): void;
  61771. /**
  61772. * Disposes the cylinder.
  61773. * @param force Specifies if the updraft should be disposed by force
  61774. */
  61775. dispose(force?: boolean): void;
  61776. private getImpostorHitData;
  61777. private _tick;
  61778. /*** Helpers ***/
  61779. private _prepareCylinder;
  61780. private _intersectsWithCylinder;
  61781. }
  61782. /**
  61783. * Represents a physics vortex event
  61784. */
  61785. class PhysicsVortexEvent {
  61786. private _scene;
  61787. private _origin;
  61788. private _options;
  61789. private _physicsEngine;
  61790. private _originTop;
  61791. private _tickCallback;
  61792. private _cylinder;
  61793. private _cylinderPosition;
  61794. private _dataFetched;
  61795. /**
  61796. * Initializes the physics vortex event
  61797. * @param _scene The BabylonJS scene
  61798. * @param _origin The origin position of the vortex
  61799. * @param _options The options for the vortex event
  61800. */
  61801. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61802. /**
  61803. * Returns the data related to the vortex event (cylinder).
  61804. * @returns The physics vortex event data
  61805. */
  61806. getData(): PhysicsVortexEventData;
  61807. /**
  61808. * Enables the vortex.
  61809. */
  61810. enable(): void;
  61811. /**
  61812. * Disables the cortex.
  61813. */
  61814. disable(): void;
  61815. /**
  61816. * Disposes the sphere.
  61817. * @param force
  61818. */
  61819. dispose(force?: boolean): void;
  61820. private getImpostorHitData;
  61821. private _tick;
  61822. /*** Helpers ***/
  61823. private _prepareCylinder;
  61824. private _intersectsWithCylinder;
  61825. }
  61826. /**
  61827. * Options fot the radial explosion event
  61828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61829. */
  61830. export class PhysicsRadialExplosionEventOptions {
  61831. /**
  61832. * The radius of the sphere for the radial explosion.
  61833. */
  61834. radius: number;
  61835. /**
  61836. * The strenth of the explosion.
  61837. */
  61838. strength: number;
  61839. /**
  61840. * The strenght of the force in correspondence to the distance of the affected object
  61841. */
  61842. falloff: PhysicsRadialImpulseFalloff;
  61843. /**
  61844. * Sphere options for the radial explosion.
  61845. */
  61846. sphere: {
  61847. segments: number;
  61848. diameter: number;
  61849. };
  61850. /**
  61851. * Sphere options for the radial explosion.
  61852. */
  61853. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61854. }
  61855. /**
  61856. * Options fot the updraft event
  61857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61858. */
  61859. export class PhysicsUpdraftEventOptions {
  61860. /**
  61861. * The radius of the cylinder for the vortex
  61862. */
  61863. radius: number;
  61864. /**
  61865. * The strenth of the updraft.
  61866. */
  61867. strength: number;
  61868. /**
  61869. * The height of the cylinder for the updraft.
  61870. */
  61871. height: number;
  61872. /**
  61873. * The mode for the the updraft.
  61874. */
  61875. updraftMode: PhysicsUpdraftMode;
  61876. }
  61877. /**
  61878. * Options fot the vortex event
  61879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61880. */
  61881. export class PhysicsVortexEventOptions {
  61882. /**
  61883. * The radius of the cylinder for the vortex
  61884. */
  61885. radius: number;
  61886. /**
  61887. * The strenth of the vortex.
  61888. */
  61889. strength: number;
  61890. /**
  61891. * The height of the cylinder for the vortex.
  61892. */
  61893. height: number;
  61894. /**
  61895. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61896. */
  61897. centripetalForceThreshold: number;
  61898. /**
  61899. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61900. */
  61901. centripetalForceMultiplier: number;
  61902. /**
  61903. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61904. */
  61905. centrifugalForceMultiplier: number;
  61906. /**
  61907. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61908. */
  61909. updraftForceMultiplier: number;
  61910. }
  61911. /**
  61912. * The strenght of the force in correspondence to the distance of the affected object
  61913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61914. */
  61915. export enum PhysicsRadialImpulseFalloff {
  61916. /** Defines that impulse is constant in strength across it's whole radius */
  61917. Constant = 0,
  61918. /** Defines that impulse gets weaker if it's further from the origin */
  61919. Linear = 1
  61920. }
  61921. /**
  61922. * The strength of the force in correspondence to the distance of the affected object
  61923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61924. */
  61925. export enum PhysicsUpdraftMode {
  61926. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61927. Center = 0,
  61928. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61929. Perpendicular = 1
  61930. }
  61931. /**
  61932. * Interface for a physics hit data
  61933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61934. */
  61935. export interface PhysicsHitData {
  61936. /**
  61937. * The force applied at the contact point
  61938. */
  61939. force: Vector3;
  61940. /**
  61941. * The contact point
  61942. */
  61943. contactPoint: Vector3;
  61944. /**
  61945. * The distance from the origin to the contact point
  61946. */
  61947. distanceFromOrigin: number;
  61948. }
  61949. /**
  61950. * Interface for radial explosion event data
  61951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61952. */
  61953. export interface PhysicsRadialExplosionEventData {
  61954. /**
  61955. * A sphere used for the radial explosion event
  61956. */
  61957. sphere: Mesh;
  61958. }
  61959. /**
  61960. * Interface for gravitational field event data
  61961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61962. */
  61963. export interface PhysicsGravitationalFieldEventData {
  61964. /**
  61965. * A sphere mesh used for the gravitational field event
  61966. */
  61967. sphere: Mesh;
  61968. }
  61969. /**
  61970. * Interface for updraft event data
  61971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61972. */
  61973. export interface PhysicsUpdraftEventData {
  61974. /**
  61975. * A cylinder used for the updraft event
  61976. */
  61977. cylinder: Mesh;
  61978. }
  61979. /**
  61980. * Interface for vortex event data
  61981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61982. */
  61983. export interface PhysicsVortexEventData {
  61984. /**
  61985. * A cylinder used for the vortex event
  61986. */
  61987. cylinder: Mesh;
  61988. }
  61989. /**
  61990. * Interface for an affected physics impostor
  61991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61992. */
  61993. export interface PhysicsAffectedImpostorWithData {
  61994. /**
  61995. * The impostor affected by the effect
  61996. */
  61997. impostor: PhysicsImpostor;
  61998. /**
  61999. * The data about the hit/horce from the explosion
  62000. */
  62001. hitData: PhysicsHitData;
  62002. }
  62003. }
  62004. declare module BABYLON {
  62005. /** @hidden */
  62006. export var blackAndWhitePixelShader: {
  62007. name: string;
  62008. shader: string;
  62009. };
  62010. }
  62011. declare module BABYLON {
  62012. /**
  62013. * Post process used to render in black and white
  62014. */
  62015. export class BlackAndWhitePostProcess extends PostProcess {
  62016. /**
  62017. * Linear about to convert he result to black and white (default: 1)
  62018. */
  62019. degree: number;
  62020. /**
  62021. * Creates a black and white post process
  62022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62023. * @param name The name of the effect.
  62024. * @param options The required width/height ratio to downsize to before computing the render pass.
  62025. * @param camera The camera to apply the render pass to.
  62026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62027. * @param engine The engine which the post process will be applied. (default: current engine)
  62028. * @param reusable If the post process can be reused on the same frame. (default: false)
  62029. */
  62030. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62031. }
  62032. }
  62033. declare module BABYLON {
  62034. /**
  62035. * This represents a set of one or more post processes in Babylon.
  62036. * A post process can be used to apply a shader to a texture after it is rendered.
  62037. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62038. */
  62039. export class PostProcessRenderEffect {
  62040. private _postProcesses;
  62041. private _getPostProcesses;
  62042. private _singleInstance;
  62043. private _cameras;
  62044. private _indicesForCamera;
  62045. /**
  62046. * Name of the effect
  62047. * @hidden
  62048. */
  62049. _name: string;
  62050. /**
  62051. * Instantiates a post process render effect.
  62052. * A post process can be used to apply a shader to a texture after it is rendered.
  62053. * @param engine The engine the effect is tied to
  62054. * @param name The name of the effect
  62055. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62056. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62057. */
  62058. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62059. /**
  62060. * Checks if all the post processes in the effect are supported.
  62061. */
  62062. get isSupported(): boolean;
  62063. /**
  62064. * Updates the current state of the effect
  62065. * @hidden
  62066. */
  62067. _update(): void;
  62068. /**
  62069. * Attaches the effect on cameras
  62070. * @param cameras The camera to attach to.
  62071. * @hidden
  62072. */
  62073. _attachCameras(cameras: Camera): void;
  62074. /**
  62075. * Attaches the effect on cameras
  62076. * @param cameras The camera to attach to.
  62077. * @hidden
  62078. */
  62079. _attachCameras(cameras: Camera[]): void;
  62080. /**
  62081. * Detaches the effect on cameras
  62082. * @param cameras The camera to detatch from.
  62083. * @hidden
  62084. */
  62085. _detachCameras(cameras: Camera): void;
  62086. /**
  62087. * Detatches the effect on cameras
  62088. * @param cameras The camera to detatch from.
  62089. * @hidden
  62090. */
  62091. _detachCameras(cameras: Camera[]): void;
  62092. /**
  62093. * Enables the effect on given cameras
  62094. * @param cameras The camera to enable.
  62095. * @hidden
  62096. */
  62097. _enable(cameras: Camera): void;
  62098. /**
  62099. * Enables the effect on given cameras
  62100. * @param cameras The camera to enable.
  62101. * @hidden
  62102. */
  62103. _enable(cameras: Nullable<Camera[]>): void;
  62104. /**
  62105. * Disables the effect on the given cameras
  62106. * @param cameras The camera to disable.
  62107. * @hidden
  62108. */
  62109. _disable(cameras: Camera): void;
  62110. /**
  62111. * Disables the effect on the given cameras
  62112. * @param cameras The camera to disable.
  62113. * @hidden
  62114. */
  62115. _disable(cameras: Nullable<Camera[]>): void;
  62116. /**
  62117. * Gets a list of the post processes contained in the effect.
  62118. * @param camera The camera to get the post processes on.
  62119. * @returns The list of the post processes in the effect.
  62120. */
  62121. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62122. }
  62123. }
  62124. declare module BABYLON {
  62125. /** @hidden */
  62126. export var extractHighlightsPixelShader: {
  62127. name: string;
  62128. shader: string;
  62129. };
  62130. }
  62131. declare module BABYLON {
  62132. /**
  62133. * 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.
  62134. */
  62135. export class ExtractHighlightsPostProcess extends PostProcess {
  62136. /**
  62137. * The luminance threshold, pixels below this value will be set to black.
  62138. */
  62139. threshold: number;
  62140. /** @hidden */
  62141. _exposure: number;
  62142. /**
  62143. * Post process which has the input texture to be used when performing highlight extraction
  62144. * @hidden
  62145. */
  62146. _inputPostProcess: Nullable<PostProcess>;
  62147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62148. }
  62149. }
  62150. declare module BABYLON {
  62151. /** @hidden */
  62152. export var bloomMergePixelShader: {
  62153. name: string;
  62154. shader: string;
  62155. };
  62156. }
  62157. declare module BABYLON {
  62158. /**
  62159. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62160. */
  62161. export class BloomMergePostProcess extends PostProcess {
  62162. /** Weight of the bloom to be added to the original input. */
  62163. weight: number;
  62164. /**
  62165. * Creates a new instance of @see BloomMergePostProcess
  62166. * @param name The name of the effect.
  62167. * @param originalFromInput Post process which's input will be used for the merge.
  62168. * @param blurred Blurred highlights post process which's output will be used.
  62169. * @param weight Weight of the bloom to be added to the original input.
  62170. * @param options The required width/height ratio to downsize to before computing the render pass.
  62171. * @param camera The camera to apply the render pass to.
  62172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62173. * @param engine The engine which the post process will be applied. (default: current engine)
  62174. * @param reusable If the post process can be reused on the same frame. (default: false)
  62175. * @param textureType Type of textures used when performing the post process. (default: 0)
  62176. * @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)
  62177. */
  62178. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62179. /** Weight of the bloom to be added to the original input. */
  62180. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62181. }
  62182. }
  62183. declare module BABYLON {
  62184. /**
  62185. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62186. */
  62187. export class BloomEffect extends PostProcessRenderEffect {
  62188. private bloomScale;
  62189. /**
  62190. * @hidden Internal
  62191. */
  62192. _effects: Array<PostProcess>;
  62193. /**
  62194. * @hidden Internal
  62195. */
  62196. _downscale: ExtractHighlightsPostProcess;
  62197. private _blurX;
  62198. private _blurY;
  62199. private _merge;
  62200. /**
  62201. * The luminance threshold to find bright areas of the image to bloom.
  62202. */
  62203. get threshold(): number;
  62204. set threshold(value: number);
  62205. /**
  62206. * The strength of the bloom.
  62207. */
  62208. get weight(): number;
  62209. set weight(value: number);
  62210. /**
  62211. * Specifies the size of the bloom blur kernel, relative to the final output size
  62212. */
  62213. get kernel(): number;
  62214. set kernel(value: number);
  62215. /**
  62216. * Creates a new instance of @see BloomEffect
  62217. * @param scene The scene the effect belongs to.
  62218. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62219. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62220. * @param bloomWeight The the strength of bloom.
  62221. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62222. * @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)
  62223. */
  62224. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62225. /**
  62226. * Disposes each of the internal effects for a given camera.
  62227. * @param camera The camera to dispose the effect on.
  62228. */
  62229. disposeEffects(camera: Camera): void;
  62230. /**
  62231. * @hidden Internal
  62232. */
  62233. _updateEffects(): void;
  62234. /**
  62235. * Internal
  62236. * @returns if all the contained post processes are ready.
  62237. * @hidden
  62238. */
  62239. _isReady(): boolean;
  62240. }
  62241. }
  62242. declare module BABYLON {
  62243. /** @hidden */
  62244. export var chromaticAberrationPixelShader: {
  62245. name: string;
  62246. shader: string;
  62247. };
  62248. }
  62249. declare module BABYLON {
  62250. /**
  62251. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62252. */
  62253. export class ChromaticAberrationPostProcess extends PostProcess {
  62254. /**
  62255. * The amount of seperation of rgb channels (default: 30)
  62256. */
  62257. aberrationAmount: number;
  62258. /**
  62259. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62260. */
  62261. radialIntensity: number;
  62262. /**
  62263. * 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))
  62264. */
  62265. direction: Vector2;
  62266. /**
  62267. * 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))
  62268. */
  62269. centerPosition: Vector2;
  62270. /**
  62271. * Creates a new instance ChromaticAberrationPostProcess
  62272. * @param name The name of the effect.
  62273. * @param screenWidth The width of the screen to apply the effect on.
  62274. * @param screenHeight The height of the screen to apply the effect on.
  62275. * @param options The required width/height ratio to downsize to before computing the render pass.
  62276. * @param camera The camera to apply the render pass to.
  62277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62278. * @param engine The engine which the post process will be applied. (default: current engine)
  62279. * @param reusable If the post process can be reused on the same frame. (default: false)
  62280. * @param textureType Type of textures used when performing the post process. (default: 0)
  62281. * @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)
  62282. */
  62283. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62284. }
  62285. }
  62286. declare module BABYLON {
  62287. /** @hidden */
  62288. export var circleOfConfusionPixelShader: {
  62289. name: string;
  62290. shader: string;
  62291. };
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62296. */
  62297. export class CircleOfConfusionPostProcess extends PostProcess {
  62298. /**
  62299. * 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.
  62300. */
  62301. lensSize: number;
  62302. /**
  62303. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62304. */
  62305. fStop: number;
  62306. /**
  62307. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62308. */
  62309. focusDistance: number;
  62310. /**
  62311. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62312. */
  62313. focalLength: number;
  62314. private _depthTexture;
  62315. /**
  62316. * Creates a new instance CircleOfConfusionPostProcess
  62317. * @param name The name of the effect.
  62318. * @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.
  62319. * @param options The required width/height ratio to downsize to before computing the render pass.
  62320. * @param camera The camera to apply the render pass to.
  62321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62322. * @param engine The engine which the post process will be applied. (default: current engine)
  62323. * @param reusable If the post process can be reused on the same frame. (default: false)
  62324. * @param textureType Type of textures used when performing the post process. (default: 0)
  62325. * @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)
  62326. */
  62327. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62328. /**
  62329. * 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.
  62330. */
  62331. set depthTexture(value: RenderTargetTexture);
  62332. }
  62333. }
  62334. declare module BABYLON {
  62335. /** @hidden */
  62336. export var colorCorrectionPixelShader: {
  62337. name: string;
  62338. shader: string;
  62339. };
  62340. }
  62341. declare module BABYLON {
  62342. /**
  62343. *
  62344. * This post-process allows the modification of rendered colors by using
  62345. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62346. *
  62347. * The object needs to be provided an url to a texture containing the color
  62348. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62349. * Use an image editing software to tweak the LUT to match your needs.
  62350. *
  62351. * For an example of a color LUT, see here:
  62352. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62353. * For explanations on color grading, see here:
  62354. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62355. *
  62356. */
  62357. export class ColorCorrectionPostProcess extends PostProcess {
  62358. private _colorTableTexture;
  62359. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62360. }
  62361. }
  62362. declare module BABYLON {
  62363. /** @hidden */
  62364. export var convolutionPixelShader: {
  62365. name: string;
  62366. shader: string;
  62367. };
  62368. }
  62369. declare module BABYLON {
  62370. /**
  62371. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62372. * input texture to perform effects such as edge detection or sharpening
  62373. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62374. */
  62375. export class ConvolutionPostProcess extends PostProcess {
  62376. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62377. kernel: number[];
  62378. /**
  62379. * Creates a new instance ConvolutionPostProcess
  62380. * @param name The name of the effect.
  62381. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62382. * @param options The required width/height ratio to downsize to before computing the render pass.
  62383. * @param camera The camera to apply the render pass to.
  62384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62385. * @param engine The engine which the post process will be applied. (default: current engine)
  62386. * @param reusable If the post process can be reused on the same frame. (default: false)
  62387. * @param textureType Type of textures used when performing the post process. (default: 0)
  62388. */
  62389. constructor(name: string,
  62390. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62391. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62392. /**
  62393. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62394. */
  62395. static EdgeDetect0Kernel: number[];
  62396. /**
  62397. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62398. */
  62399. static EdgeDetect1Kernel: number[];
  62400. /**
  62401. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62402. */
  62403. static EdgeDetect2Kernel: number[];
  62404. /**
  62405. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62406. */
  62407. static SharpenKernel: number[];
  62408. /**
  62409. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62410. */
  62411. static EmbossKernel: number[];
  62412. /**
  62413. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62414. */
  62415. static GaussianKernel: number[];
  62416. }
  62417. }
  62418. declare module BABYLON {
  62419. /**
  62420. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62421. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62422. * based on samples that have a large difference in distance than the center pixel.
  62423. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62424. */
  62425. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62426. direction: Vector2;
  62427. /**
  62428. * Creates a new instance CircleOfConfusionPostProcess
  62429. * @param name The name of the effect.
  62430. * @param scene The scene the effect belongs to.
  62431. * @param direction The direction the blur should be applied.
  62432. * @param kernel The size of the kernel used to blur.
  62433. * @param options The required width/height ratio to downsize to before computing the render pass.
  62434. * @param camera The camera to apply the render pass to.
  62435. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62436. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62438. * @param engine The engine which the post process will be applied. (default: current engine)
  62439. * @param reusable If the post process can be reused on the same frame. (default: false)
  62440. * @param textureType Type of textures used when performing the post process. (default: 0)
  62441. * @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)
  62442. */
  62443. 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);
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /** @hidden */
  62448. export var depthOfFieldMergePixelShader: {
  62449. name: string;
  62450. shader: string;
  62451. };
  62452. }
  62453. declare module BABYLON {
  62454. /**
  62455. * Options to be set when merging outputs from the default pipeline.
  62456. */
  62457. export class DepthOfFieldMergePostProcessOptions {
  62458. /**
  62459. * The original image to merge on top of
  62460. */
  62461. originalFromInput: PostProcess;
  62462. /**
  62463. * Parameters to perform the merge of the depth of field effect
  62464. */
  62465. depthOfField?: {
  62466. circleOfConfusion: PostProcess;
  62467. blurSteps: Array<PostProcess>;
  62468. };
  62469. /**
  62470. * Parameters to perform the merge of bloom effect
  62471. */
  62472. bloom?: {
  62473. blurred: PostProcess;
  62474. weight: number;
  62475. };
  62476. }
  62477. /**
  62478. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62479. */
  62480. export class DepthOfFieldMergePostProcess extends PostProcess {
  62481. private blurSteps;
  62482. /**
  62483. * Creates a new instance of DepthOfFieldMergePostProcess
  62484. * @param name The name of the effect.
  62485. * @param originalFromInput Post process which's input will be used for the merge.
  62486. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62487. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62488. * @param options The required width/height ratio to downsize to before computing the render pass.
  62489. * @param camera The camera to apply the render pass to.
  62490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62491. * @param engine The engine which the post process will be applied. (default: current engine)
  62492. * @param reusable If the post process can be reused on the same frame. (default: false)
  62493. * @param textureType Type of textures used when performing the post process. (default: 0)
  62494. * @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)
  62495. */
  62496. 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);
  62497. /**
  62498. * Updates the effect with the current post process compile time values and recompiles the shader.
  62499. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62500. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62501. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62502. * @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
  62503. * @param onCompiled Called when the shader has been compiled.
  62504. * @param onError Called if there is an error when compiling a shader.
  62505. */
  62506. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62507. }
  62508. }
  62509. declare module BABYLON {
  62510. /**
  62511. * Specifies the level of max blur that should be applied when using the depth of field effect
  62512. */
  62513. export enum DepthOfFieldEffectBlurLevel {
  62514. /**
  62515. * Subtle blur
  62516. */
  62517. Low = 0,
  62518. /**
  62519. * Medium blur
  62520. */
  62521. Medium = 1,
  62522. /**
  62523. * Large blur
  62524. */
  62525. High = 2
  62526. }
  62527. /**
  62528. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62529. */
  62530. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62531. private _circleOfConfusion;
  62532. /**
  62533. * @hidden Internal, blurs from high to low
  62534. */
  62535. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62536. private _depthOfFieldBlurY;
  62537. private _dofMerge;
  62538. /**
  62539. * @hidden Internal post processes in depth of field effect
  62540. */
  62541. _effects: Array<PostProcess>;
  62542. /**
  62543. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62544. */
  62545. set focalLength(value: number);
  62546. get focalLength(): number;
  62547. /**
  62548. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62549. */
  62550. set fStop(value: number);
  62551. get fStop(): number;
  62552. /**
  62553. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62554. */
  62555. set focusDistance(value: number);
  62556. get focusDistance(): number;
  62557. /**
  62558. * 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.
  62559. */
  62560. set lensSize(value: number);
  62561. get lensSize(): number;
  62562. /**
  62563. * Creates a new instance DepthOfFieldEffect
  62564. * @param scene The scene the effect belongs to.
  62565. * @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.
  62566. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62567. * @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)
  62568. */
  62569. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62570. /**
  62571. * Get the current class name of the current effet
  62572. * @returns "DepthOfFieldEffect"
  62573. */
  62574. getClassName(): string;
  62575. /**
  62576. * 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.
  62577. */
  62578. set depthTexture(value: RenderTargetTexture);
  62579. /**
  62580. * Disposes each of the internal effects for a given camera.
  62581. * @param camera The camera to dispose the effect on.
  62582. */
  62583. disposeEffects(camera: Camera): void;
  62584. /**
  62585. * @hidden Internal
  62586. */
  62587. _updateEffects(): void;
  62588. /**
  62589. * Internal
  62590. * @returns if all the contained post processes are ready.
  62591. * @hidden
  62592. */
  62593. _isReady(): boolean;
  62594. }
  62595. }
  62596. declare module BABYLON {
  62597. /** @hidden */
  62598. export var displayPassPixelShader: {
  62599. name: string;
  62600. shader: string;
  62601. };
  62602. }
  62603. declare module BABYLON {
  62604. /**
  62605. * DisplayPassPostProcess which produces an output the same as it's input
  62606. */
  62607. export class DisplayPassPostProcess extends PostProcess {
  62608. /**
  62609. * Creates the DisplayPassPostProcess
  62610. * @param name The name of the effect.
  62611. * @param options The required width/height ratio to downsize to before computing the render pass.
  62612. * @param camera The camera to apply the render pass to.
  62613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62614. * @param engine The engine which the post process will be applied. (default: current engine)
  62615. * @param reusable If the post process can be reused on the same frame. (default: false)
  62616. */
  62617. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62618. }
  62619. }
  62620. declare module BABYLON {
  62621. /** @hidden */
  62622. export var filterPixelShader: {
  62623. name: string;
  62624. shader: string;
  62625. };
  62626. }
  62627. declare module BABYLON {
  62628. /**
  62629. * Applies a kernel filter to the image
  62630. */
  62631. export class FilterPostProcess extends PostProcess {
  62632. /** The matrix to be applied to the image */
  62633. kernelMatrix: Matrix;
  62634. /**
  62635. *
  62636. * @param name The name of the effect.
  62637. * @param kernelMatrix The matrix to be applied to the image
  62638. * @param options The required width/height ratio to downsize to before computing the render pass.
  62639. * @param camera The camera to apply the render pass to.
  62640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62641. * @param engine The engine which the post process will be applied. (default: current engine)
  62642. * @param reusable If the post process can be reused on the same frame. (default: false)
  62643. */
  62644. constructor(name: string,
  62645. /** The matrix to be applied to the image */
  62646. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62647. }
  62648. }
  62649. declare module BABYLON {
  62650. /** @hidden */
  62651. export var fxaaPixelShader: {
  62652. name: string;
  62653. shader: string;
  62654. };
  62655. }
  62656. declare module BABYLON {
  62657. /** @hidden */
  62658. export var fxaaVertexShader: {
  62659. name: string;
  62660. shader: string;
  62661. };
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * Fxaa post process
  62666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62667. */
  62668. export class FxaaPostProcess extends PostProcess {
  62669. /** @hidden */
  62670. texelWidth: number;
  62671. /** @hidden */
  62672. texelHeight: number;
  62673. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62674. private _getDefines;
  62675. }
  62676. }
  62677. declare module BABYLON {
  62678. /** @hidden */
  62679. export var grainPixelShader: {
  62680. name: string;
  62681. shader: string;
  62682. };
  62683. }
  62684. declare module BABYLON {
  62685. /**
  62686. * The GrainPostProcess adds noise to the image at mid luminance levels
  62687. */
  62688. export class GrainPostProcess extends PostProcess {
  62689. /**
  62690. * The intensity of the grain added (default: 30)
  62691. */
  62692. intensity: number;
  62693. /**
  62694. * If the grain should be randomized on every frame
  62695. */
  62696. animated: boolean;
  62697. /**
  62698. * Creates a new instance of @see GrainPostProcess
  62699. * @param name The name of the effect.
  62700. * @param options The required width/height ratio to downsize to before computing the render pass.
  62701. * @param camera The camera to apply the render pass to.
  62702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62703. * @param engine The engine which the post process will be applied. (default: current engine)
  62704. * @param reusable If the post process can be reused on the same frame. (default: false)
  62705. * @param textureType Type of textures used when performing the post process. (default: 0)
  62706. * @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)
  62707. */
  62708. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /** @hidden */
  62713. export var highlightsPixelShader: {
  62714. name: string;
  62715. shader: string;
  62716. };
  62717. }
  62718. declare module BABYLON {
  62719. /**
  62720. * Extracts highlights from the image
  62721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62722. */
  62723. export class HighlightsPostProcess extends PostProcess {
  62724. /**
  62725. * Extracts highlights from the image
  62726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62727. * @param name The name of the effect.
  62728. * @param options The required width/height ratio to downsize to before computing the render pass.
  62729. * @param camera The camera to apply the render pass to.
  62730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62731. * @param engine The engine which the post process will be applied. (default: current engine)
  62732. * @param reusable If the post process can be reused on the same frame. (default: false)
  62733. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62734. */
  62735. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62736. }
  62737. }
  62738. declare module BABYLON {
  62739. /** @hidden */
  62740. export var mrtFragmentDeclaration: {
  62741. name: string;
  62742. shader: string;
  62743. };
  62744. }
  62745. declare module BABYLON {
  62746. /** @hidden */
  62747. export var geometryPixelShader: {
  62748. name: string;
  62749. shader: string;
  62750. };
  62751. }
  62752. declare module BABYLON {
  62753. /** @hidden */
  62754. export var geometryVertexShader: {
  62755. name: string;
  62756. shader: string;
  62757. };
  62758. }
  62759. declare module BABYLON {
  62760. /** @hidden */
  62761. interface ISavedTransformationMatrix {
  62762. world: Matrix;
  62763. viewProjection: Matrix;
  62764. }
  62765. /**
  62766. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62767. */
  62768. export class GeometryBufferRenderer {
  62769. /**
  62770. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62771. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62772. */
  62773. static readonly POSITION_TEXTURE_TYPE: number;
  62774. /**
  62775. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62776. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62777. */
  62778. static readonly VELOCITY_TEXTURE_TYPE: number;
  62779. /**
  62780. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62781. * in order to compute objects velocities when enableVelocity is set to "true"
  62782. * @hidden
  62783. */
  62784. _previousTransformationMatrices: {
  62785. [index: number]: ISavedTransformationMatrix;
  62786. };
  62787. /**
  62788. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62789. * in order to compute objects velocities when enableVelocity is set to "true"
  62790. * @hidden
  62791. */
  62792. _previousBonesTransformationMatrices: {
  62793. [index: number]: Float32Array;
  62794. };
  62795. /**
  62796. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62797. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62798. */
  62799. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62800. private _scene;
  62801. private _multiRenderTarget;
  62802. private _ratio;
  62803. private _enablePosition;
  62804. private _enableVelocity;
  62805. private _positionIndex;
  62806. private _velocityIndex;
  62807. protected _effect: Effect;
  62808. protected _cachedDefines: string;
  62809. /**
  62810. * Set the render list (meshes to be rendered) used in the G buffer.
  62811. */
  62812. set renderList(meshes: Mesh[]);
  62813. /**
  62814. * Gets wether or not G buffer are supported by the running hardware.
  62815. * This requires draw buffer supports
  62816. */
  62817. get isSupported(): boolean;
  62818. /**
  62819. * Returns the index of the given texture type in the G-Buffer textures array
  62820. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62821. * @returns the index of the given texture type in the G-Buffer textures array
  62822. */
  62823. getTextureIndex(textureType: number): number;
  62824. /**
  62825. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62826. */
  62827. get enablePosition(): boolean;
  62828. /**
  62829. * Sets whether or not objects positions are enabled for the G buffer.
  62830. */
  62831. set enablePosition(enable: boolean);
  62832. /**
  62833. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62834. */
  62835. get enableVelocity(): boolean;
  62836. /**
  62837. * Sets wether or not objects velocities are enabled for the G buffer.
  62838. */
  62839. set enableVelocity(enable: boolean);
  62840. /**
  62841. * Gets the scene associated with the buffer.
  62842. */
  62843. get scene(): Scene;
  62844. /**
  62845. * Gets the ratio used by the buffer during its creation.
  62846. * How big is the buffer related to the main canvas.
  62847. */
  62848. get ratio(): number;
  62849. /** @hidden */
  62850. static _SceneComponentInitialization: (scene: Scene) => void;
  62851. /**
  62852. * Creates a new G Buffer for the scene
  62853. * @param scene The scene the buffer belongs to
  62854. * @param ratio How big is the buffer related to the main canvas.
  62855. */
  62856. constructor(scene: Scene, ratio?: number);
  62857. /**
  62858. * Checks wether everything is ready to render a submesh to the G buffer.
  62859. * @param subMesh the submesh to check readiness for
  62860. * @param useInstances is the mesh drawn using instance or not
  62861. * @returns true if ready otherwise false
  62862. */
  62863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62864. /**
  62865. * Gets the current underlying G Buffer.
  62866. * @returns the buffer
  62867. */
  62868. getGBuffer(): MultiRenderTarget;
  62869. /**
  62870. * Gets the number of samples used to render the buffer (anti aliasing).
  62871. */
  62872. get samples(): number;
  62873. /**
  62874. * Sets the number of samples used to render the buffer (anti aliasing).
  62875. */
  62876. set samples(value: number);
  62877. /**
  62878. * Disposes the renderer and frees up associated resources.
  62879. */
  62880. dispose(): void;
  62881. protected _createRenderTargets(): void;
  62882. private _copyBonesTransformationMatrices;
  62883. }
  62884. }
  62885. declare module BABYLON {
  62886. interface Scene {
  62887. /** @hidden (Backing field) */
  62888. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62889. /**
  62890. * Gets or Sets the current geometry buffer associated to the scene.
  62891. */
  62892. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62893. /**
  62894. * Enables a GeometryBufferRender and associates it with the scene
  62895. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62896. * @returns the GeometryBufferRenderer
  62897. */
  62898. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62899. /**
  62900. * Disables the GeometryBufferRender associated with the scene
  62901. */
  62902. disableGeometryBufferRenderer(): void;
  62903. }
  62904. /**
  62905. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62906. * in several rendering techniques.
  62907. */
  62908. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62909. /**
  62910. * The component name helpful to identify the component in the list of scene components.
  62911. */
  62912. readonly name: string;
  62913. /**
  62914. * The scene the component belongs to.
  62915. */
  62916. scene: Scene;
  62917. /**
  62918. * Creates a new instance of the component for the given scene
  62919. * @param scene Defines the scene to register the component in
  62920. */
  62921. constructor(scene: Scene);
  62922. /**
  62923. * Registers the component in a given scene
  62924. */
  62925. register(): void;
  62926. /**
  62927. * Rebuilds the elements related to this component in case of
  62928. * context lost for instance.
  62929. */
  62930. rebuild(): void;
  62931. /**
  62932. * Disposes the component and the associated ressources
  62933. */
  62934. dispose(): void;
  62935. private _gatherRenderTargets;
  62936. }
  62937. }
  62938. declare module BABYLON {
  62939. /** @hidden */
  62940. export var motionBlurPixelShader: {
  62941. name: string;
  62942. shader: string;
  62943. };
  62944. }
  62945. declare module BABYLON {
  62946. /**
  62947. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62948. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62949. * As an example, all you have to do is to create the post-process:
  62950. * var mb = new BABYLON.MotionBlurPostProcess(
  62951. * 'mb', // The name of the effect.
  62952. * scene, // The scene containing the objects to blur according to their velocity.
  62953. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62954. * camera // The camera to apply the render pass to.
  62955. * );
  62956. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62957. */
  62958. export class MotionBlurPostProcess extends PostProcess {
  62959. /**
  62960. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62961. */
  62962. motionStrength: number;
  62963. /**
  62964. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62965. */
  62966. get motionBlurSamples(): number;
  62967. /**
  62968. * Sets the number of iterations to be used for motion blur quality
  62969. */
  62970. set motionBlurSamples(samples: number);
  62971. private _motionBlurSamples;
  62972. private _geometryBufferRenderer;
  62973. /**
  62974. * Creates a new instance MotionBlurPostProcess
  62975. * @param name The name of the effect.
  62976. * @param scene The scene containing the objects to blur according to their velocity.
  62977. * @param options The required width/height ratio to downsize to before computing the render pass.
  62978. * @param camera The camera to apply the render pass to.
  62979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62980. * @param engine The engine which the post process will be applied. (default: current engine)
  62981. * @param reusable If the post process can be reused on the same frame. (default: false)
  62982. * @param textureType Type of textures used when performing the post process. (default: 0)
  62983. * @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)
  62984. */
  62985. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62986. /**
  62987. * Excludes the given skinned mesh from computing bones velocities.
  62988. * 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.
  62989. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62990. */
  62991. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62992. /**
  62993. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62994. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62995. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62996. */
  62997. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62998. /**
  62999. * Disposes the post process.
  63000. * @param camera The camera to dispose the post process on.
  63001. */
  63002. dispose(camera?: Camera): void;
  63003. }
  63004. }
  63005. declare module BABYLON {
  63006. /** @hidden */
  63007. export var refractionPixelShader: {
  63008. name: string;
  63009. shader: string;
  63010. };
  63011. }
  63012. declare module BABYLON {
  63013. /**
  63014. * Post process which applies a refractin texture
  63015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63016. */
  63017. export class RefractionPostProcess extends PostProcess {
  63018. /** the base color of the refraction (used to taint the rendering) */
  63019. color: Color3;
  63020. /** simulated refraction depth */
  63021. depth: number;
  63022. /** the coefficient of the base color (0 to remove base color tainting) */
  63023. colorLevel: number;
  63024. private _refTexture;
  63025. private _ownRefractionTexture;
  63026. /**
  63027. * Gets or sets the refraction texture
  63028. * Please note that you are responsible for disposing the texture if you set it manually
  63029. */
  63030. get refractionTexture(): Texture;
  63031. set refractionTexture(value: Texture);
  63032. /**
  63033. * Initializes the RefractionPostProcess
  63034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63035. * @param name The name of the effect.
  63036. * @param refractionTextureUrl Url of the refraction texture to use
  63037. * @param color the base color of the refraction (used to taint the rendering)
  63038. * @param depth simulated refraction depth
  63039. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63040. * @param camera The camera to apply the render pass to.
  63041. * @param options The required width/height ratio to downsize to before computing the render pass.
  63042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63043. * @param engine The engine which the post process will be applied. (default: current engine)
  63044. * @param reusable If the post process can be reused on the same frame. (default: false)
  63045. */
  63046. constructor(name: string, refractionTextureUrl: string,
  63047. /** the base color of the refraction (used to taint the rendering) */
  63048. color: Color3,
  63049. /** simulated refraction depth */
  63050. depth: number,
  63051. /** the coefficient of the base color (0 to remove base color tainting) */
  63052. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63053. /**
  63054. * Disposes of the post process
  63055. * @param camera Camera to dispose post process on
  63056. */
  63057. dispose(camera: Camera): void;
  63058. }
  63059. }
  63060. declare module BABYLON {
  63061. /** @hidden */
  63062. export var sharpenPixelShader: {
  63063. name: string;
  63064. shader: string;
  63065. };
  63066. }
  63067. declare module BABYLON {
  63068. /**
  63069. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63070. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63071. */
  63072. export class SharpenPostProcess extends PostProcess {
  63073. /**
  63074. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63075. */
  63076. colorAmount: number;
  63077. /**
  63078. * How much sharpness should be applied (default: 0.3)
  63079. */
  63080. edgeAmount: number;
  63081. /**
  63082. * Creates a new instance ConvolutionPostProcess
  63083. * @param name The name of the effect.
  63084. * @param options The required width/height ratio to downsize to before computing the render pass.
  63085. * @param camera The camera to apply the render pass to.
  63086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63087. * @param engine The engine which the post process will be applied. (default: current engine)
  63088. * @param reusable If the post process can be reused on the same frame. (default: false)
  63089. * @param textureType Type of textures used when performing the post process. (default: 0)
  63090. * @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)
  63091. */
  63092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63093. }
  63094. }
  63095. declare module BABYLON {
  63096. /**
  63097. * PostProcessRenderPipeline
  63098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63099. */
  63100. export class PostProcessRenderPipeline {
  63101. private engine;
  63102. private _renderEffects;
  63103. private _renderEffectsForIsolatedPass;
  63104. /**
  63105. * List of inspectable custom properties (used by the Inspector)
  63106. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63107. */
  63108. inspectableCustomProperties: IInspectable[];
  63109. /**
  63110. * @hidden
  63111. */
  63112. protected _cameras: Camera[];
  63113. /** @hidden */
  63114. _name: string;
  63115. /**
  63116. * Gets pipeline name
  63117. */
  63118. get name(): string;
  63119. /** Gets the list of attached cameras */
  63120. get cameras(): Camera[];
  63121. /**
  63122. * Initializes a PostProcessRenderPipeline
  63123. * @param engine engine to add the pipeline to
  63124. * @param name name of the pipeline
  63125. */
  63126. constructor(engine: Engine, name: string);
  63127. /**
  63128. * Gets the class name
  63129. * @returns "PostProcessRenderPipeline"
  63130. */
  63131. getClassName(): string;
  63132. /**
  63133. * If all the render effects in the pipeline are supported
  63134. */
  63135. get isSupported(): boolean;
  63136. /**
  63137. * Adds an effect to the pipeline
  63138. * @param renderEffect the effect to add
  63139. */
  63140. addEffect(renderEffect: PostProcessRenderEffect): void;
  63141. /** @hidden */
  63142. _rebuild(): void;
  63143. /** @hidden */
  63144. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63145. /** @hidden */
  63146. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63147. /** @hidden */
  63148. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63149. /** @hidden */
  63150. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63151. /** @hidden */
  63152. _attachCameras(cameras: Camera, unique: boolean): void;
  63153. /** @hidden */
  63154. _attachCameras(cameras: Camera[], unique: boolean): void;
  63155. /** @hidden */
  63156. _detachCameras(cameras: Camera): void;
  63157. /** @hidden */
  63158. _detachCameras(cameras: Nullable<Camera[]>): void;
  63159. /** @hidden */
  63160. _update(): void;
  63161. /** @hidden */
  63162. _reset(): void;
  63163. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63164. /**
  63165. * Disposes of the pipeline
  63166. */
  63167. dispose(): void;
  63168. }
  63169. }
  63170. declare module BABYLON {
  63171. /**
  63172. * PostProcessRenderPipelineManager class
  63173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63174. */
  63175. export class PostProcessRenderPipelineManager {
  63176. private _renderPipelines;
  63177. /**
  63178. * Initializes a PostProcessRenderPipelineManager
  63179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63180. */
  63181. constructor();
  63182. /**
  63183. * Gets the list of supported render pipelines
  63184. */
  63185. get supportedPipelines(): PostProcessRenderPipeline[];
  63186. /**
  63187. * Adds a pipeline to the manager
  63188. * @param renderPipeline The pipeline to add
  63189. */
  63190. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63191. /**
  63192. * Attaches a camera to the pipeline
  63193. * @param renderPipelineName The name of the pipeline to attach to
  63194. * @param cameras the camera to attach
  63195. * @param unique if the camera can be attached multiple times to the pipeline
  63196. */
  63197. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63198. /**
  63199. * Detaches a camera from the pipeline
  63200. * @param renderPipelineName The name of the pipeline to detach from
  63201. * @param cameras the camera to detach
  63202. */
  63203. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63204. /**
  63205. * Enables an effect by name on a pipeline
  63206. * @param renderPipelineName the name of the pipeline to enable the effect in
  63207. * @param renderEffectName the name of the effect to enable
  63208. * @param cameras the cameras that the effect should be enabled on
  63209. */
  63210. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63211. /**
  63212. * Disables an effect by name on a pipeline
  63213. * @param renderPipelineName the name of the pipeline to disable the effect in
  63214. * @param renderEffectName the name of the effect to disable
  63215. * @param cameras the cameras that the effect should be disabled on
  63216. */
  63217. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63218. /**
  63219. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63220. */
  63221. update(): void;
  63222. /** @hidden */
  63223. _rebuild(): void;
  63224. /**
  63225. * Disposes of the manager and pipelines
  63226. */
  63227. dispose(): void;
  63228. }
  63229. }
  63230. declare module BABYLON {
  63231. interface Scene {
  63232. /** @hidden (Backing field) */
  63233. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63234. /**
  63235. * Gets the postprocess render pipeline manager
  63236. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63237. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63238. */
  63239. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63240. }
  63241. /**
  63242. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63243. */
  63244. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63245. /**
  63246. * The component name helpfull to identify the component in the list of scene components.
  63247. */
  63248. readonly name: string;
  63249. /**
  63250. * The scene the component belongs to.
  63251. */
  63252. scene: Scene;
  63253. /**
  63254. * Creates a new instance of the component for the given scene
  63255. * @param scene Defines the scene to register the component in
  63256. */
  63257. constructor(scene: Scene);
  63258. /**
  63259. * Registers the component in a given scene
  63260. */
  63261. register(): void;
  63262. /**
  63263. * Rebuilds the elements related to this component in case of
  63264. * context lost for instance.
  63265. */
  63266. rebuild(): void;
  63267. /**
  63268. * Disposes the component and the associated ressources
  63269. */
  63270. dispose(): void;
  63271. private _gatherRenderTargets;
  63272. }
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63277. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63278. */
  63279. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63280. private _scene;
  63281. private _camerasToBeAttached;
  63282. /**
  63283. * ID of the sharpen post process,
  63284. */
  63285. private readonly SharpenPostProcessId;
  63286. /**
  63287. * @ignore
  63288. * ID of the image processing post process;
  63289. */
  63290. readonly ImageProcessingPostProcessId: string;
  63291. /**
  63292. * @ignore
  63293. * ID of the Fast Approximate Anti-Aliasing post process;
  63294. */
  63295. readonly FxaaPostProcessId: string;
  63296. /**
  63297. * ID of the chromatic aberration post process,
  63298. */
  63299. private readonly ChromaticAberrationPostProcessId;
  63300. /**
  63301. * ID of the grain post process
  63302. */
  63303. private readonly GrainPostProcessId;
  63304. /**
  63305. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63306. */
  63307. sharpen: SharpenPostProcess;
  63308. private _sharpenEffect;
  63309. private bloom;
  63310. /**
  63311. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63312. */
  63313. depthOfField: DepthOfFieldEffect;
  63314. /**
  63315. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63316. */
  63317. fxaa: FxaaPostProcess;
  63318. /**
  63319. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63320. */
  63321. imageProcessing: ImageProcessingPostProcess;
  63322. /**
  63323. * Chromatic aberration post process which will shift rgb colors in the image
  63324. */
  63325. chromaticAberration: ChromaticAberrationPostProcess;
  63326. private _chromaticAberrationEffect;
  63327. /**
  63328. * Grain post process which add noise to the image
  63329. */
  63330. grain: GrainPostProcess;
  63331. private _grainEffect;
  63332. /**
  63333. * Glow post process which adds a glow to emissive areas of the image
  63334. */
  63335. private _glowLayer;
  63336. /**
  63337. * Animations which can be used to tweak settings over a period of time
  63338. */
  63339. animations: Animation[];
  63340. private _imageProcessingConfigurationObserver;
  63341. private _sharpenEnabled;
  63342. private _bloomEnabled;
  63343. private _depthOfFieldEnabled;
  63344. private _depthOfFieldBlurLevel;
  63345. private _fxaaEnabled;
  63346. private _imageProcessingEnabled;
  63347. private _defaultPipelineTextureType;
  63348. private _bloomScale;
  63349. private _chromaticAberrationEnabled;
  63350. private _grainEnabled;
  63351. private _buildAllowed;
  63352. /**
  63353. * Gets active scene
  63354. */
  63355. get scene(): Scene;
  63356. /**
  63357. * Enable or disable the sharpen process from the pipeline
  63358. */
  63359. set sharpenEnabled(enabled: boolean);
  63360. get sharpenEnabled(): boolean;
  63361. private _resizeObserver;
  63362. private _hardwareScaleLevel;
  63363. private _bloomKernel;
  63364. /**
  63365. * Specifies the size of the bloom blur kernel, relative to the final output size
  63366. */
  63367. get bloomKernel(): number;
  63368. set bloomKernel(value: number);
  63369. /**
  63370. * Specifies the weight of the bloom in the final rendering
  63371. */
  63372. private _bloomWeight;
  63373. /**
  63374. * Specifies the luma threshold for the area that will be blurred by the bloom
  63375. */
  63376. private _bloomThreshold;
  63377. private _hdr;
  63378. /**
  63379. * The strength of the bloom.
  63380. */
  63381. set bloomWeight(value: number);
  63382. get bloomWeight(): number;
  63383. /**
  63384. * The strength of the bloom.
  63385. */
  63386. set bloomThreshold(value: number);
  63387. get bloomThreshold(): number;
  63388. /**
  63389. * The scale of the bloom, lower value will provide better performance.
  63390. */
  63391. set bloomScale(value: number);
  63392. get bloomScale(): number;
  63393. /**
  63394. * Enable or disable the bloom from the pipeline
  63395. */
  63396. set bloomEnabled(enabled: boolean);
  63397. get bloomEnabled(): boolean;
  63398. private _rebuildBloom;
  63399. /**
  63400. * If the depth of field is enabled.
  63401. */
  63402. get depthOfFieldEnabled(): boolean;
  63403. set depthOfFieldEnabled(enabled: boolean);
  63404. /**
  63405. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63406. */
  63407. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63408. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63409. /**
  63410. * If the anti aliasing is enabled.
  63411. */
  63412. set fxaaEnabled(enabled: boolean);
  63413. get fxaaEnabled(): boolean;
  63414. private _samples;
  63415. /**
  63416. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63417. */
  63418. set samples(sampleCount: number);
  63419. get samples(): number;
  63420. /**
  63421. * If image processing is enabled.
  63422. */
  63423. set imageProcessingEnabled(enabled: boolean);
  63424. get imageProcessingEnabled(): boolean;
  63425. /**
  63426. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63427. */
  63428. set glowLayerEnabled(enabled: boolean);
  63429. get glowLayerEnabled(): boolean;
  63430. /**
  63431. * Gets the glow layer (or null if not defined)
  63432. */
  63433. get glowLayer(): Nullable<GlowLayer>;
  63434. /**
  63435. * Enable or disable the chromaticAberration process from the pipeline
  63436. */
  63437. set chromaticAberrationEnabled(enabled: boolean);
  63438. get chromaticAberrationEnabled(): boolean;
  63439. /**
  63440. * Enable or disable the grain process from the pipeline
  63441. */
  63442. set grainEnabled(enabled: boolean);
  63443. get grainEnabled(): boolean;
  63444. /**
  63445. * @constructor
  63446. * @param name - The rendering pipeline name (default: "")
  63447. * @param hdr - If high dynamic range textures should be used (default: true)
  63448. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63449. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63450. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63451. */
  63452. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63453. /**
  63454. * Get the class name
  63455. * @returns "DefaultRenderingPipeline"
  63456. */
  63457. getClassName(): string;
  63458. /**
  63459. * Force the compilation of the entire pipeline.
  63460. */
  63461. prepare(): void;
  63462. private _hasCleared;
  63463. private _prevPostProcess;
  63464. private _prevPrevPostProcess;
  63465. private _setAutoClearAndTextureSharing;
  63466. private _depthOfFieldSceneObserver;
  63467. private _buildPipeline;
  63468. private _disposePostProcesses;
  63469. /**
  63470. * Adds a camera to the pipeline
  63471. * @param camera the camera to be added
  63472. */
  63473. addCamera(camera: Camera): void;
  63474. /**
  63475. * Removes a camera from the pipeline
  63476. * @param camera the camera to remove
  63477. */
  63478. removeCamera(camera: Camera): void;
  63479. /**
  63480. * Dispose of the pipeline and stop all post processes
  63481. */
  63482. dispose(): void;
  63483. /**
  63484. * Serialize the rendering pipeline (Used when exporting)
  63485. * @returns the serialized object
  63486. */
  63487. serialize(): any;
  63488. /**
  63489. * Parse the serialized pipeline
  63490. * @param source Source pipeline.
  63491. * @param scene The scene to load the pipeline to.
  63492. * @param rootUrl The URL of the serialized pipeline.
  63493. * @returns An instantiated pipeline from the serialized object.
  63494. */
  63495. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. /** @hidden */
  63500. export var lensHighlightsPixelShader: {
  63501. name: string;
  63502. shader: string;
  63503. };
  63504. }
  63505. declare module BABYLON {
  63506. /** @hidden */
  63507. export var depthOfFieldPixelShader: {
  63508. name: string;
  63509. shader: string;
  63510. };
  63511. }
  63512. declare module BABYLON {
  63513. /**
  63514. * BABYLON.JS Chromatic Aberration GLSL Shader
  63515. * Author: Olivier Guyot
  63516. * Separates very slightly R, G and B colors on the edges of the screen
  63517. * Inspired by Francois Tarlier & Martins Upitis
  63518. */
  63519. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63520. /**
  63521. * @ignore
  63522. * The chromatic aberration PostProcess id in the pipeline
  63523. */
  63524. LensChromaticAberrationEffect: string;
  63525. /**
  63526. * @ignore
  63527. * The highlights enhancing PostProcess id in the pipeline
  63528. */
  63529. HighlightsEnhancingEffect: string;
  63530. /**
  63531. * @ignore
  63532. * The depth-of-field PostProcess id in the pipeline
  63533. */
  63534. LensDepthOfFieldEffect: string;
  63535. private _scene;
  63536. private _depthTexture;
  63537. private _grainTexture;
  63538. private _chromaticAberrationPostProcess;
  63539. private _highlightsPostProcess;
  63540. private _depthOfFieldPostProcess;
  63541. private _edgeBlur;
  63542. private _grainAmount;
  63543. private _chromaticAberration;
  63544. private _distortion;
  63545. private _highlightsGain;
  63546. private _highlightsThreshold;
  63547. private _dofDistance;
  63548. private _dofAperture;
  63549. private _dofDarken;
  63550. private _dofPentagon;
  63551. private _blurNoise;
  63552. /**
  63553. * @constructor
  63554. *
  63555. * Effect parameters are as follow:
  63556. * {
  63557. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63558. * edge_blur: number; // from 0 to x (1 for realism)
  63559. * distortion: number; // from 0 to x (1 for realism)
  63560. * grain_amount: number; // from 0 to 1
  63561. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63562. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63563. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63564. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63565. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63566. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63567. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63568. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63569. * }
  63570. * Note: if an effect parameter is unset, effect is disabled
  63571. *
  63572. * @param name The rendering pipeline name
  63573. * @param parameters - An object containing all parameters (see above)
  63574. * @param scene The scene linked to this pipeline
  63575. * @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)
  63576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63577. */
  63578. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63579. /**
  63580. * Get the class name
  63581. * @returns "LensRenderingPipeline"
  63582. */
  63583. getClassName(): string;
  63584. /**
  63585. * Gets associated scene
  63586. */
  63587. get scene(): Scene;
  63588. /**
  63589. * Gets or sets the edge blur
  63590. */
  63591. get edgeBlur(): number;
  63592. set edgeBlur(value: number);
  63593. /**
  63594. * Gets or sets the grain amount
  63595. */
  63596. get grainAmount(): number;
  63597. set grainAmount(value: number);
  63598. /**
  63599. * Gets or sets the chromatic aberration amount
  63600. */
  63601. get chromaticAberration(): number;
  63602. set chromaticAberration(value: number);
  63603. /**
  63604. * Gets or sets the depth of field aperture
  63605. */
  63606. get dofAperture(): number;
  63607. set dofAperture(value: number);
  63608. /**
  63609. * Gets or sets the edge distortion
  63610. */
  63611. get edgeDistortion(): number;
  63612. set edgeDistortion(value: number);
  63613. /**
  63614. * Gets or sets the depth of field distortion
  63615. */
  63616. get dofDistortion(): number;
  63617. set dofDistortion(value: number);
  63618. /**
  63619. * Gets or sets the darken out of focus amount
  63620. */
  63621. get darkenOutOfFocus(): number;
  63622. set darkenOutOfFocus(value: number);
  63623. /**
  63624. * Gets or sets a boolean indicating if blur noise is enabled
  63625. */
  63626. get blurNoise(): boolean;
  63627. set blurNoise(value: boolean);
  63628. /**
  63629. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63630. */
  63631. get pentagonBokeh(): boolean;
  63632. set pentagonBokeh(value: boolean);
  63633. /**
  63634. * Gets or sets the highlight grain amount
  63635. */
  63636. get highlightsGain(): number;
  63637. set highlightsGain(value: number);
  63638. /**
  63639. * Gets or sets the highlight threshold
  63640. */
  63641. get highlightsThreshold(): number;
  63642. set highlightsThreshold(value: number);
  63643. /**
  63644. * Sets the amount of blur at the edges
  63645. * @param amount blur amount
  63646. */
  63647. setEdgeBlur(amount: number): void;
  63648. /**
  63649. * Sets edge blur to 0
  63650. */
  63651. disableEdgeBlur(): void;
  63652. /**
  63653. * Sets the amout of grain
  63654. * @param amount Amount of grain
  63655. */
  63656. setGrainAmount(amount: number): void;
  63657. /**
  63658. * Set grain amount to 0
  63659. */
  63660. disableGrain(): void;
  63661. /**
  63662. * Sets the chromatic aberration amount
  63663. * @param amount amount of chromatic aberration
  63664. */
  63665. setChromaticAberration(amount: number): void;
  63666. /**
  63667. * Sets chromatic aberration amount to 0
  63668. */
  63669. disableChromaticAberration(): void;
  63670. /**
  63671. * Sets the EdgeDistortion amount
  63672. * @param amount amount of EdgeDistortion
  63673. */
  63674. setEdgeDistortion(amount: number): void;
  63675. /**
  63676. * Sets edge distortion to 0
  63677. */
  63678. disableEdgeDistortion(): void;
  63679. /**
  63680. * Sets the FocusDistance amount
  63681. * @param amount amount of FocusDistance
  63682. */
  63683. setFocusDistance(amount: number): void;
  63684. /**
  63685. * Disables depth of field
  63686. */
  63687. disableDepthOfField(): void;
  63688. /**
  63689. * Sets the Aperture amount
  63690. * @param amount amount of Aperture
  63691. */
  63692. setAperture(amount: number): void;
  63693. /**
  63694. * Sets the DarkenOutOfFocus amount
  63695. * @param amount amount of DarkenOutOfFocus
  63696. */
  63697. setDarkenOutOfFocus(amount: number): void;
  63698. private _pentagonBokehIsEnabled;
  63699. /**
  63700. * Creates a pentagon bokeh effect
  63701. */
  63702. enablePentagonBokeh(): void;
  63703. /**
  63704. * Disables the pentagon bokeh effect
  63705. */
  63706. disablePentagonBokeh(): void;
  63707. /**
  63708. * Enables noise blur
  63709. */
  63710. enableNoiseBlur(): void;
  63711. /**
  63712. * Disables noise blur
  63713. */
  63714. disableNoiseBlur(): void;
  63715. /**
  63716. * Sets the HighlightsGain amount
  63717. * @param amount amount of HighlightsGain
  63718. */
  63719. setHighlightsGain(amount: number): void;
  63720. /**
  63721. * Sets the HighlightsThreshold amount
  63722. * @param amount amount of HighlightsThreshold
  63723. */
  63724. setHighlightsThreshold(amount: number): void;
  63725. /**
  63726. * Disables highlights
  63727. */
  63728. disableHighlights(): void;
  63729. /**
  63730. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63731. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63732. */
  63733. dispose(disableDepthRender?: boolean): void;
  63734. private _createChromaticAberrationPostProcess;
  63735. private _createHighlightsPostProcess;
  63736. private _createDepthOfFieldPostProcess;
  63737. private _createGrainTexture;
  63738. }
  63739. }
  63740. declare module BABYLON {
  63741. /** @hidden */
  63742. export var ssao2PixelShader: {
  63743. name: string;
  63744. shader: string;
  63745. };
  63746. }
  63747. declare module BABYLON {
  63748. /** @hidden */
  63749. export var ssaoCombinePixelShader: {
  63750. name: string;
  63751. shader: string;
  63752. };
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Render pipeline to produce ssao effect
  63757. */
  63758. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63759. /**
  63760. * @ignore
  63761. * The PassPostProcess id in the pipeline that contains the original scene color
  63762. */
  63763. SSAOOriginalSceneColorEffect: string;
  63764. /**
  63765. * @ignore
  63766. * The SSAO PostProcess id in the pipeline
  63767. */
  63768. SSAORenderEffect: string;
  63769. /**
  63770. * @ignore
  63771. * The horizontal blur PostProcess id in the pipeline
  63772. */
  63773. SSAOBlurHRenderEffect: string;
  63774. /**
  63775. * @ignore
  63776. * The vertical blur PostProcess id in the pipeline
  63777. */
  63778. SSAOBlurVRenderEffect: string;
  63779. /**
  63780. * @ignore
  63781. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63782. */
  63783. SSAOCombineRenderEffect: string;
  63784. /**
  63785. * The output strength of the SSAO post-process. Default value is 1.0.
  63786. */
  63787. totalStrength: number;
  63788. /**
  63789. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63790. */
  63791. maxZ: number;
  63792. /**
  63793. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63794. */
  63795. minZAspect: number;
  63796. private _samples;
  63797. /**
  63798. * Number of samples used for the SSAO calculations. Default value is 8
  63799. */
  63800. set samples(n: number);
  63801. get samples(): number;
  63802. private _textureSamples;
  63803. /**
  63804. * Number of samples to use for antialiasing
  63805. */
  63806. set textureSamples(n: number);
  63807. get textureSamples(): number;
  63808. /**
  63809. * Ratio object used for SSAO ratio and blur ratio
  63810. */
  63811. private _ratio;
  63812. /**
  63813. * Dynamically generated sphere sampler.
  63814. */
  63815. private _sampleSphere;
  63816. /**
  63817. * Blur filter offsets
  63818. */
  63819. private _samplerOffsets;
  63820. private _expensiveBlur;
  63821. /**
  63822. * If bilateral blur should be used
  63823. */
  63824. set expensiveBlur(b: boolean);
  63825. get expensiveBlur(): boolean;
  63826. /**
  63827. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63828. */
  63829. radius: number;
  63830. /**
  63831. * The base color of the SSAO post-process
  63832. * The final result is "base + ssao" between [0, 1]
  63833. */
  63834. base: number;
  63835. /**
  63836. * Support test.
  63837. */
  63838. static get IsSupported(): boolean;
  63839. private _scene;
  63840. private _depthTexture;
  63841. private _normalTexture;
  63842. private _randomTexture;
  63843. private _originalColorPostProcess;
  63844. private _ssaoPostProcess;
  63845. private _blurHPostProcess;
  63846. private _blurVPostProcess;
  63847. private _ssaoCombinePostProcess;
  63848. /**
  63849. * Gets active scene
  63850. */
  63851. get scene(): Scene;
  63852. /**
  63853. * @constructor
  63854. * @param name The rendering pipeline name
  63855. * @param scene The scene linked to this pipeline
  63856. * @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 }
  63857. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63858. */
  63859. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63860. /**
  63861. * Get the class name
  63862. * @returns "SSAO2RenderingPipeline"
  63863. */
  63864. getClassName(): string;
  63865. /**
  63866. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63867. */
  63868. dispose(disableGeometryBufferRenderer?: boolean): void;
  63869. private _createBlurPostProcess;
  63870. /** @hidden */
  63871. _rebuild(): void;
  63872. private _bits;
  63873. private _radicalInverse_VdC;
  63874. private _hammersley;
  63875. private _hemisphereSample_uniform;
  63876. private _generateHemisphere;
  63877. private _createSSAOPostProcess;
  63878. private _createSSAOCombinePostProcess;
  63879. private _createRandomTexture;
  63880. /**
  63881. * Serialize the rendering pipeline (Used when exporting)
  63882. * @returns the serialized object
  63883. */
  63884. serialize(): any;
  63885. /**
  63886. * Parse the serialized pipeline
  63887. * @param source Source pipeline.
  63888. * @param scene The scene to load the pipeline to.
  63889. * @param rootUrl The URL of the serialized pipeline.
  63890. * @returns An instantiated pipeline from the serialized object.
  63891. */
  63892. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63893. }
  63894. }
  63895. declare module BABYLON {
  63896. /** @hidden */
  63897. export var ssaoPixelShader: {
  63898. name: string;
  63899. shader: string;
  63900. };
  63901. }
  63902. declare module BABYLON {
  63903. /**
  63904. * Render pipeline to produce ssao effect
  63905. */
  63906. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63907. /**
  63908. * @ignore
  63909. * The PassPostProcess id in the pipeline that contains the original scene color
  63910. */
  63911. SSAOOriginalSceneColorEffect: string;
  63912. /**
  63913. * @ignore
  63914. * The SSAO PostProcess id in the pipeline
  63915. */
  63916. SSAORenderEffect: string;
  63917. /**
  63918. * @ignore
  63919. * The horizontal blur PostProcess id in the pipeline
  63920. */
  63921. SSAOBlurHRenderEffect: string;
  63922. /**
  63923. * @ignore
  63924. * The vertical blur PostProcess id in the pipeline
  63925. */
  63926. SSAOBlurVRenderEffect: string;
  63927. /**
  63928. * @ignore
  63929. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63930. */
  63931. SSAOCombineRenderEffect: string;
  63932. /**
  63933. * The output strength of the SSAO post-process. Default value is 1.0.
  63934. */
  63935. totalStrength: number;
  63936. /**
  63937. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63938. */
  63939. radius: number;
  63940. /**
  63941. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63942. * Must not be equal to fallOff and superior to fallOff.
  63943. * Default value is 0.0075
  63944. */
  63945. area: number;
  63946. /**
  63947. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63948. * Must not be equal to area and inferior to area.
  63949. * Default value is 0.000001
  63950. */
  63951. fallOff: number;
  63952. /**
  63953. * The base color of the SSAO post-process
  63954. * The final result is "base + ssao" between [0, 1]
  63955. */
  63956. base: number;
  63957. private _scene;
  63958. private _depthTexture;
  63959. private _randomTexture;
  63960. private _originalColorPostProcess;
  63961. private _ssaoPostProcess;
  63962. private _blurHPostProcess;
  63963. private _blurVPostProcess;
  63964. private _ssaoCombinePostProcess;
  63965. private _firstUpdate;
  63966. /**
  63967. * Gets active scene
  63968. */
  63969. get scene(): Scene;
  63970. /**
  63971. * @constructor
  63972. * @param name - The rendering pipeline name
  63973. * @param scene - The scene linked to this pipeline
  63974. * @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 }
  63975. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63976. */
  63977. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63978. /**
  63979. * Get the class name
  63980. * @returns "SSAORenderingPipeline"
  63981. */
  63982. getClassName(): string;
  63983. /**
  63984. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63985. */
  63986. dispose(disableDepthRender?: boolean): void;
  63987. private _createBlurPostProcess;
  63988. /** @hidden */
  63989. _rebuild(): void;
  63990. private _createSSAOPostProcess;
  63991. private _createSSAOCombinePostProcess;
  63992. private _createRandomTexture;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /** @hidden */
  63997. export var standardPixelShader: {
  63998. name: string;
  63999. shader: string;
  64000. };
  64001. }
  64002. declare module BABYLON {
  64003. /**
  64004. * Standard rendering pipeline
  64005. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64006. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64007. */
  64008. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64009. /**
  64010. * Public members
  64011. */
  64012. /**
  64013. * Post-process which contains the original scene color before the pipeline applies all the effects
  64014. */
  64015. originalPostProcess: Nullable<PostProcess>;
  64016. /**
  64017. * Post-process used to down scale an image x4
  64018. */
  64019. downSampleX4PostProcess: Nullable<PostProcess>;
  64020. /**
  64021. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64022. */
  64023. brightPassPostProcess: Nullable<PostProcess>;
  64024. /**
  64025. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64026. */
  64027. blurHPostProcesses: PostProcess[];
  64028. /**
  64029. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64030. */
  64031. blurVPostProcesses: PostProcess[];
  64032. /**
  64033. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64034. */
  64035. textureAdderPostProcess: Nullable<PostProcess>;
  64036. /**
  64037. * Post-process used to create volumetric lighting effect
  64038. */
  64039. volumetricLightPostProcess: Nullable<PostProcess>;
  64040. /**
  64041. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64042. */
  64043. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64044. /**
  64045. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64046. */
  64047. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64048. /**
  64049. * Post-process used to merge the volumetric light effect and the real scene color
  64050. */
  64051. volumetricLightMergePostProces: Nullable<PostProcess>;
  64052. /**
  64053. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64054. */
  64055. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64056. /**
  64057. * Base post-process used to calculate the average luminance of the final image for HDR
  64058. */
  64059. luminancePostProcess: Nullable<PostProcess>;
  64060. /**
  64061. * Post-processes used to create down sample post-processes in order to get
  64062. * the average luminance of the final image for HDR
  64063. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64064. */
  64065. luminanceDownSamplePostProcesses: PostProcess[];
  64066. /**
  64067. * Post-process used to create a HDR effect (light adaptation)
  64068. */
  64069. hdrPostProcess: Nullable<PostProcess>;
  64070. /**
  64071. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64072. */
  64073. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64074. /**
  64075. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64076. */
  64077. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64078. /**
  64079. * Post-process used to merge the final HDR post-process and the real scene color
  64080. */
  64081. hdrFinalPostProcess: Nullable<PostProcess>;
  64082. /**
  64083. * Post-process used to create a lens flare effect
  64084. */
  64085. lensFlarePostProcess: Nullable<PostProcess>;
  64086. /**
  64087. * Post-process that merges the result of the lens flare post-process and the real scene color
  64088. */
  64089. lensFlareComposePostProcess: Nullable<PostProcess>;
  64090. /**
  64091. * Post-process used to create a motion blur effect
  64092. */
  64093. motionBlurPostProcess: Nullable<PostProcess>;
  64094. /**
  64095. * Post-process used to create a depth of field effect
  64096. */
  64097. depthOfFieldPostProcess: Nullable<PostProcess>;
  64098. /**
  64099. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64100. */
  64101. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64102. /**
  64103. * Represents the brightness threshold in order to configure the illuminated surfaces
  64104. */
  64105. brightThreshold: number;
  64106. /**
  64107. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64108. */
  64109. blurWidth: number;
  64110. /**
  64111. * Sets if the blur for highlighted surfaces must be only horizontal
  64112. */
  64113. horizontalBlur: boolean;
  64114. /**
  64115. * Gets the overall exposure used by the pipeline
  64116. */
  64117. get exposure(): number;
  64118. /**
  64119. * Sets the overall exposure used by the pipeline
  64120. */
  64121. set exposure(value: number);
  64122. /**
  64123. * Texture used typically to simulate "dirty" on camera lens
  64124. */
  64125. lensTexture: Nullable<Texture>;
  64126. /**
  64127. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64128. */
  64129. volumetricLightCoefficient: number;
  64130. /**
  64131. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64132. */
  64133. volumetricLightPower: number;
  64134. /**
  64135. * Used the set the blur intensity to smooth the volumetric lights
  64136. */
  64137. volumetricLightBlurScale: number;
  64138. /**
  64139. * Light (spot or directional) used to generate the volumetric lights rays
  64140. * The source light must have a shadow generate so the pipeline can get its
  64141. * depth map
  64142. */
  64143. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64144. /**
  64145. * For eye adaptation, represents the minimum luminance the eye can see
  64146. */
  64147. hdrMinimumLuminance: number;
  64148. /**
  64149. * For eye adaptation, represents the decrease luminance speed
  64150. */
  64151. hdrDecreaseRate: number;
  64152. /**
  64153. * For eye adaptation, represents the increase luminance speed
  64154. */
  64155. hdrIncreaseRate: number;
  64156. /**
  64157. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64158. */
  64159. get hdrAutoExposure(): boolean;
  64160. /**
  64161. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64162. */
  64163. set hdrAutoExposure(value: boolean);
  64164. /**
  64165. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64166. */
  64167. lensColorTexture: Nullable<Texture>;
  64168. /**
  64169. * The overall strengh for the lens flare effect
  64170. */
  64171. lensFlareStrength: number;
  64172. /**
  64173. * Dispersion coefficient for lens flare ghosts
  64174. */
  64175. lensFlareGhostDispersal: number;
  64176. /**
  64177. * Main lens flare halo width
  64178. */
  64179. lensFlareHaloWidth: number;
  64180. /**
  64181. * Based on the lens distortion effect, defines how much the lens flare result
  64182. * is distorted
  64183. */
  64184. lensFlareDistortionStrength: number;
  64185. /**
  64186. * Configures the blur intensity used for for lens flare (halo)
  64187. */
  64188. lensFlareBlurWidth: number;
  64189. /**
  64190. * Lens star texture must be used to simulate rays on the flares and is available
  64191. * in the documentation
  64192. */
  64193. lensStarTexture: Nullable<Texture>;
  64194. /**
  64195. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64196. * flare effect by taking account of the dirt texture
  64197. */
  64198. lensFlareDirtTexture: Nullable<Texture>;
  64199. /**
  64200. * Represents the focal length for the depth of field effect
  64201. */
  64202. depthOfFieldDistance: number;
  64203. /**
  64204. * Represents the blur intensity for the blurred part of the depth of field effect
  64205. */
  64206. depthOfFieldBlurWidth: number;
  64207. /**
  64208. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64209. */
  64210. get motionStrength(): number;
  64211. /**
  64212. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64213. */
  64214. set motionStrength(strength: number);
  64215. /**
  64216. * Gets wether or not the motion blur post-process is object based or screen based.
  64217. */
  64218. get objectBasedMotionBlur(): boolean;
  64219. /**
  64220. * Sets wether or not the motion blur post-process should be object based or screen based
  64221. */
  64222. set objectBasedMotionBlur(value: boolean);
  64223. /**
  64224. * List of animations for the pipeline (IAnimatable implementation)
  64225. */
  64226. animations: Animation[];
  64227. /**
  64228. * Private members
  64229. */
  64230. private _scene;
  64231. private _currentDepthOfFieldSource;
  64232. private _basePostProcess;
  64233. private _fixedExposure;
  64234. private _currentExposure;
  64235. private _hdrAutoExposure;
  64236. private _hdrCurrentLuminance;
  64237. private _motionStrength;
  64238. private _isObjectBasedMotionBlur;
  64239. private _floatTextureType;
  64240. private _camerasToBeAttached;
  64241. private _ratio;
  64242. private _bloomEnabled;
  64243. private _depthOfFieldEnabled;
  64244. private _vlsEnabled;
  64245. private _lensFlareEnabled;
  64246. private _hdrEnabled;
  64247. private _motionBlurEnabled;
  64248. private _fxaaEnabled;
  64249. private _motionBlurSamples;
  64250. private _volumetricLightStepsCount;
  64251. private _samples;
  64252. /**
  64253. * @ignore
  64254. * Specifies if the bloom pipeline is enabled
  64255. */
  64256. get BloomEnabled(): boolean;
  64257. set BloomEnabled(enabled: boolean);
  64258. /**
  64259. * @ignore
  64260. * Specifies if the depth of field pipeline is enabed
  64261. */
  64262. get DepthOfFieldEnabled(): boolean;
  64263. set DepthOfFieldEnabled(enabled: boolean);
  64264. /**
  64265. * @ignore
  64266. * Specifies if the lens flare pipeline is enabed
  64267. */
  64268. get LensFlareEnabled(): boolean;
  64269. set LensFlareEnabled(enabled: boolean);
  64270. /**
  64271. * @ignore
  64272. * Specifies if the HDR pipeline is enabled
  64273. */
  64274. get HDREnabled(): boolean;
  64275. set HDREnabled(enabled: boolean);
  64276. /**
  64277. * @ignore
  64278. * Specifies if the volumetric lights scattering effect is enabled
  64279. */
  64280. get VLSEnabled(): boolean;
  64281. set VLSEnabled(enabled: boolean);
  64282. /**
  64283. * @ignore
  64284. * Specifies if the motion blur effect is enabled
  64285. */
  64286. get MotionBlurEnabled(): boolean;
  64287. set MotionBlurEnabled(enabled: boolean);
  64288. /**
  64289. * Specifies if anti-aliasing is enabled
  64290. */
  64291. get fxaaEnabled(): boolean;
  64292. set fxaaEnabled(enabled: boolean);
  64293. /**
  64294. * Specifies the number of steps used to calculate the volumetric lights
  64295. * Typically in interval [50, 200]
  64296. */
  64297. get volumetricLightStepsCount(): number;
  64298. set volumetricLightStepsCount(count: number);
  64299. /**
  64300. * Specifies the number of samples used for the motion blur effect
  64301. * Typically in interval [16, 64]
  64302. */
  64303. get motionBlurSamples(): number;
  64304. set motionBlurSamples(samples: number);
  64305. /**
  64306. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64307. */
  64308. get samples(): number;
  64309. set samples(sampleCount: number);
  64310. /**
  64311. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64312. * @constructor
  64313. * @param name The rendering pipeline name
  64314. * @param scene The scene linked to this pipeline
  64315. * @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)
  64316. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64317. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64318. */
  64319. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64320. private _buildPipeline;
  64321. private _createDownSampleX4PostProcess;
  64322. private _createBrightPassPostProcess;
  64323. private _createBlurPostProcesses;
  64324. private _createTextureAdderPostProcess;
  64325. private _createVolumetricLightPostProcess;
  64326. private _createLuminancePostProcesses;
  64327. private _createHdrPostProcess;
  64328. private _createLensFlarePostProcess;
  64329. private _createDepthOfFieldPostProcess;
  64330. private _createMotionBlurPostProcess;
  64331. private _getDepthTexture;
  64332. private _disposePostProcesses;
  64333. /**
  64334. * Dispose of the pipeline and stop all post processes
  64335. */
  64336. dispose(): void;
  64337. /**
  64338. * Serialize the rendering pipeline (Used when exporting)
  64339. * @returns the serialized object
  64340. */
  64341. serialize(): any;
  64342. /**
  64343. * Parse the serialized pipeline
  64344. * @param source Source pipeline.
  64345. * @param scene The scene to load the pipeline to.
  64346. * @param rootUrl The URL of the serialized pipeline.
  64347. * @returns An instantiated pipeline from the serialized object.
  64348. */
  64349. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64350. /**
  64351. * Luminance steps
  64352. */
  64353. static LuminanceSteps: number;
  64354. }
  64355. }
  64356. declare module BABYLON {
  64357. /** @hidden */
  64358. export var tonemapPixelShader: {
  64359. name: string;
  64360. shader: string;
  64361. };
  64362. }
  64363. declare module BABYLON {
  64364. /** Defines operator used for tonemapping */
  64365. export enum TonemappingOperator {
  64366. /** Hable */
  64367. Hable = 0,
  64368. /** Reinhard */
  64369. Reinhard = 1,
  64370. /** HejiDawson */
  64371. HejiDawson = 2,
  64372. /** Photographic */
  64373. Photographic = 3
  64374. }
  64375. /**
  64376. * Defines a post process to apply tone mapping
  64377. */
  64378. export class TonemapPostProcess extends PostProcess {
  64379. private _operator;
  64380. /** Defines the required exposure adjustement */
  64381. exposureAdjustment: number;
  64382. /**
  64383. * Creates a new TonemapPostProcess
  64384. * @param name defines the name of the postprocess
  64385. * @param _operator defines the operator to use
  64386. * @param exposureAdjustment defines the required exposure adjustement
  64387. * @param camera defines the camera to use (can be null)
  64388. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64389. * @param engine defines the hosting engine (can be ignore if camera is set)
  64390. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64391. */
  64392. constructor(name: string, _operator: TonemappingOperator,
  64393. /** Defines the required exposure adjustement */
  64394. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64395. }
  64396. }
  64397. declare module BABYLON {
  64398. /** @hidden */
  64399. export var depthVertexShader: {
  64400. name: string;
  64401. shader: string;
  64402. };
  64403. }
  64404. declare module BABYLON {
  64405. /** @hidden */
  64406. export var volumetricLightScatteringPixelShader: {
  64407. name: string;
  64408. shader: string;
  64409. };
  64410. }
  64411. declare module BABYLON {
  64412. /** @hidden */
  64413. export var volumetricLightScatteringPassVertexShader: {
  64414. name: string;
  64415. shader: string;
  64416. };
  64417. }
  64418. declare module BABYLON {
  64419. /** @hidden */
  64420. export var volumetricLightScatteringPassPixelShader: {
  64421. name: string;
  64422. shader: string;
  64423. };
  64424. }
  64425. declare module BABYLON {
  64426. /**
  64427. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64428. */
  64429. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64430. private _volumetricLightScatteringPass;
  64431. private _volumetricLightScatteringRTT;
  64432. private _viewPort;
  64433. private _screenCoordinates;
  64434. private _cachedDefines;
  64435. /**
  64436. * If not undefined, the mesh position is computed from the attached node position
  64437. */
  64438. attachedNode: {
  64439. position: Vector3;
  64440. };
  64441. /**
  64442. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64443. */
  64444. customMeshPosition: Vector3;
  64445. /**
  64446. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64447. */
  64448. useCustomMeshPosition: boolean;
  64449. /**
  64450. * If the post-process should inverse the light scattering direction
  64451. */
  64452. invert: boolean;
  64453. /**
  64454. * The internal mesh used by the post-process
  64455. */
  64456. mesh: Mesh;
  64457. /**
  64458. * @hidden
  64459. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64460. */
  64461. get useDiffuseColor(): boolean;
  64462. set useDiffuseColor(useDiffuseColor: boolean);
  64463. /**
  64464. * Array containing the excluded meshes not rendered in the internal pass
  64465. */
  64466. excludedMeshes: AbstractMesh[];
  64467. /**
  64468. * Controls the overall intensity of the post-process
  64469. */
  64470. exposure: number;
  64471. /**
  64472. * Dissipates each sample's contribution in range [0, 1]
  64473. */
  64474. decay: number;
  64475. /**
  64476. * Controls the overall intensity of each sample
  64477. */
  64478. weight: number;
  64479. /**
  64480. * Controls the density of each sample
  64481. */
  64482. density: number;
  64483. /**
  64484. * @constructor
  64485. * @param name The post-process name
  64486. * @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)
  64487. * @param camera The camera that the post-process will be attached to
  64488. * @param mesh The mesh used to create the light scattering
  64489. * @param samples The post-process quality, default 100
  64490. * @param samplingModeThe post-process filtering mode
  64491. * @param engine The babylon engine
  64492. * @param reusable If the post-process is reusable
  64493. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64494. */
  64495. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64496. /**
  64497. * Returns the string "VolumetricLightScatteringPostProcess"
  64498. * @returns "VolumetricLightScatteringPostProcess"
  64499. */
  64500. getClassName(): string;
  64501. private _isReady;
  64502. /**
  64503. * Sets the new light position for light scattering effect
  64504. * @param position The new custom light position
  64505. */
  64506. setCustomMeshPosition(position: Vector3): void;
  64507. /**
  64508. * Returns the light position for light scattering effect
  64509. * @return Vector3 The custom light position
  64510. */
  64511. getCustomMeshPosition(): Vector3;
  64512. /**
  64513. * Disposes the internal assets and detaches the post-process from the camera
  64514. */
  64515. dispose(camera: Camera): void;
  64516. /**
  64517. * Returns the render target texture used by the post-process
  64518. * @return the render target texture used by the post-process
  64519. */
  64520. getPass(): RenderTargetTexture;
  64521. private _meshExcluded;
  64522. private _createPass;
  64523. private _updateMeshScreenCoordinates;
  64524. /**
  64525. * Creates a default mesh for the Volumeric Light Scattering post-process
  64526. * @param name The mesh name
  64527. * @param scene The scene where to create the mesh
  64528. * @return the default mesh
  64529. */
  64530. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. interface Scene {
  64535. /** @hidden (Backing field) */
  64536. _boundingBoxRenderer: BoundingBoxRenderer;
  64537. /** @hidden (Backing field) */
  64538. _forceShowBoundingBoxes: boolean;
  64539. /**
  64540. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64541. */
  64542. forceShowBoundingBoxes: boolean;
  64543. /**
  64544. * Gets the bounding box renderer associated with the scene
  64545. * @returns a BoundingBoxRenderer
  64546. */
  64547. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64548. }
  64549. interface AbstractMesh {
  64550. /** @hidden (Backing field) */
  64551. _showBoundingBox: boolean;
  64552. /**
  64553. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64554. */
  64555. showBoundingBox: boolean;
  64556. }
  64557. /**
  64558. * Component responsible of rendering the bounding box of the meshes in a scene.
  64559. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64560. */
  64561. export class BoundingBoxRenderer implements ISceneComponent {
  64562. /**
  64563. * The component name helpfull to identify the component in the list of scene components.
  64564. */
  64565. readonly name: string;
  64566. /**
  64567. * The scene the component belongs to.
  64568. */
  64569. scene: Scene;
  64570. /**
  64571. * Color of the bounding box lines placed in front of an object
  64572. */
  64573. frontColor: Color3;
  64574. /**
  64575. * Color of the bounding box lines placed behind an object
  64576. */
  64577. backColor: Color3;
  64578. /**
  64579. * Defines if the renderer should show the back lines or not
  64580. */
  64581. showBackLines: boolean;
  64582. /**
  64583. * @hidden
  64584. */
  64585. renderList: SmartArray<BoundingBox>;
  64586. private _colorShader;
  64587. private _vertexBuffers;
  64588. private _indexBuffer;
  64589. private _fillIndexBuffer;
  64590. private _fillIndexData;
  64591. /**
  64592. * Instantiates a new bounding box renderer in a scene.
  64593. * @param scene the scene the renderer renders in
  64594. */
  64595. constructor(scene: Scene);
  64596. /**
  64597. * Registers the component in a given scene
  64598. */
  64599. register(): void;
  64600. private _evaluateSubMesh;
  64601. private _activeMesh;
  64602. private _prepareRessources;
  64603. private _createIndexBuffer;
  64604. /**
  64605. * Rebuilds the elements related to this component in case of
  64606. * context lost for instance.
  64607. */
  64608. rebuild(): void;
  64609. /**
  64610. * @hidden
  64611. */
  64612. reset(): void;
  64613. /**
  64614. * Render the bounding boxes of a specific rendering group
  64615. * @param renderingGroupId defines the rendering group to render
  64616. */
  64617. render(renderingGroupId: number): void;
  64618. /**
  64619. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64620. * @param mesh Define the mesh to render the occlusion bounding box for
  64621. */
  64622. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64623. /**
  64624. * Dispose and release the resources attached to this renderer.
  64625. */
  64626. dispose(): void;
  64627. }
  64628. }
  64629. declare module BABYLON {
  64630. /** @hidden */
  64631. export var depthPixelShader: {
  64632. name: string;
  64633. shader: string;
  64634. };
  64635. }
  64636. declare module BABYLON {
  64637. /**
  64638. * This represents a depth renderer in Babylon.
  64639. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64640. */
  64641. export class DepthRenderer {
  64642. private _scene;
  64643. private _depthMap;
  64644. private _effect;
  64645. private readonly _storeNonLinearDepth;
  64646. private readonly _clearColor;
  64647. /** Get if the depth renderer is using packed depth or not */
  64648. readonly isPacked: boolean;
  64649. private _cachedDefines;
  64650. private _camera;
  64651. /**
  64652. * Specifiess that the depth renderer will only be used within
  64653. * the camera it is created for.
  64654. * This can help forcing its rendering during the camera processing.
  64655. */
  64656. useOnlyInActiveCamera: boolean;
  64657. /** @hidden */
  64658. static _SceneComponentInitialization: (scene: Scene) => void;
  64659. /**
  64660. * Instantiates a depth renderer
  64661. * @param scene The scene the renderer belongs to
  64662. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64663. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64664. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64665. */
  64666. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64667. /**
  64668. * Creates the depth rendering effect and checks if the effect is ready.
  64669. * @param subMesh The submesh to be used to render the depth map of
  64670. * @param useInstances If multiple world instances should be used
  64671. * @returns if the depth renderer is ready to render the depth map
  64672. */
  64673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64674. /**
  64675. * Gets the texture which the depth map will be written to.
  64676. * @returns The depth map texture
  64677. */
  64678. getDepthMap(): RenderTargetTexture;
  64679. /**
  64680. * Disposes of the depth renderer.
  64681. */
  64682. dispose(): void;
  64683. }
  64684. }
  64685. declare module BABYLON {
  64686. interface Scene {
  64687. /** @hidden (Backing field) */
  64688. _depthRenderer: {
  64689. [id: string]: DepthRenderer;
  64690. };
  64691. /**
  64692. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64693. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64694. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64695. * @returns the created depth renderer
  64696. */
  64697. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64698. /**
  64699. * Disables a depth renderer for a given camera
  64700. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64701. */
  64702. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64703. }
  64704. /**
  64705. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64706. * in several rendering techniques.
  64707. */
  64708. export class DepthRendererSceneComponent implements ISceneComponent {
  64709. /**
  64710. * The component name helpfull to identify the component in the list of scene components.
  64711. */
  64712. readonly name: string;
  64713. /**
  64714. * The scene the component belongs to.
  64715. */
  64716. scene: Scene;
  64717. /**
  64718. * Creates a new instance of the component for the given scene
  64719. * @param scene Defines the scene to register the component in
  64720. */
  64721. constructor(scene: Scene);
  64722. /**
  64723. * Registers the component in a given scene
  64724. */
  64725. register(): void;
  64726. /**
  64727. * Rebuilds the elements related to this component in case of
  64728. * context lost for instance.
  64729. */
  64730. rebuild(): void;
  64731. /**
  64732. * Disposes the component and the associated ressources
  64733. */
  64734. dispose(): void;
  64735. private _gatherRenderTargets;
  64736. private _gatherActiveCameraRenderTargets;
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /** @hidden */
  64741. export var outlinePixelShader: {
  64742. name: string;
  64743. shader: string;
  64744. };
  64745. }
  64746. declare module BABYLON {
  64747. /** @hidden */
  64748. export var outlineVertexShader: {
  64749. name: string;
  64750. shader: string;
  64751. };
  64752. }
  64753. declare module BABYLON {
  64754. interface Scene {
  64755. /** @hidden */
  64756. _outlineRenderer: OutlineRenderer;
  64757. /**
  64758. * Gets the outline renderer associated with the scene
  64759. * @returns a OutlineRenderer
  64760. */
  64761. getOutlineRenderer(): OutlineRenderer;
  64762. }
  64763. interface AbstractMesh {
  64764. /** @hidden (Backing field) */
  64765. _renderOutline: boolean;
  64766. /**
  64767. * Gets or sets a boolean indicating if the outline must be rendered as well
  64768. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64769. */
  64770. renderOutline: boolean;
  64771. /** @hidden (Backing field) */
  64772. _renderOverlay: boolean;
  64773. /**
  64774. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64775. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64776. */
  64777. renderOverlay: boolean;
  64778. }
  64779. /**
  64780. * This class is responsible to draw bothe outline/overlay of meshes.
  64781. * It should not be used directly but through the available method on mesh.
  64782. */
  64783. export class OutlineRenderer implements ISceneComponent {
  64784. /**
  64785. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64786. */
  64787. private static _StencilReference;
  64788. /**
  64789. * The name of the component. Each component must have a unique name.
  64790. */
  64791. name: string;
  64792. /**
  64793. * The scene the component belongs to.
  64794. */
  64795. scene: Scene;
  64796. /**
  64797. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64798. */
  64799. zOffset: number;
  64800. private _engine;
  64801. private _effect;
  64802. private _cachedDefines;
  64803. private _savedDepthWrite;
  64804. /**
  64805. * Instantiates a new outline renderer. (There could be only one per scene).
  64806. * @param scene Defines the scene it belongs to
  64807. */
  64808. constructor(scene: Scene);
  64809. /**
  64810. * Register the component to one instance of a scene.
  64811. */
  64812. register(): void;
  64813. /**
  64814. * Rebuilds the elements related to this component in case of
  64815. * context lost for instance.
  64816. */
  64817. rebuild(): void;
  64818. /**
  64819. * Disposes the component and the associated ressources.
  64820. */
  64821. dispose(): void;
  64822. /**
  64823. * Renders the outline in the canvas.
  64824. * @param subMesh Defines the sumesh to render
  64825. * @param batch Defines the batch of meshes in case of instances
  64826. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64827. */
  64828. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64829. /**
  64830. * Returns whether or not the outline renderer is ready for a given submesh.
  64831. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64832. * @param subMesh Defines the submesh to check readyness for
  64833. * @param useInstances Defines wheter wee are trying to render instances or not
  64834. * @returns true if ready otherwise false
  64835. */
  64836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64837. private _beforeRenderingMesh;
  64838. private _afterRenderingMesh;
  64839. }
  64840. }
  64841. declare module BABYLON {
  64842. /**
  64843. * Defines the basic options interface of a Sprite Frame Source Size.
  64844. */
  64845. export interface ISpriteJSONSpriteSourceSize {
  64846. /**
  64847. * number of the original width of the Frame
  64848. */
  64849. w: number;
  64850. /**
  64851. * number of the original height of the Frame
  64852. */
  64853. h: number;
  64854. }
  64855. /**
  64856. * Defines the basic options interface of a Sprite Frame Data.
  64857. */
  64858. export interface ISpriteJSONSpriteFrameData {
  64859. /**
  64860. * number of the x offset of the Frame
  64861. */
  64862. x: number;
  64863. /**
  64864. * number of the y offset of the Frame
  64865. */
  64866. y: number;
  64867. /**
  64868. * number of the width of the Frame
  64869. */
  64870. w: number;
  64871. /**
  64872. * number of the height of the Frame
  64873. */
  64874. h: number;
  64875. }
  64876. /**
  64877. * Defines the basic options interface of a JSON Sprite.
  64878. */
  64879. export interface ISpriteJSONSprite {
  64880. /**
  64881. * string name of the Frame
  64882. */
  64883. filename: string;
  64884. /**
  64885. * ISpriteJSONSpriteFrame basic object of the frame data
  64886. */
  64887. frame: ISpriteJSONSpriteFrameData;
  64888. /**
  64889. * boolean to flag is the frame was rotated.
  64890. */
  64891. rotated: boolean;
  64892. /**
  64893. * boolean to flag is the frame was trimmed.
  64894. */
  64895. trimmed: boolean;
  64896. /**
  64897. * ISpriteJSONSpriteFrame basic object of the source data
  64898. */
  64899. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64900. /**
  64901. * ISpriteJSONSpriteFrame basic object of the source data
  64902. */
  64903. sourceSize: ISpriteJSONSpriteSourceSize;
  64904. }
  64905. /**
  64906. * Defines the basic options interface of a JSON atlas.
  64907. */
  64908. export interface ISpriteJSONAtlas {
  64909. /**
  64910. * Array of objects that contain the frame data.
  64911. */
  64912. frames: Array<ISpriteJSONSprite>;
  64913. /**
  64914. * object basic object containing the sprite meta data.
  64915. */
  64916. meta?: object;
  64917. }
  64918. }
  64919. declare module BABYLON {
  64920. /** @hidden */
  64921. export var spriteMapPixelShader: {
  64922. name: string;
  64923. shader: string;
  64924. };
  64925. }
  64926. declare module BABYLON {
  64927. /** @hidden */
  64928. export var spriteMapVertexShader: {
  64929. name: string;
  64930. shader: string;
  64931. };
  64932. }
  64933. declare module BABYLON {
  64934. /**
  64935. * Defines the basic options interface of a SpriteMap
  64936. */
  64937. export interface ISpriteMapOptions {
  64938. /**
  64939. * Vector2 of the number of cells in the grid.
  64940. */
  64941. stageSize?: Vector2;
  64942. /**
  64943. * Vector2 of the size of the output plane in World Units.
  64944. */
  64945. outputSize?: Vector2;
  64946. /**
  64947. * Vector3 of the position of the output plane in World Units.
  64948. */
  64949. outputPosition?: Vector3;
  64950. /**
  64951. * Vector3 of the rotation of the output plane.
  64952. */
  64953. outputRotation?: Vector3;
  64954. /**
  64955. * number of layers that the system will reserve in resources.
  64956. */
  64957. layerCount?: number;
  64958. /**
  64959. * number of max animation frames a single cell will reserve in resources.
  64960. */
  64961. maxAnimationFrames?: number;
  64962. /**
  64963. * number cell index of the base tile when the system compiles.
  64964. */
  64965. baseTile?: number;
  64966. /**
  64967. * boolean flip the sprite after its been repositioned by the framing data.
  64968. */
  64969. flipU?: boolean;
  64970. /**
  64971. * Vector3 scalar of the global RGB values of the SpriteMap.
  64972. */
  64973. colorMultiply?: Vector3;
  64974. }
  64975. /**
  64976. * Defines the IDisposable interface in order to be cleanable from resources.
  64977. */
  64978. export interface ISpriteMap extends IDisposable {
  64979. /**
  64980. * String name of the SpriteMap.
  64981. */
  64982. name: string;
  64983. /**
  64984. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64985. */
  64986. atlasJSON: ISpriteJSONAtlas;
  64987. /**
  64988. * Texture of the SpriteMap.
  64989. */
  64990. spriteSheet: Texture;
  64991. /**
  64992. * The parameters to initialize the SpriteMap with.
  64993. */
  64994. options: ISpriteMapOptions;
  64995. }
  64996. /**
  64997. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64998. */
  64999. export class SpriteMap implements ISpriteMap {
  65000. /** The Name of the spriteMap */
  65001. name: string;
  65002. /** The JSON file with the frame and meta data */
  65003. atlasJSON: ISpriteJSONAtlas;
  65004. /** The systems Sprite Sheet Texture */
  65005. spriteSheet: Texture;
  65006. /** Arguments passed with the Constructor */
  65007. options: ISpriteMapOptions;
  65008. /** Public Sprite Storage array, parsed from atlasJSON */
  65009. sprites: Array<ISpriteJSONSprite>;
  65010. /** Returns the Number of Sprites in the System */
  65011. get spriteCount(): number;
  65012. /** Returns the Position of Output Plane*/
  65013. get position(): Vector3;
  65014. /** Returns the Position of Output Plane*/
  65015. set position(v: Vector3);
  65016. /** Returns the Rotation of Output Plane*/
  65017. get rotation(): Vector3;
  65018. /** Returns the Rotation of Output Plane*/
  65019. set rotation(v: Vector3);
  65020. /** Sets the AnimationMap*/
  65021. get animationMap(): RawTexture;
  65022. /** Sets the AnimationMap*/
  65023. set animationMap(v: RawTexture);
  65024. /** Scene that the SpriteMap was created in */
  65025. private _scene;
  65026. /** Texture Buffer of Float32 that holds tile frame data*/
  65027. private _frameMap;
  65028. /** Texture Buffers of Float32 that holds tileMap data*/
  65029. private _tileMaps;
  65030. /** Texture Buffer of Float32 that holds Animation Data*/
  65031. private _animationMap;
  65032. /** Custom ShaderMaterial Central to the System*/
  65033. private _material;
  65034. /** Custom ShaderMaterial Central to the System*/
  65035. private _output;
  65036. /** Systems Time Ticker*/
  65037. private _time;
  65038. /**
  65039. * Creates a new SpriteMap
  65040. * @param name defines the SpriteMaps Name
  65041. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65042. * @param spriteSheet is the Texture that the Sprites are on.
  65043. * @param options a basic deployment configuration
  65044. * @param scene The Scene that the map is deployed on
  65045. */
  65046. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65047. /**
  65048. * Returns tileID location
  65049. * @returns Vector2 the cell position ID
  65050. */
  65051. getTileID(): Vector2;
  65052. /**
  65053. * Gets the UV location of the mouse over the SpriteMap.
  65054. * @returns Vector2 the UV position of the mouse interaction
  65055. */
  65056. getMousePosition(): Vector2;
  65057. /**
  65058. * Creates the "frame" texture Buffer
  65059. * -------------------------------------
  65060. * Structure of frames
  65061. * "filename": "Falling-Water-2.png",
  65062. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65063. * "rotated": true,
  65064. * "trimmed": true,
  65065. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65066. * "sourceSize": {"w":32,"h":32}
  65067. * @returns RawTexture of the frameMap
  65068. */
  65069. private _createFrameBuffer;
  65070. /**
  65071. * Creates the tileMap texture Buffer
  65072. * @param buffer normally and array of numbers, or a false to generate from scratch
  65073. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65074. * @returns RawTexture of the tileMap
  65075. */
  65076. private _createTileBuffer;
  65077. /**
  65078. * Modifies the data of the tileMaps
  65079. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65080. * @param pos is the iVector2 Coordinates of the Tile
  65081. * @param tile The SpriteIndex of the new Tile
  65082. */
  65083. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65084. /**
  65085. * Creates the animationMap texture Buffer
  65086. * @param buffer normally and array of numbers, or a false to generate from scratch
  65087. * @returns RawTexture of the animationMap
  65088. */
  65089. private _createTileAnimationBuffer;
  65090. /**
  65091. * Modifies the data of the animationMap
  65092. * @param cellID is the Index of the Sprite
  65093. * @param _frame is the target Animation frame
  65094. * @param toCell is the Target Index of the next frame of the animation
  65095. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65096. * @param speed is a global scalar of the time variable on the map.
  65097. */
  65098. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65099. /**
  65100. * Exports the .tilemaps file
  65101. */
  65102. saveTileMaps(): void;
  65103. /**
  65104. * Imports the .tilemaps file
  65105. * @param url of the .tilemaps file
  65106. */
  65107. loadTileMaps(url: string): void;
  65108. /**
  65109. * Release associated resources
  65110. */
  65111. dispose(): void;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65117. * @see http://doc.babylonjs.com/babylon101/sprites
  65118. */
  65119. export class SpritePackedManager extends SpriteManager {
  65120. /** defines the packed manager's name */
  65121. name: string;
  65122. /**
  65123. * Creates a new sprite manager from a packed sprite sheet
  65124. * @param name defines the manager's name
  65125. * @param imgUrl defines the sprite sheet url
  65126. * @param capacity defines the maximum allowed number of sprites
  65127. * @param scene defines the hosting scene
  65128. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65129. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65130. * @param samplingMode defines the smapling mode to use with spritesheet
  65131. * @param fromPacked set to true; do not alter
  65132. */
  65133. constructor(
  65134. /** defines the packed manager's name */
  65135. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65136. }
  65137. }
  65138. declare module BABYLON {
  65139. /**
  65140. * Defines the list of states available for a task inside a AssetsManager
  65141. */
  65142. export enum AssetTaskState {
  65143. /**
  65144. * Initialization
  65145. */
  65146. INIT = 0,
  65147. /**
  65148. * Running
  65149. */
  65150. RUNNING = 1,
  65151. /**
  65152. * Done
  65153. */
  65154. DONE = 2,
  65155. /**
  65156. * Error
  65157. */
  65158. ERROR = 3
  65159. }
  65160. /**
  65161. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65162. */
  65163. export abstract class AbstractAssetTask {
  65164. /**
  65165. * Task name
  65166. */ name: string;
  65167. /**
  65168. * Callback called when the task is successful
  65169. */
  65170. onSuccess: (task: any) => void;
  65171. /**
  65172. * Callback called when the task is not successful
  65173. */
  65174. onError: (task: any, message?: string, exception?: any) => void;
  65175. /**
  65176. * Creates a new AssetsManager
  65177. * @param name defines the name of the task
  65178. */
  65179. constructor(
  65180. /**
  65181. * Task name
  65182. */ name: string);
  65183. private _isCompleted;
  65184. private _taskState;
  65185. private _errorObject;
  65186. /**
  65187. * Get if the task is completed
  65188. */
  65189. get isCompleted(): boolean;
  65190. /**
  65191. * Gets the current state of the task
  65192. */
  65193. get taskState(): AssetTaskState;
  65194. /**
  65195. * Gets the current error object (if task is in error)
  65196. */
  65197. get errorObject(): {
  65198. message?: string;
  65199. exception?: any;
  65200. };
  65201. /**
  65202. * Internal only
  65203. * @hidden
  65204. */
  65205. _setErrorObject(message?: string, exception?: any): void;
  65206. /**
  65207. * Execute the current task
  65208. * @param scene defines the scene where you want your assets to be loaded
  65209. * @param onSuccess is a callback called when the task is successfully executed
  65210. * @param onError is a callback called if an error occurs
  65211. */
  65212. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65213. /**
  65214. * Execute the current task
  65215. * @param scene defines the scene where you want your assets to be loaded
  65216. * @param onSuccess is a callback called when the task is successfully executed
  65217. * @param onError is a callback called if an error occurs
  65218. */
  65219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65220. /**
  65221. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65222. * This can be used with failed tasks that have the reason for failure fixed.
  65223. */
  65224. reset(): void;
  65225. private onErrorCallback;
  65226. private onDoneCallback;
  65227. }
  65228. /**
  65229. * Define the interface used by progress events raised during assets loading
  65230. */
  65231. export interface IAssetsProgressEvent {
  65232. /**
  65233. * Defines the number of remaining tasks to process
  65234. */
  65235. remainingCount: number;
  65236. /**
  65237. * Defines the total number of tasks
  65238. */
  65239. totalCount: number;
  65240. /**
  65241. * Defines the task that was just processed
  65242. */
  65243. task: AbstractAssetTask;
  65244. }
  65245. /**
  65246. * Class used to share progress information about assets loading
  65247. */
  65248. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65249. /**
  65250. * Defines the number of remaining tasks to process
  65251. */
  65252. remainingCount: number;
  65253. /**
  65254. * Defines the total number of tasks
  65255. */
  65256. totalCount: number;
  65257. /**
  65258. * Defines the task that was just processed
  65259. */
  65260. task: AbstractAssetTask;
  65261. /**
  65262. * Creates a AssetsProgressEvent
  65263. * @param remainingCount defines the number of remaining tasks to process
  65264. * @param totalCount defines the total number of tasks
  65265. * @param task defines the task that was just processed
  65266. */
  65267. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65268. }
  65269. /**
  65270. * Define a task used by AssetsManager to load meshes
  65271. */
  65272. export class MeshAssetTask extends AbstractAssetTask {
  65273. /**
  65274. * Defines the name of the task
  65275. */
  65276. name: string;
  65277. /**
  65278. * Defines the list of mesh's names you want to load
  65279. */
  65280. meshesNames: any;
  65281. /**
  65282. * Defines the root url to use as a base to load your meshes and associated resources
  65283. */
  65284. rootUrl: string;
  65285. /**
  65286. * Defines the filename of the scene to load from
  65287. */
  65288. sceneFilename: string;
  65289. /**
  65290. * Gets the list of loaded meshes
  65291. */
  65292. loadedMeshes: Array<AbstractMesh>;
  65293. /**
  65294. * Gets the list of loaded particle systems
  65295. */
  65296. loadedParticleSystems: Array<IParticleSystem>;
  65297. /**
  65298. * Gets the list of loaded skeletons
  65299. */
  65300. loadedSkeletons: Array<Skeleton>;
  65301. /**
  65302. * Gets the list of loaded animation groups
  65303. */
  65304. loadedAnimationGroups: Array<AnimationGroup>;
  65305. /**
  65306. * Callback called when the task is successful
  65307. */
  65308. onSuccess: (task: MeshAssetTask) => void;
  65309. /**
  65310. * Callback called when the task is successful
  65311. */
  65312. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65313. /**
  65314. * Creates a new MeshAssetTask
  65315. * @param name defines the name of the task
  65316. * @param meshesNames defines the list of mesh's names you want to load
  65317. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65318. * @param sceneFilename defines the filename of the scene to load from
  65319. */
  65320. constructor(
  65321. /**
  65322. * Defines the name of the task
  65323. */
  65324. name: string,
  65325. /**
  65326. * Defines the list of mesh's names you want to load
  65327. */
  65328. meshesNames: any,
  65329. /**
  65330. * Defines the root url to use as a base to load your meshes and associated resources
  65331. */
  65332. rootUrl: string,
  65333. /**
  65334. * Defines the filename of the scene to load from
  65335. */
  65336. sceneFilename: string);
  65337. /**
  65338. * Execute the current task
  65339. * @param scene defines the scene where you want your assets to be loaded
  65340. * @param onSuccess is a callback called when the task is successfully executed
  65341. * @param onError is a callback called if an error occurs
  65342. */
  65343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65344. }
  65345. /**
  65346. * Define a task used by AssetsManager to load text content
  65347. */
  65348. export class TextFileAssetTask extends AbstractAssetTask {
  65349. /**
  65350. * Defines the name of the task
  65351. */
  65352. name: string;
  65353. /**
  65354. * Defines the location of the file to load
  65355. */
  65356. url: string;
  65357. /**
  65358. * Gets the loaded text string
  65359. */
  65360. text: string;
  65361. /**
  65362. * Callback called when the task is successful
  65363. */
  65364. onSuccess: (task: TextFileAssetTask) => void;
  65365. /**
  65366. * Callback called when the task is successful
  65367. */
  65368. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65369. /**
  65370. * Creates a new TextFileAssetTask object
  65371. * @param name defines the name of the task
  65372. * @param url defines the location of the file to load
  65373. */
  65374. constructor(
  65375. /**
  65376. * Defines the name of the task
  65377. */
  65378. name: string,
  65379. /**
  65380. * Defines the location of the file to load
  65381. */
  65382. url: string);
  65383. /**
  65384. * Execute the current task
  65385. * @param scene defines the scene where you want your assets to be loaded
  65386. * @param onSuccess is a callback called when the task is successfully executed
  65387. * @param onError is a callback called if an error occurs
  65388. */
  65389. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65390. }
  65391. /**
  65392. * Define a task used by AssetsManager to load binary data
  65393. */
  65394. export class BinaryFileAssetTask extends AbstractAssetTask {
  65395. /**
  65396. * Defines the name of the task
  65397. */
  65398. name: string;
  65399. /**
  65400. * Defines the location of the file to load
  65401. */
  65402. url: string;
  65403. /**
  65404. * Gets the lodaded data (as an array buffer)
  65405. */
  65406. data: ArrayBuffer;
  65407. /**
  65408. * Callback called when the task is successful
  65409. */
  65410. onSuccess: (task: BinaryFileAssetTask) => void;
  65411. /**
  65412. * Callback called when the task is successful
  65413. */
  65414. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65415. /**
  65416. * Creates a new BinaryFileAssetTask object
  65417. * @param name defines the name of the new task
  65418. * @param url defines the location of the file to load
  65419. */
  65420. constructor(
  65421. /**
  65422. * Defines the name of the task
  65423. */
  65424. name: string,
  65425. /**
  65426. * Defines the location of the file to load
  65427. */
  65428. url: string);
  65429. /**
  65430. * Execute the current task
  65431. * @param scene defines the scene where you want your assets to be loaded
  65432. * @param onSuccess is a callback called when the task is successfully executed
  65433. * @param onError is a callback called if an error occurs
  65434. */
  65435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65436. }
  65437. /**
  65438. * Define a task used by AssetsManager to load images
  65439. */
  65440. export class ImageAssetTask extends AbstractAssetTask {
  65441. /**
  65442. * Defines the name of the task
  65443. */
  65444. name: string;
  65445. /**
  65446. * Defines the location of the image to load
  65447. */
  65448. url: string;
  65449. /**
  65450. * Gets the loaded images
  65451. */
  65452. image: HTMLImageElement;
  65453. /**
  65454. * Callback called when the task is successful
  65455. */
  65456. onSuccess: (task: ImageAssetTask) => void;
  65457. /**
  65458. * Callback called when the task is successful
  65459. */
  65460. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65461. /**
  65462. * Creates a new ImageAssetTask
  65463. * @param name defines the name of the task
  65464. * @param url defines the location of the image to load
  65465. */
  65466. constructor(
  65467. /**
  65468. * Defines the name of the task
  65469. */
  65470. name: string,
  65471. /**
  65472. * Defines the location of the image to load
  65473. */
  65474. url: string);
  65475. /**
  65476. * Execute the current task
  65477. * @param scene defines the scene where you want your assets to be loaded
  65478. * @param onSuccess is a callback called when the task is successfully executed
  65479. * @param onError is a callback called if an error occurs
  65480. */
  65481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65482. }
  65483. /**
  65484. * Defines the interface used by texture loading tasks
  65485. */
  65486. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65487. /**
  65488. * Gets the loaded texture
  65489. */
  65490. texture: TEX;
  65491. }
  65492. /**
  65493. * Define a task used by AssetsManager to load 2D textures
  65494. */
  65495. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65496. /**
  65497. * Defines the name of the task
  65498. */
  65499. name: string;
  65500. /**
  65501. * Defines the location of the file to load
  65502. */
  65503. url: string;
  65504. /**
  65505. * Defines if mipmap should not be generated (default is false)
  65506. */
  65507. noMipmap?: boolean | undefined;
  65508. /**
  65509. * Defines if texture must be inverted on Y axis (default is false)
  65510. */
  65511. invertY?: boolean | undefined;
  65512. /**
  65513. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65514. */
  65515. samplingMode: number;
  65516. /**
  65517. * Gets the loaded texture
  65518. */
  65519. texture: Texture;
  65520. /**
  65521. * Callback called when the task is successful
  65522. */
  65523. onSuccess: (task: TextureAssetTask) => void;
  65524. /**
  65525. * Callback called when the task is successful
  65526. */
  65527. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65528. /**
  65529. * Creates a new TextureAssetTask object
  65530. * @param name defines the name of the task
  65531. * @param url defines the location of the file to load
  65532. * @param noMipmap defines if mipmap should not be generated (default is false)
  65533. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65534. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65535. */
  65536. constructor(
  65537. /**
  65538. * Defines the name of the task
  65539. */
  65540. name: string,
  65541. /**
  65542. * Defines the location of the file to load
  65543. */
  65544. url: string,
  65545. /**
  65546. * Defines if mipmap should not be generated (default is false)
  65547. */
  65548. noMipmap?: boolean | undefined,
  65549. /**
  65550. * Defines if texture must be inverted on Y axis (default is false)
  65551. */
  65552. invertY?: boolean | undefined,
  65553. /**
  65554. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65555. */
  65556. samplingMode?: number);
  65557. /**
  65558. * Execute the current task
  65559. * @param scene defines the scene where you want your assets to be loaded
  65560. * @param onSuccess is a callback called when the task is successfully executed
  65561. * @param onError is a callback called if an error occurs
  65562. */
  65563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65564. }
  65565. /**
  65566. * Define a task used by AssetsManager to load cube textures
  65567. */
  65568. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65569. /**
  65570. * Defines the name of the task
  65571. */
  65572. name: string;
  65573. /**
  65574. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65575. */
  65576. url: string;
  65577. /**
  65578. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65579. */
  65580. extensions?: string[] | undefined;
  65581. /**
  65582. * Defines if mipmaps should not be generated (default is false)
  65583. */
  65584. noMipmap?: boolean | undefined;
  65585. /**
  65586. * Defines the explicit list of files (undefined by default)
  65587. */
  65588. files?: string[] | undefined;
  65589. /**
  65590. * Gets the loaded texture
  65591. */
  65592. texture: CubeTexture;
  65593. /**
  65594. * Callback called when the task is successful
  65595. */
  65596. onSuccess: (task: CubeTextureAssetTask) => void;
  65597. /**
  65598. * Callback called when the task is successful
  65599. */
  65600. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65601. /**
  65602. * Creates a new CubeTextureAssetTask
  65603. * @param name defines the name of the task
  65604. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65605. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65606. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65607. * @param files defines the explicit list of files (undefined by default)
  65608. */
  65609. constructor(
  65610. /**
  65611. * Defines the name of the task
  65612. */
  65613. name: string,
  65614. /**
  65615. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65616. */
  65617. url: string,
  65618. /**
  65619. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65620. */
  65621. extensions?: string[] | undefined,
  65622. /**
  65623. * Defines if mipmaps should not be generated (default is false)
  65624. */
  65625. noMipmap?: boolean | undefined,
  65626. /**
  65627. * Defines the explicit list of files (undefined by default)
  65628. */
  65629. files?: string[] | undefined);
  65630. /**
  65631. * Execute the current task
  65632. * @param scene defines the scene where you want your assets to be loaded
  65633. * @param onSuccess is a callback called when the task is successfully executed
  65634. * @param onError is a callback called if an error occurs
  65635. */
  65636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65637. }
  65638. /**
  65639. * Define a task used by AssetsManager to load HDR cube textures
  65640. */
  65641. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65642. /**
  65643. * Defines the name of the task
  65644. */
  65645. name: string;
  65646. /**
  65647. * Defines the location of the file to load
  65648. */
  65649. url: string;
  65650. /**
  65651. * Defines the desired size (the more it increases the longer the generation will be)
  65652. */
  65653. size: number;
  65654. /**
  65655. * Defines if mipmaps should not be generated (default is false)
  65656. */
  65657. noMipmap: boolean;
  65658. /**
  65659. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65660. */
  65661. generateHarmonics: boolean;
  65662. /**
  65663. * 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)
  65664. */
  65665. gammaSpace: boolean;
  65666. /**
  65667. * Internal Use Only
  65668. */
  65669. reserved: boolean;
  65670. /**
  65671. * Gets the loaded texture
  65672. */
  65673. texture: HDRCubeTexture;
  65674. /**
  65675. * Callback called when the task is successful
  65676. */
  65677. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65678. /**
  65679. * Callback called when the task is successful
  65680. */
  65681. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65682. /**
  65683. * Creates a new HDRCubeTextureAssetTask object
  65684. * @param name defines the name of the task
  65685. * @param url defines the location of the file to load
  65686. * @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.
  65687. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65688. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65689. * @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)
  65690. * @param reserved Internal use only
  65691. */
  65692. constructor(
  65693. /**
  65694. * Defines the name of the task
  65695. */
  65696. name: string,
  65697. /**
  65698. * Defines the location of the file to load
  65699. */
  65700. url: string,
  65701. /**
  65702. * Defines the desired size (the more it increases the longer the generation will be)
  65703. */
  65704. size: number,
  65705. /**
  65706. * Defines if mipmaps should not be generated (default is false)
  65707. */
  65708. noMipmap?: boolean,
  65709. /**
  65710. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65711. */
  65712. generateHarmonics?: boolean,
  65713. /**
  65714. * 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)
  65715. */
  65716. gammaSpace?: boolean,
  65717. /**
  65718. * Internal Use Only
  65719. */
  65720. reserved?: boolean);
  65721. /**
  65722. * Execute the current task
  65723. * @param scene defines the scene where you want your assets to be loaded
  65724. * @param onSuccess is a callback called when the task is successfully executed
  65725. * @param onError is a callback called if an error occurs
  65726. */
  65727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65728. }
  65729. /**
  65730. * Define a task used by AssetsManager to load Equirectangular cube textures
  65731. */
  65732. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65733. /**
  65734. * Defines the name of the task
  65735. */
  65736. name: string;
  65737. /**
  65738. * Defines the location of the file to load
  65739. */
  65740. url: string;
  65741. /**
  65742. * Defines the desired size (the more it increases the longer the generation will be)
  65743. */
  65744. size: number;
  65745. /**
  65746. * Defines if mipmaps should not be generated (default is false)
  65747. */
  65748. noMipmap: boolean;
  65749. /**
  65750. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65751. * but the standard material would require them in Gamma space) (default is true)
  65752. */
  65753. gammaSpace: boolean;
  65754. /**
  65755. * Gets the loaded texture
  65756. */
  65757. texture: EquiRectangularCubeTexture;
  65758. /**
  65759. * Callback called when the task is successful
  65760. */
  65761. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65762. /**
  65763. * Callback called when the task is successful
  65764. */
  65765. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65766. /**
  65767. * Creates a new EquiRectangularCubeTextureAssetTask object
  65768. * @param name defines the name of the task
  65769. * @param url defines the location of the file to load
  65770. * @param size defines the desired size (the more it increases the longer the generation will be)
  65771. * If the size is omitted this implies you are using a preprocessed cubemap.
  65772. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65773. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65774. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65775. * (default is true)
  65776. */
  65777. constructor(
  65778. /**
  65779. * Defines the name of the task
  65780. */
  65781. name: string,
  65782. /**
  65783. * Defines the location of the file to load
  65784. */
  65785. url: string,
  65786. /**
  65787. * Defines the desired size (the more it increases the longer the generation will be)
  65788. */
  65789. size: number,
  65790. /**
  65791. * Defines if mipmaps should not be generated (default is false)
  65792. */
  65793. noMipmap?: boolean,
  65794. /**
  65795. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65796. * but the standard material would require them in Gamma space) (default is true)
  65797. */
  65798. gammaSpace?: boolean);
  65799. /**
  65800. * Execute the current task
  65801. * @param scene defines the scene where you want your assets to be loaded
  65802. * @param onSuccess is a callback called when the task is successfully executed
  65803. * @param onError is a callback called if an error occurs
  65804. */
  65805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65806. }
  65807. /**
  65808. * This class can be used to easily import assets into a scene
  65809. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65810. */
  65811. export class AssetsManager {
  65812. private _scene;
  65813. private _isLoading;
  65814. protected _tasks: AbstractAssetTask[];
  65815. protected _waitingTasksCount: number;
  65816. protected _totalTasksCount: number;
  65817. /**
  65818. * Callback called when all tasks are processed
  65819. */
  65820. onFinish: (tasks: AbstractAssetTask[]) => void;
  65821. /**
  65822. * Callback called when a task is successful
  65823. */
  65824. onTaskSuccess: (task: AbstractAssetTask) => void;
  65825. /**
  65826. * Callback called when a task had an error
  65827. */
  65828. onTaskError: (task: AbstractAssetTask) => void;
  65829. /**
  65830. * Callback called when a task is done (whatever the result is)
  65831. */
  65832. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65833. /**
  65834. * Observable called when all tasks are processed
  65835. */
  65836. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65837. /**
  65838. * Observable called when a task had an error
  65839. */
  65840. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65841. /**
  65842. * Observable called when all tasks were executed
  65843. */
  65844. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65845. /**
  65846. * Observable called when a task is done (whatever the result is)
  65847. */
  65848. onProgressObservable: Observable<IAssetsProgressEvent>;
  65849. /**
  65850. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65852. */
  65853. useDefaultLoadingScreen: boolean;
  65854. /**
  65855. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65856. * when all assets have been downloaded.
  65857. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65858. */
  65859. autoHideLoadingUI: boolean;
  65860. /**
  65861. * Creates a new AssetsManager
  65862. * @param scene defines the scene to work on
  65863. */
  65864. constructor(scene: Scene);
  65865. /**
  65866. * Add a MeshAssetTask to the list of active tasks
  65867. * @param taskName defines the name of the new task
  65868. * @param meshesNames defines the name of meshes to load
  65869. * @param rootUrl defines the root url to use to locate files
  65870. * @param sceneFilename defines the filename of the scene file
  65871. * @returns a new MeshAssetTask object
  65872. */
  65873. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65874. /**
  65875. * Add a TextFileAssetTask to the list of active tasks
  65876. * @param taskName defines the name of the new task
  65877. * @param url defines the url of the file to load
  65878. * @returns a new TextFileAssetTask object
  65879. */
  65880. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65881. /**
  65882. * Add a BinaryFileAssetTask to the list of active tasks
  65883. * @param taskName defines the name of the new task
  65884. * @param url defines the url of the file to load
  65885. * @returns a new BinaryFileAssetTask object
  65886. */
  65887. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65888. /**
  65889. * Add a ImageAssetTask to the list of active tasks
  65890. * @param taskName defines the name of the new task
  65891. * @param url defines the url of the file to load
  65892. * @returns a new ImageAssetTask object
  65893. */
  65894. addImageTask(taskName: string, url: string): ImageAssetTask;
  65895. /**
  65896. * Add a TextureAssetTask to the list of active tasks
  65897. * @param taskName defines the name of the new task
  65898. * @param url defines the url of the file to load
  65899. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65900. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65901. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65902. * @returns a new TextureAssetTask object
  65903. */
  65904. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65905. /**
  65906. * Add a CubeTextureAssetTask to the list of active tasks
  65907. * @param taskName defines the name of the new task
  65908. * @param url defines the url of the file to load
  65909. * @param extensions defines the extension to use to load the cube map (can be null)
  65910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65911. * @param files defines the list of files to load (can be null)
  65912. * @returns a new CubeTextureAssetTask object
  65913. */
  65914. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65915. /**
  65916. *
  65917. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65918. * @param taskName defines the name of the new task
  65919. * @param url defines the url of the file to load
  65920. * @param size defines the size you want for the cubemap (can be null)
  65921. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65922. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65923. * @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)
  65924. * @param reserved Internal use only
  65925. * @returns a new HDRCubeTextureAssetTask object
  65926. */
  65927. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65928. /**
  65929. *
  65930. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65931. * @param taskName defines the name of the new task
  65932. * @param url defines the url of the file to load
  65933. * @param size defines the size you want for the cubemap (can be null)
  65934. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65935. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65936. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65937. * @returns a new EquiRectangularCubeTextureAssetTask object
  65938. */
  65939. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65940. /**
  65941. * Remove a task from the assets manager.
  65942. * @param task the task to remove
  65943. */
  65944. removeTask(task: AbstractAssetTask): void;
  65945. private _decreaseWaitingTasksCount;
  65946. private _runTask;
  65947. /**
  65948. * Reset the AssetsManager and remove all tasks
  65949. * @return the current instance of the AssetsManager
  65950. */
  65951. reset(): AssetsManager;
  65952. /**
  65953. * Start the loading process
  65954. * @return the current instance of the AssetsManager
  65955. */
  65956. load(): AssetsManager;
  65957. /**
  65958. * Start the loading process as an async operation
  65959. * @return a promise returning the list of failed tasks
  65960. */
  65961. loadAsync(): Promise<void>;
  65962. }
  65963. }
  65964. declare module BABYLON {
  65965. /**
  65966. * Wrapper class for promise with external resolve and reject.
  65967. */
  65968. export class Deferred<T> {
  65969. /**
  65970. * The promise associated with this deferred object.
  65971. */
  65972. readonly promise: Promise<T>;
  65973. private _resolve;
  65974. private _reject;
  65975. /**
  65976. * The resolve method of the promise associated with this deferred object.
  65977. */
  65978. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  65979. /**
  65980. * The reject method of the promise associated with this deferred object.
  65981. */
  65982. get reject(): (reason?: any) => void;
  65983. /**
  65984. * Constructor for this deferred object.
  65985. */
  65986. constructor();
  65987. }
  65988. }
  65989. declare module BABYLON {
  65990. /**
  65991. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65992. */
  65993. export class MeshExploder {
  65994. private _centerMesh;
  65995. private _meshes;
  65996. private _meshesOrigins;
  65997. private _toCenterVectors;
  65998. private _scaledDirection;
  65999. private _newPosition;
  66000. private _centerPosition;
  66001. /**
  66002. * Explodes meshes from a center mesh.
  66003. * @param meshes The meshes to explode.
  66004. * @param centerMesh The mesh to be center of explosion.
  66005. */
  66006. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66007. private _setCenterMesh;
  66008. /**
  66009. * Get class name
  66010. * @returns "MeshExploder"
  66011. */
  66012. getClassName(): string;
  66013. /**
  66014. * "Exploded meshes"
  66015. * @returns Array of meshes with the centerMesh at index 0.
  66016. */
  66017. getMeshes(): Array<Mesh>;
  66018. /**
  66019. * Explodes meshes giving a specific direction
  66020. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66021. */
  66022. explode(direction?: number): void;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * Class used to help managing file picking and drag'n'drop
  66028. */
  66029. export class FilesInput {
  66030. /**
  66031. * List of files ready to be loaded
  66032. */
  66033. static get FilesToLoad(): {
  66034. [key: string]: File;
  66035. };
  66036. /**
  66037. * Callback called when a file is processed
  66038. */
  66039. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66040. private _engine;
  66041. private _currentScene;
  66042. private _sceneLoadedCallback;
  66043. private _progressCallback;
  66044. private _additionalRenderLoopLogicCallback;
  66045. private _textureLoadingCallback;
  66046. private _startingProcessingFilesCallback;
  66047. private _onReloadCallback;
  66048. private _errorCallback;
  66049. private _elementToMonitor;
  66050. private _sceneFileToLoad;
  66051. private _filesToLoad;
  66052. /**
  66053. * Creates a new FilesInput
  66054. * @param engine defines the rendering engine
  66055. * @param scene defines the hosting scene
  66056. * @param sceneLoadedCallback callback called when scene is loaded
  66057. * @param progressCallback callback called to track progress
  66058. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66059. * @param textureLoadingCallback callback called when a texture is loading
  66060. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66061. * @param onReloadCallback callback called when a reload is requested
  66062. * @param errorCallback callback call if an error occurs
  66063. */
  66064. 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);
  66065. private _dragEnterHandler;
  66066. private _dragOverHandler;
  66067. private _dropHandler;
  66068. /**
  66069. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66070. * @param elementToMonitor defines the DOM element to track
  66071. */
  66072. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66073. /**
  66074. * Release all associated resources
  66075. */
  66076. dispose(): void;
  66077. private renderFunction;
  66078. private drag;
  66079. private drop;
  66080. private _traverseFolder;
  66081. private _processFiles;
  66082. /**
  66083. * Load files from a drop event
  66084. * @param event defines the drop event to use as source
  66085. */
  66086. loadFiles(event: any): void;
  66087. private _processReload;
  66088. /**
  66089. * Reload the current scene from the loaded files
  66090. */
  66091. reload(): void;
  66092. }
  66093. }
  66094. declare module BABYLON {
  66095. /**
  66096. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66098. */
  66099. export class SceneOptimization {
  66100. /**
  66101. * Defines the priority of this optimization (0 by default which means first in the list)
  66102. */
  66103. priority: number;
  66104. /**
  66105. * Gets a string describing the action executed by the current optimization
  66106. * @returns description string
  66107. */
  66108. getDescription(): string;
  66109. /**
  66110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66111. * @param scene defines the current scene where to apply this optimization
  66112. * @param optimizer defines the current optimizer
  66113. * @returns true if everything that can be done was applied
  66114. */
  66115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66116. /**
  66117. * Creates the SceneOptimization object
  66118. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66119. * @param desc defines the description associated with the optimization
  66120. */
  66121. constructor(
  66122. /**
  66123. * Defines the priority of this optimization (0 by default which means first in the list)
  66124. */
  66125. priority?: number);
  66126. }
  66127. /**
  66128. * Defines an optimization used to reduce the size of render target textures
  66129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66130. */
  66131. export class TextureOptimization extends SceneOptimization {
  66132. /**
  66133. * Defines the priority of this optimization (0 by default which means first in the list)
  66134. */
  66135. priority: number;
  66136. /**
  66137. * 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
  66138. */
  66139. maximumSize: number;
  66140. /**
  66141. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66142. */
  66143. step: number;
  66144. /**
  66145. * Gets a string describing the action executed by the current optimization
  66146. * @returns description string
  66147. */
  66148. getDescription(): string;
  66149. /**
  66150. * Creates the TextureOptimization object
  66151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66152. * @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
  66153. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66154. */
  66155. constructor(
  66156. /**
  66157. * Defines the priority of this optimization (0 by default which means first in the list)
  66158. */
  66159. priority?: number,
  66160. /**
  66161. * 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
  66162. */
  66163. maximumSize?: number,
  66164. /**
  66165. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66166. */
  66167. step?: number);
  66168. /**
  66169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66170. * @param scene defines the current scene where to apply this optimization
  66171. * @param optimizer defines the current optimizer
  66172. * @returns true if everything that can be done was applied
  66173. */
  66174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66175. }
  66176. /**
  66177. * Defines an optimization used to increase or decrease the rendering resolution
  66178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66179. */
  66180. export class HardwareScalingOptimization extends SceneOptimization {
  66181. /**
  66182. * Defines the priority of this optimization (0 by default which means first in the list)
  66183. */
  66184. priority: number;
  66185. /**
  66186. * Defines the maximum scale to use (2 by default)
  66187. */
  66188. maximumScale: number;
  66189. /**
  66190. * Defines the step to use between two passes (0.5 by default)
  66191. */
  66192. step: number;
  66193. private _currentScale;
  66194. private _directionOffset;
  66195. /**
  66196. * Gets a string describing the action executed by the current optimization
  66197. * @return description string
  66198. */
  66199. getDescription(): string;
  66200. /**
  66201. * Creates the HardwareScalingOptimization object
  66202. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66203. * @param maximumScale defines the maximum scale to use (2 by default)
  66204. * @param step defines the step to use between two passes (0.5 by default)
  66205. */
  66206. constructor(
  66207. /**
  66208. * Defines the priority of this optimization (0 by default which means first in the list)
  66209. */
  66210. priority?: number,
  66211. /**
  66212. * Defines the maximum scale to use (2 by default)
  66213. */
  66214. maximumScale?: number,
  66215. /**
  66216. * Defines the step to use between two passes (0.5 by default)
  66217. */
  66218. step?: number);
  66219. /**
  66220. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66221. * @param scene defines the current scene where to apply this optimization
  66222. * @param optimizer defines the current optimizer
  66223. * @returns true if everything that can be done was applied
  66224. */
  66225. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66226. }
  66227. /**
  66228. * Defines an optimization used to remove shadows
  66229. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66230. */
  66231. export class ShadowsOptimization extends SceneOptimization {
  66232. /**
  66233. * Gets a string describing the action executed by the current optimization
  66234. * @return description string
  66235. */
  66236. getDescription(): string;
  66237. /**
  66238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66239. * @param scene defines the current scene where to apply this optimization
  66240. * @param optimizer defines the current optimizer
  66241. * @returns true if everything that can be done was applied
  66242. */
  66243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66244. }
  66245. /**
  66246. * Defines an optimization used to turn post-processes off
  66247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66248. */
  66249. export class PostProcessesOptimization extends SceneOptimization {
  66250. /**
  66251. * Gets a string describing the action executed by the current optimization
  66252. * @return description string
  66253. */
  66254. getDescription(): string;
  66255. /**
  66256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66257. * @param scene defines the current scene where to apply this optimization
  66258. * @param optimizer defines the current optimizer
  66259. * @returns true if everything that can be done was applied
  66260. */
  66261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66262. }
  66263. /**
  66264. * Defines an optimization used to turn lens flares off
  66265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66266. */
  66267. export class LensFlaresOptimization extends SceneOptimization {
  66268. /**
  66269. * Gets a string describing the action executed by the current optimization
  66270. * @return description string
  66271. */
  66272. getDescription(): string;
  66273. /**
  66274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66275. * @param scene defines the current scene where to apply this optimization
  66276. * @param optimizer defines the current optimizer
  66277. * @returns true if everything that can be done was applied
  66278. */
  66279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66280. }
  66281. /**
  66282. * Defines an optimization based on user defined callback.
  66283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66284. */
  66285. export class CustomOptimization extends SceneOptimization {
  66286. /**
  66287. * Callback called to apply the custom optimization.
  66288. */
  66289. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66290. /**
  66291. * Callback called to get custom description
  66292. */
  66293. onGetDescription: () => string;
  66294. /**
  66295. * Gets a string describing the action executed by the current optimization
  66296. * @returns description string
  66297. */
  66298. getDescription(): string;
  66299. /**
  66300. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66301. * @param scene defines the current scene where to apply this optimization
  66302. * @param optimizer defines the current optimizer
  66303. * @returns true if everything that can be done was applied
  66304. */
  66305. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66306. }
  66307. /**
  66308. * Defines an optimization used to turn particles off
  66309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66310. */
  66311. export class ParticlesOptimization extends SceneOptimization {
  66312. /**
  66313. * Gets a string describing the action executed by the current optimization
  66314. * @return description string
  66315. */
  66316. getDescription(): string;
  66317. /**
  66318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66319. * @param scene defines the current scene where to apply this optimization
  66320. * @param optimizer defines the current optimizer
  66321. * @returns true if everything that can be done was applied
  66322. */
  66323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66324. }
  66325. /**
  66326. * Defines an optimization used to turn render targets off
  66327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66328. */
  66329. export class RenderTargetsOptimization extends SceneOptimization {
  66330. /**
  66331. * Gets a string describing the action executed by the current optimization
  66332. * @return description string
  66333. */
  66334. getDescription(): string;
  66335. /**
  66336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66337. * @param scene defines the current scene where to apply this optimization
  66338. * @param optimizer defines the current optimizer
  66339. * @returns true if everything that can be done was applied
  66340. */
  66341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66342. }
  66343. /**
  66344. * Defines an optimization used to merge meshes with compatible materials
  66345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66346. */
  66347. export class MergeMeshesOptimization extends SceneOptimization {
  66348. private static _UpdateSelectionTree;
  66349. /**
  66350. * Gets or sets a boolean which defines if optimization octree has to be updated
  66351. */
  66352. static get UpdateSelectionTree(): boolean;
  66353. /**
  66354. * Gets or sets a boolean which defines if optimization octree has to be updated
  66355. */
  66356. static set UpdateSelectionTree(value: boolean);
  66357. /**
  66358. * Gets a string describing the action executed by the current optimization
  66359. * @return description string
  66360. */
  66361. getDescription(): string;
  66362. private _canBeMerged;
  66363. /**
  66364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66365. * @param scene defines the current scene where to apply this optimization
  66366. * @param optimizer defines the current optimizer
  66367. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66368. * @returns true if everything that can be done was applied
  66369. */
  66370. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66371. }
  66372. /**
  66373. * Defines a list of options used by SceneOptimizer
  66374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66375. */
  66376. export class SceneOptimizerOptions {
  66377. /**
  66378. * Defines the target frame rate to reach (60 by default)
  66379. */
  66380. targetFrameRate: number;
  66381. /**
  66382. * Defines the interval between two checkes (2000ms by default)
  66383. */
  66384. trackerDuration: number;
  66385. /**
  66386. * Gets the list of optimizations to apply
  66387. */
  66388. optimizations: SceneOptimization[];
  66389. /**
  66390. * Creates a new list of options used by SceneOptimizer
  66391. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66392. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66393. */
  66394. constructor(
  66395. /**
  66396. * Defines the target frame rate to reach (60 by default)
  66397. */
  66398. targetFrameRate?: number,
  66399. /**
  66400. * Defines the interval between two checkes (2000ms by default)
  66401. */
  66402. trackerDuration?: number);
  66403. /**
  66404. * Add a new optimization
  66405. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66406. * @returns the current SceneOptimizerOptions
  66407. */
  66408. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66409. /**
  66410. * Add a new custom optimization
  66411. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66412. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66413. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66414. * @returns the current SceneOptimizerOptions
  66415. */
  66416. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66417. /**
  66418. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66419. * @param targetFrameRate defines the target frame rate (60 by default)
  66420. * @returns a SceneOptimizerOptions object
  66421. */
  66422. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66423. /**
  66424. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66425. * @param targetFrameRate defines the target frame rate (60 by default)
  66426. * @returns a SceneOptimizerOptions object
  66427. */
  66428. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66429. /**
  66430. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66431. * @param targetFrameRate defines the target frame rate (60 by default)
  66432. * @returns a SceneOptimizerOptions object
  66433. */
  66434. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66435. }
  66436. /**
  66437. * Class used to run optimizations in order to reach a target frame rate
  66438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66439. */
  66440. export class SceneOptimizer implements IDisposable {
  66441. private _isRunning;
  66442. private _options;
  66443. private _scene;
  66444. private _currentPriorityLevel;
  66445. private _targetFrameRate;
  66446. private _trackerDuration;
  66447. private _currentFrameRate;
  66448. private _sceneDisposeObserver;
  66449. private _improvementMode;
  66450. /**
  66451. * Defines an observable called when the optimizer reaches the target frame rate
  66452. */
  66453. onSuccessObservable: Observable<SceneOptimizer>;
  66454. /**
  66455. * Defines an observable called when the optimizer enables an optimization
  66456. */
  66457. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66458. /**
  66459. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66460. */
  66461. onFailureObservable: Observable<SceneOptimizer>;
  66462. /**
  66463. * Gets a boolean indicating if the optimizer is in improvement mode
  66464. */
  66465. get isInImprovementMode(): boolean;
  66466. /**
  66467. * Gets the current priority level (0 at start)
  66468. */
  66469. get currentPriorityLevel(): number;
  66470. /**
  66471. * Gets the current frame rate checked by the SceneOptimizer
  66472. */
  66473. get currentFrameRate(): number;
  66474. /**
  66475. * Gets or sets the current target frame rate (60 by default)
  66476. */
  66477. get targetFrameRate(): number;
  66478. /**
  66479. * Gets or sets the current target frame rate (60 by default)
  66480. */
  66481. set targetFrameRate(value: number);
  66482. /**
  66483. * Gets or sets the current interval between two checks (every 2000ms by default)
  66484. */
  66485. get trackerDuration(): number;
  66486. /**
  66487. * Gets or sets the current interval between two checks (every 2000ms by default)
  66488. */
  66489. set trackerDuration(value: number);
  66490. /**
  66491. * Gets the list of active optimizations
  66492. */
  66493. get optimizations(): SceneOptimization[];
  66494. /**
  66495. * Creates a new SceneOptimizer
  66496. * @param scene defines the scene to work on
  66497. * @param options defines the options to use with the SceneOptimizer
  66498. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66499. * @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)
  66500. */
  66501. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66502. /**
  66503. * Stops the current optimizer
  66504. */
  66505. stop(): void;
  66506. /**
  66507. * Reset the optimizer to initial step (current priority level = 0)
  66508. */
  66509. reset(): void;
  66510. /**
  66511. * Start the optimizer. By default it will try to reach a specific framerate
  66512. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66513. */
  66514. start(): void;
  66515. private _checkCurrentState;
  66516. /**
  66517. * Release all resources
  66518. */
  66519. dispose(): void;
  66520. /**
  66521. * Helper function to create a SceneOptimizer with one single line of code
  66522. * @param scene defines the scene to work on
  66523. * @param options defines the options to use with the SceneOptimizer
  66524. * @param onSuccess defines a callback to call on success
  66525. * @param onFailure defines a callback to call on failure
  66526. * @returns the new SceneOptimizer object
  66527. */
  66528. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66529. }
  66530. }
  66531. declare module BABYLON {
  66532. /**
  66533. * Class used to serialize a scene into a string
  66534. */
  66535. export class SceneSerializer {
  66536. /**
  66537. * Clear cache used by a previous serialization
  66538. */
  66539. static ClearCache(): void;
  66540. /**
  66541. * Serialize a scene into a JSON compatible object
  66542. * @param scene defines the scene to serialize
  66543. * @returns a JSON compatible object
  66544. */
  66545. static Serialize(scene: Scene): any;
  66546. /**
  66547. * Serialize a mesh into a JSON compatible object
  66548. * @param toSerialize defines the mesh to serialize
  66549. * @param withParents defines if parents must be serialized as well
  66550. * @param withChildren defines if children must be serialized as well
  66551. * @returns a JSON compatible object
  66552. */
  66553. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66554. }
  66555. }
  66556. declare module BABYLON {
  66557. /**
  66558. * Class used to host texture specific utilities
  66559. */
  66560. export class TextureTools {
  66561. /**
  66562. * Uses the GPU to create a copy texture rescaled at a given size
  66563. * @param texture Texture to copy from
  66564. * @param width defines the desired width
  66565. * @param height defines the desired height
  66566. * @param useBilinearMode defines if bilinear mode has to be used
  66567. * @return the generated texture
  66568. */
  66569. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66570. }
  66571. }
  66572. declare module BABYLON {
  66573. /**
  66574. * This represents the different options available for the video capture.
  66575. */
  66576. export interface VideoRecorderOptions {
  66577. /** Defines the mime type of the video. */
  66578. mimeType: string;
  66579. /** Defines the FPS the video should be recorded at. */
  66580. fps: number;
  66581. /** Defines the chunk size for the recording data. */
  66582. recordChunckSize: number;
  66583. /** The audio tracks to attach to the recording. */
  66584. audioTracks?: MediaStreamTrack[];
  66585. }
  66586. /**
  66587. * This can help with recording videos from BabylonJS.
  66588. * This is based on the available WebRTC functionalities of the browser.
  66589. *
  66590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66591. */
  66592. export class VideoRecorder {
  66593. private static readonly _defaultOptions;
  66594. /**
  66595. * Returns whether or not the VideoRecorder is available in your browser.
  66596. * @param engine Defines the Babylon Engine.
  66597. * @returns true if supported otherwise false.
  66598. */
  66599. static IsSupported(engine: Engine): boolean;
  66600. private readonly _options;
  66601. private _canvas;
  66602. private _mediaRecorder;
  66603. private _recordedChunks;
  66604. private _fileName;
  66605. private _resolve;
  66606. private _reject;
  66607. /**
  66608. * True when a recording is already in progress.
  66609. */
  66610. get isRecording(): boolean;
  66611. /**
  66612. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66613. * @param engine Defines the BabylonJS Engine you wish to record.
  66614. * @param options Defines options that can be used to customize the capture.
  66615. */
  66616. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66617. /**
  66618. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66619. */
  66620. stopRecording(): void;
  66621. /**
  66622. * Starts recording the canvas for a max duration specified in parameters.
  66623. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66624. * If null no automatic download will start and you can rely on the promise to get the data back.
  66625. * @param maxDuration Defines the maximum recording time in seconds.
  66626. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66627. * @return A promise callback at the end of the recording with the video data in Blob.
  66628. */
  66629. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66630. /**
  66631. * Releases internal resources used during the recording.
  66632. */
  66633. dispose(): void;
  66634. private _handleDataAvailable;
  66635. private _handleError;
  66636. private _handleStop;
  66637. }
  66638. }
  66639. declare module BABYLON {
  66640. /**
  66641. * Class containing a set of static utilities functions for screenshots
  66642. */
  66643. export class ScreenshotTools {
  66644. /**
  66645. * Captures a screenshot of the current rendering
  66646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66647. * @param engine defines the rendering engine
  66648. * @param camera defines the source camera
  66649. * @param size This parameter can be set to a single number or to an object with the
  66650. * following (optional) properties: precision, width, height. If a single number is passed,
  66651. * it will be used for both width and height. If an object is passed, the screenshot size
  66652. * will be derived from the parameters. The precision property is a multiplier allowing
  66653. * rendering at a higher or lower resolution
  66654. * @param successCallback defines the callback receives a single parameter which contains the
  66655. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66656. * src parameter of an <img> to display it
  66657. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66658. * Check your browser for supported MIME types
  66659. */
  66660. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66661. /**
  66662. * Captures a screenshot of the current rendering
  66663. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66664. * @param engine defines the rendering engine
  66665. * @param camera defines the source camera
  66666. * @param size This parameter can be set to a single number or to an object with the
  66667. * following (optional) properties: precision, width, height. If a single number is passed,
  66668. * it will be used for both width and height. If an object is passed, the screenshot size
  66669. * will be derived from the parameters. The precision property is a multiplier allowing
  66670. * rendering at a higher or lower resolution
  66671. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66672. * Check your browser for supported MIME types
  66673. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66674. * to the src parameter of an <img> to display it
  66675. */
  66676. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66677. /**
  66678. * Generates an image screenshot from the specified camera.
  66679. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66680. * @param engine The engine to use for rendering
  66681. * @param camera The camera to use for rendering
  66682. * @param size This parameter can be set to a single number or to an object with the
  66683. * following (optional) properties: precision, width, height. If a single number is passed,
  66684. * it will be used for both width and height. If an object is passed, the screenshot size
  66685. * will be derived from the parameters. The precision property is a multiplier allowing
  66686. * rendering at a higher or lower resolution
  66687. * @param successCallback The callback receives a single parameter which contains the
  66688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66689. * src parameter of an <img> to display it
  66690. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66691. * Check your browser for supported MIME types
  66692. * @param samples Texture samples (default: 1)
  66693. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66694. * @param fileName A name for for the downloaded file.
  66695. */
  66696. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66697. /**
  66698. * Generates an image screenshot from the specified camera.
  66699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66700. * @param engine The engine to use for rendering
  66701. * @param camera The camera to use for rendering
  66702. * @param size This parameter can be set to a single number or to an object with the
  66703. * following (optional) properties: precision, width, height. If a single number is passed,
  66704. * it will be used for both width and height. If an object is passed, the screenshot size
  66705. * will be derived from the parameters. The precision property is a multiplier allowing
  66706. * rendering at a higher or lower resolution
  66707. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66708. * Check your browser for supported MIME types
  66709. * @param samples Texture samples (default: 1)
  66710. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66711. * @param fileName A name for for the downloaded file.
  66712. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66713. * to the src parameter of an <img> to display it
  66714. */
  66715. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66716. /**
  66717. * Gets height and width for screenshot size
  66718. * @private
  66719. */
  66720. private static _getScreenshotSize;
  66721. }
  66722. }
  66723. declare module BABYLON {
  66724. /**
  66725. * Interface for a data buffer
  66726. */
  66727. export interface IDataBuffer {
  66728. /**
  66729. * Reads bytes from the data buffer.
  66730. * @param byteOffset The byte offset to read
  66731. * @param byteLength The byte length to read
  66732. * @returns A promise that resolves when the bytes are read
  66733. */
  66734. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66735. /**
  66736. * The byte length of the buffer.
  66737. */
  66738. readonly byteLength: number;
  66739. }
  66740. /**
  66741. * Utility class for reading from a data buffer
  66742. */
  66743. export class DataReader {
  66744. /**
  66745. * The data buffer associated with this data reader.
  66746. */
  66747. readonly buffer: IDataBuffer;
  66748. /**
  66749. * The current byte offset from the beginning of the data buffer.
  66750. */
  66751. byteOffset: number;
  66752. private _dataView;
  66753. private _dataByteOffset;
  66754. /**
  66755. * Constructor
  66756. * @param buffer The buffer to read
  66757. */
  66758. constructor(buffer: IDataBuffer);
  66759. /**
  66760. * Loads the given byte length.
  66761. * @param byteLength The byte length to load
  66762. * @returns A promise that resolves when the load is complete
  66763. */
  66764. loadAsync(byteLength: number): Promise<void>;
  66765. /**
  66766. * Read a unsigned 32-bit integer from the currently loaded data range.
  66767. * @returns The 32-bit integer read
  66768. */
  66769. readUint32(): number;
  66770. /**
  66771. * Read a byte array from the currently loaded data range.
  66772. * @param byteLength The byte length to read
  66773. * @returns The byte array read
  66774. */
  66775. readUint8Array(byteLength: number): Uint8Array;
  66776. /**
  66777. * Read a string from the currently loaded data range.
  66778. * @param byteLength The byte length to read
  66779. * @returns The string read
  66780. */
  66781. readString(byteLength: number): string;
  66782. /**
  66783. * Skips the given byte length the currently loaded data range.
  66784. * @param byteLength The byte length to skip
  66785. */
  66786. skipBytes(byteLength: number): void;
  66787. }
  66788. }
  66789. declare module BABYLON {
  66790. /**
  66791. * A cursor which tracks a point on a path
  66792. */
  66793. export class PathCursor {
  66794. private path;
  66795. /**
  66796. * Stores path cursor callbacks for when an onchange event is triggered
  66797. */
  66798. private _onchange;
  66799. /**
  66800. * The value of the path cursor
  66801. */
  66802. value: number;
  66803. /**
  66804. * The animation array of the path cursor
  66805. */
  66806. animations: Animation[];
  66807. /**
  66808. * Initializes the path cursor
  66809. * @param path The path to track
  66810. */
  66811. constructor(path: Path2);
  66812. /**
  66813. * Gets the cursor point on the path
  66814. * @returns A point on the path cursor at the cursor location
  66815. */
  66816. getPoint(): Vector3;
  66817. /**
  66818. * Moves the cursor ahead by the step amount
  66819. * @param step The amount to move the cursor forward
  66820. * @returns This path cursor
  66821. */
  66822. moveAhead(step?: number): PathCursor;
  66823. /**
  66824. * Moves the cursor behind by the step amount
  66825. * @param step The amount to move the cursor back
  66826. * @returns This path cursor
  66827. */
  66828. moveBack(step?: number): PathCursor;
  66829. /**
  66830. * Moves the cursor by the step amount
  66831. * If the step amount is greater than one, an exception is thrown
  66832. * @param step The amount to move the cursor
  66833. * @returns This path cursor
  66834. */
  66835. move(step: number): PathCursor;
  66836. /**
  66837. * Ensures that the value is limited between zero and one
  66838. * @returns This path cursor
  66839. */
  66840. private ensureLimits;
  66841. /**
  66842. * Runs onchange callbacks on change (used by the animation engine)
  66843. * @returns This path cursor
  66844. */
  66845. private raiseOnChange;
  66846. /**
  66847. * Executes a function on change
  66848. * @param f A path cursor onchange callback
  66849. * @returns This path cursor
  66850. */
  66851. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66852. }
  66853. }
  66854. declare module BABYLON {
  66855. /** @hidden */
  66856. export var blurPixelShader: {
  66857. name: string;
  66858. shader: string;
  66859. };
  66860. }
  66861. declare module BABYLON {
  66862. /** @hidden */
  66863. export var pointCloudVertexDeclaration: {
  66864. name: string;
  66865. shader: string;
  66866. };
  66867. }
  66868. // Mixins
  66869. interface Window {
  66870. mozIndexedDB: IDBFactory;
  66871. webkitIndexedDB: IDBFactory;
  66872. msIndexedDB: IDBFactory;
  66873. webkitURL: typeof URL;
  66874. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66875. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66876. WebGLRenderingContext: WebGLRenderingContext;
  66877. MSGesture: MSGesture;
  66878. CANNON: any;
  66879. AudioContext: AudioContext;
  66880. webkitAudioContext: AudioContext;
  66881. PointerEvent: any;
  66882. Math: Math;
  66883. Uint8Array: Uint8ArrayConstructor;
  66884. Float32Array: Float32ArrayConstructor;
  66885. mozURL: typeof URL;
  66886. msURL: typeof URL;
  66887. VRFrameData: any; // WebVR, from specs 1.1
  66888. DracoDecoderModule: any;
  66889. setImmediate(handler: (...args: any[]) => void): number;
  66890. }
  66891. interface HTMLCanvasElement {
  66892. requestPointerLock(): void;
  66893. msRequestPointerLock?(): void;
  66894. mozRequestPointerLock?(): void;
  66895. webkitRequestPointerLock?(): void;
  66896. /** Track wether a record is in progress */
  66897. isRecording: boolean;
  66898. /** Capture Stream method defined by some browsers */
  66899. captureStream(fps?: number): MediaStream;
  66900. }
  66901. interface CanvasRenderingContext2D {
  66902. msImageSmoothingEnabled: boolean;
  66903. }
  66904. interface MouseEvent {
  66905. mozMovementX: number;
  66906. mozMovementY: number;
  66907. webkitMovementX: number;
  66908. webkitMovementY: number;
  66909. msMovementX: number;
  66910. msMovementY: number;
  66911. }
  66912. interface Navigator {
  66913. mozGetVRDevices: (any: any) => any;
  66914. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66915. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66916. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66917. webkitGetGamepads(): Gamepad[];
  66918. msGetGamepads(): Gamepad[];
  66919. webkitGamepads(): Gamepad[];
  66920. }
  66921. interface HTMLVideoElement {
  66922. mozSrcObject: any;
  66923. }
  66924. interface Math {
  66925. fround(x: number): number;
  66926. imul(a: number, b: number): number;
  66927. }
  66928. interface WebGLRenderingContext {
  66929. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66930. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66931. vertexAttribDivisor(index: number, divisor: number): void;
  66932. createVertexArray(): any;
  66933. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66934. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66935. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66936. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66937. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66938. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66939. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66940. // Queries
  66941. createQuery(): WebGLQuery;
  66942. deleteQuery(query: WebGLQuery): void;
  66943. beginQuery(target: number, query: WebGLQuery): void;
  66944. endQuery(target: number): void;
  66945. getQueryParameter(query: WebGLQuery, pname: number): any;
  66946. getQuery(target: number, pname: number): any;
  66947. MAX_SAMPLES: number;
  66948. RGBA8: number;
  66949. READ_FRAMEBUFFER: number;
  66950. DRAW_FRAMEBUFFER: number;
  66951. UNIFORM_BUFFER: number;
  66952. HALF_FLOAT_OES: number;
  66953. RGBA16F: number;
  66954. RGBA32F: number;
  66955. R32F: number;
  66956. RG32F: number;
  66957. RGB32F: number;
  66958. R16F: number;
  66959. RG16F: number;
  66960. RGB16F: number;
  66961. RED: number;
  66962. RG: number;
  66963. R8: number;
  66964. RG8: number;
  66965. UNSIGNED_INT_24_8: number;
  66966. DEPTH24_STENCIL8: number;
  66967. MIN: number;
  66968. MAX: number;
  66969. /* Multiple Render Targets */
  66970. drawBuffers(buffers: number[]): void;
  66971. readBuffer(src: number): void;
  66972. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66973. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66974. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66975. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66976. // Occlusion Query
  66977. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66978. ANY_SAMPLES_PASSED: number;
  66979. QUERY_RESULT_AVAILABLE: number;
  66980. QUERY_RESULT: number;
  66981. }
  66982. interface WebGLProgram {
  66983. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66984. }
  66985. interface EXT_disjoint_timer_query {
  66986. QUERY_COUNTER_BITS_EXT: number;
  66987. TIME_ELAPSED_EXT: number;
  66988. TIMESTAMP_EXT: number;
  66989. GPU_DISJOINT_EXT: number;
  66990. QUERY_RESULT_EXT: number;
  66991. QUERY_RESULT_AVAILABLE_EXT: number;
  66992. queryCounterEXT(query: WebGLQuery, target: number): void;
  66993. createQueryEXT(): WebGLQuery;
  66994. beginQueryEXT(target: number, query: WebGLQuery): void;
  66995. endQueryEXT(target: number): void;
  66996. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66997. deleteQueryEXT(query: WebGLQuery): void;
  66998. }
  66999. interface WebGLUniformLocation {
  67000. _currentState: any;
  67001. }
  67002. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  67003. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  67004. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  67005. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67006. interface WebGLRenderingContext {
  67007. readonly RASTERIZER_DISCARD: number;
  67008. readonly DEPTH_COMPONENT24: number;
  67009. readonly TEXTURE_3D: number;
  67010. readonly TEXTURE_2D_ARRAY: number;
  67011. readonly TEXTURE_COMPARE_FUNC: number;
  67012. readonly TEXTURE_COMPARE_MODE: number;
  67013. readonly COMPARE_REF_TO_TEXTURE: number;
  67014. readonly TEXTURE_WRAP_R: number;
  67015. readonly HALF_FLOAT: number;
  67016. readonly RGB8: number;
  67017. readonly RED_INTEGER: number;
  67018. readonly RG_INTEGER: number;
  67019. readonly RGB_INTEGER: number;
  67020. readonly RGBA_INTEGER: number;
  67021. readonly R8_SNORM: number;
  67022. readonly RG8_SNORM: number;
  67023. readonly RGB8_SNORM: number;
  67024. readonly RGBA8_SNORM: number;
  67025. readonly R8I: number;
  67026. readonly RG8I: number;
  67027. readonly RGB8I: number;
  67028. readonly RGBA8I: number;
  67029. readonly R8UI: number;
  67030. readonly RG8UI: number;
  67031. readonly RGB8UI: number;
  67032. readonly RGBA8UI: number;
  67033. readonly R16I: number;
  67034. readonly RG16I: number;
  67035. readonly RGB16I: number;
  67036. readonly RGBA16I: number;
  67037. readonly R16UI: number;
  67038. readonly RG16UI: number;
  67039. readonly RGB16UI: number;
  67040. readonly RGBA16UI: number;
  67041. readonly R32I: number;
  67042. readonly RG32I: number;
  67043. readonly RGB32I: number;
  67044. readonly RGBA32I: number;
  67045. readonly R32UI: number;
  67046. readonly RG32UI: number;
  67047. readonly RGB32UI: number;
  67048. readonly RGBA32UI: number;
  67049. readonly RGB10_A2UI: number;
  67050. readonly R11F_G11F_B10F: number;
  67051. readonly RGB9_E5: number;
  67052. readonly RGB10_A2: number;
  67053. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67054. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67055. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67056. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67057. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67058. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67059. 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;
  67060. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67061. readonly TRANSFORM_FEEDBACK: number;
  67062. readonly INTERLEAVED_ATTRIBS: number;
  67063. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67064. createTransformFeedback(): WebGLTransformFeedback;
  67065. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67066. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67067. beginTransformFeedback(primitiveMode: number): void;
  67068. endTransformFeedback(): void;
  67069. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67070. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67071. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67072. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67073. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67074. }
  67075. interface ImageBitmap {
  67076. readonly width: number;
  67077. readonly height: number;
  67078. close(): void;
  67079. }
  67080. interface WebGLQuery extends WebGLObject {
  67081. }
  67082. declare var WebGLQuery: {
  67083. prototype: WebGLQuery;
  67084. new(): WebGLQuery;
  67085. };
  67086. interface WebGLSampler extends WebGLObject {
  67087. }
  67088. declare var WebGLSampler: {
  67089. prototype: WebGLSampler;
  67090. new(): WebGLSampler;
  67091. };
  67092. interface WebGLSync extends WebGLObject {
  67093. }
  67094. declare var WebGLSync: {
  67095. prototype: WebGLSync;
  67096. new(): WebGLSync;
  67097. };
  67098. interface WebGLTransformFeedback extends WebGLObject {
  67099. }
  67100. declare var WebGLTransformFeedback: {
  67101. prototype: WebGLTransformFeedback;
  67102. new(): WebGLTransformFeedback;
  67103. };
  67104. interface WebGLVertexArrayObject extends WebGLObject {
  67105. }
  67106. declare var WebGLVertexArrayObject: {
  67107. prototype: WebGLVertexArrayObject;
  67108. new(): WebGLVertexArrayObject;
  67109. };
  67110. // Type definitions for WebVR API
  67111. // Project: https://w3c.github.io/webvr/
  67112. // Definitions by: six a <https://github.com/lostfictions>
  67113. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67114. interface VRDisplay extends EventTarget {
  67115. /**
  67116. * Dictionary of capabilities describing the VRDisplay.
  67117. */
  67118. readonly capabilities: VRDisplayCapabilities;
  67119. /**
  67120. * z-depth defining the far plane of the eye view frustum
  67121. * enables mapping of values in the render target depth
  67122. * attachment to scene coordinates. Initially set to 10000.0.
  67123. */
  67124. depthFar: number;
  67125. /**
  67126. * z-depth defining the near plane of the eye view frustum
  67127. * enables mapping of values in the render target depth
  67128. * attachment to scene coordinates. Initially set to 0.01.
  67129. */
  67130. depthNear: number;
  67131. /**
  67132. * An identifier for this distinct VRDisplay. Used as an
  67133. * association point in the Gamepad API.
  67134. */
  67135. readonly displayId: number;
  67136. /**
  67137. * A display name, a user-readable name identifying it.
  67138. */
  67139. readonly displayName: string;
  67140. readonly isConnected: boolean;
  67141. readonly isPresenting: boolean;
  67142. /**
  67143. * If this VRDisplay supports room-scale experiences, the optional
  67144. * stage attribute contains details on the room-scale parameters.
  67145. */
  67146. readonly stageParameters: VRStageParameters | null;
  67147. /**
  67148. * Passing the value returned by `requestAnimationFrame` to
  67149. * `cancelAnimationFrame` will unregister the callback.
  67150. * @param handle Define the hanle of the request to cancel
  67151. */
  67152. cancelAnimationFrame(handle: number): void;
  67153. /**
  67154. * Stops presenting to the VRDisplay.
  67155. * @returns a promise to know when it stopped
  67156. */
  67157. exitPresent(): Promise<void>;
  67158. /**
  67159. * Return the current VREyeParameters for the given eye.
  67160. * @param whichEye Define the eye we want the parameter for
  67161. * @returns the eye parameters
  67162. */
  67163. getEyeParameters(whichEye: string): VREyeParameters;
  67164. /**
  67165. * Populates the passed VRFrameData with the information required to render
  67166. * the current frame.
  67167. * @param frameData Define the data structure to populate
  67168. * @returns true if ok otherwise false
  67169. */
  67170. getFrameData(frameData: VRFrameData): boolean;
  67171. /**
  67172. * Get the layers currently being presented.
  67173. * @returns the list of VR layers
  67174. */
  67175. getLayers(): VRLayer[];
  67176. /**
  67177. * Return a VRPose containing the future predicted pose of the VRDisplay
  67178. * when the current frame will be presented. The value returned will not
  67179. * change until JavaScript has returned control to the browser.
  67180. *
  67181. * The VRPose will contain the position, orientation, velocity,
  67182. * and acceleration of each of these properties.
  67183. * @returns the pose object
  67184. */
  67185. getPose(): VRPose;
  67186. /**
  67187. * Return the current instantaneous pose of the VRDisplay, with no
  67188. * prediction applied.
  67189. * @returns the current instantaneous pose
  67190. */
  67191. getImmediatePose(): VRPose;
  67192. /**
  67193. * The callback passed to `requestAnimationFrame` will be called
  67194. * any time a new frame should be rendered. When the VRDisplay is
  67195. * presenting the callback will be called at the native refresh
  67196. * rate of the HMD. When not presenting this function acts
  67197. * identically to how window.requestAnimationFrame acts. Content should
  67198. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67199. * asynchronously from other displays and at differing refresh rates.
  67200. * @param callback Define the eaction to run next frame
  67201. * @returns the request handle it
  67202. */
  67203. requestAnimationFrame(callback: FrameRequestCallback): number;
  67204. /**
  67205. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67206. * Repeat calls while already presenting will update the VRLayers being displayed.
  67207. * @param layers Define the list of layer to present
  67208. * @returns a promise to know when the request has been fulfilled
  67209. */
  67210. requestPresent(layers: VRLayer[]): Promise<void>;
  67211. /**
  67212. * Reset the pose for this display, treating its current position and
  67213. * orientation as the "origin/zero" values. VRPose.position,
  67214. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67215. * updated when calling resetPose(). This should be called in only
  67216. * sitting-space experiences.
  67217. */
  67218. resetPose(): void;
  67219. /**
  67220. * The VRLayer provided to the VRDisplay will be captured and presented
  67221. * in the HMD. Calling this function has the same effect on the source
  67222. * canvas as any other operation that uses its source image, and canvases
  67223. * created without preserveDrawingBuffer set to true will be cleared.
  67224. * @param pose Define the pose to submit
  67225. */
  67226. submitFrame(pose?: VRPose): void;
  67227. }
  67228. declare var VRDisplay: {
  67229. prototype: VRDisplay;
  67230. new(): VRDisplay;
  67231. };
  67232. interface VRLayer {
  67233. leftBounds?: number[] | Float32Array | null;
  67234. rightBounds?: number[] | Float32Array | null;
  67235. source?: HTMLCanvasElement | null;
  67236. }
  67237. interface VRDisplayCapabilities {
  67238. readonly canPresent: boolean;
  67239. readonly hasExternalDisplay: boolean;
  67240. readonly hasOrientation: boolean;
  67241. readonly hasPosition: boolean;
  67242. readonly maxLayers: number;
  67243. }
  67244. interface VREyeParameters {
  67245. /** @deprecated */
  67246. readonly fieldOfView: VRFieldOfView;
  67247. readonly offset: Float32Array;
  67248. readonly renderHeight: number;
  67249. readonly renderWidth: number;
  67250. }
  67251. interface VRFieldOfView {
  67252. readonly downDegrees: number;
  67253. readonly leftDegrees: number;
  67254. readonly rightDegrees: number;
  67255. readonly upDegrees: number;
  67256. }
  67257. interface VRFrameData {
  67258. readonly leftProjectionMatrix: Float32Array;
  67259. readonly leftViewMatrix: Float32Array;
  67260. readonly pose: VRPose;
  67261. readonly rightProjectionMatrix: Float32Array;
  67262. readonly rightViewMatrix: Float32Array;
  67263. readonly timestamp: number;
  67264. }
  67265. interface VRPose {
  67266. readonly angularAcceleration: Float32Array | null;
  67267. readonly angularVelocity: Float32Array | null;
  67268. readonly linearAcceleration: Float32Array | null;
  67269. readonly linearVelocity: Float32Array | null;
  67270. readonly orientation: Float32Array | null;
  67271. readonly position: Float32Array | null;
  67272. readonly timestamp: number;
  67273. }
  67274. interface VRStageParameters {
  67275. sittingToStandingTransform?: Float32Array;
  67276. sizeX?: number;
  67277. sizeY?: number;
  67278. }
  67279. interface Navigator {
  67280. getVRDisplays(): Promise<VRDisplay[]>;
  67281. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67282. }
  67283. interface Window {
  67284. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67285. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67286. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67287. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67288. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67289. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67290. }
  67291. interface Gamepad {
  67292. readonly displayId: number;
  67293. }
  67294. type XRSessionMode =
  67295. | "inline"
  67296. | "immersive-vr"
  67297. | "immersive-ar";
  67298. type XRReferenceSpaceType =
  67299. | "viewer"
  67300. | "local"
  67301. | "local-floor"
  67302. | "bounded-floor"
  67303. | "unbounded";
  67304. type XREnvironmentBlendMode =
  67305. | "opaque"
  67306. | "additive"
  67307. | "alpha-blend";
  67308. type XRVisibilityState =
  67309. | "visible"
  67310. | "visible-blurred"
  67311. | "hidden";
  67312. type XRHandedness =
  67313. | "none"
  67314. | "left"
  67315. | "right";
  67316. type XRTargetRayMode =
  67317. | "gaze"
  67318. | "tracked-pointer"
  67319. | "screen";
  67320. type XREye =
  67321. | "none"
  67322. | "left"
  67323. | "right";
  67324. interface XRSpace extends EventTarget {
  67325. }
  67326. interface XRRenderState {
  67327. depthNear?: number;
  67328. depthFar?: number;
  67329. inlineVerticalFieldOfView?: number;
  67330. baseLayer?: XRWebGLLayer;
  67331. }
  67332. interface XRInputSource {
  67333. handedness: XRHandedness;
  67334. targetRayMode: XRTargetRayMode;
  67335. targetRaySpace: XRSpace;
  67336. gripSpace: XRSpace | undefined;
  67337. gamepad: Gamepad | undefined;
  67338. profiles: Array<string>;
  67339. }
  67340. interface XRSession extends XRAnchorCreator {
  67341. addEventListener: Function;
  67342. removeEventListener: Function;
  67343. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67344. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67345. requestAnimationFrame: Function;
  67346. end(): Promise<void>;
  67347. renderState: XRRenderState;
  67348. inputSources: Array<XRInputSource>;
  67349. // AR hit test
  67350. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67351. updateWorldTrackingState(options: {
  67352. planeDetectionState?: { enabled: boolean; }
  67353. }): void;
  67354. }
  67355. interface XRReferenceSpace extends XRSpace {
  67356. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67357. onreset: any;
  67358. }
  67359. type XRPlaneSet = Set<XRPlane>;
  67360. type XRAnchorSet = Set<XRAnchor>;
  67361. interface XRFrame {
  67362. session: XRSession;
  67363. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67364. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67365. // Anchors
  67366. trackedAnchors?: XRAnchorSet;
  67367. // Planes
  67368. worldInformation: {
  67369. detectedPlanes?: XRPlaneSet;
  67370. };
  67371. }
  67372. interface XRViewerPose extends XRPose {
  67373. views: Array<XRView>;
  67374. }
  67375. interface XRPose {
  67376. transform: XRRigidTransform;
  67377. emulatedPosition: boolean;
  67378. }
  67379. interface XRWebGLLayerOptions {
  67380. antialias?: boolean;
  67381. depth?: boolean;
  67382. stencil?: boolean;
  67383. alpha?: boolean;
  67384. multiview?: boolean;
  67385. framebufferScaleFactor?: number;
  67386. }
  67387. declare var XRWebGLLayer: {
  67388. prototype: XRWebGLLayer;
  67389. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67390. };
  67391. interface XRWebGLLayer {
  67392. framebuffer: WebGLFramebuffer;
  67393. framebufferWidth: number;
  67394. framebufferHeight: number;
  67395. getViewport: Function;
  67396. }
  67397. declare class XRRigidTransform {
  67398. constructor(matrix: Float32Array);
  67399. position: DOMPointReadOnly;
  67400. orientation: DOMPointReadOnly;
  67401. matrix: Float32Array;
  67402. inverse: XRRigidTransform;
  67403. }
  67404. interface XRView {
  67405. eye: XREye;
  67406. projectionMatrix: Float32Array;
  67407. transform: XRRigidTransform;
  67408. }
  67409. interface XRInputSourceChangeEvent {
  67410. session: XRSession;
  67411. removed: Array<XRInputSource>;
  67412. added: Array<XRInputSource>;
  67413. }
  67414. interface XRInputSourceEvent extends Event {
  67415. readonly frame: XRFrame;
  67416. readonly inputSource: XRInputSource;
  67417. }
  67418. // Experimental(er) features
  67419. declare class XRRay {
  67420. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  67421. origin: DOMPointReadOnly;
  67422. direction: DOMPointReadOnly;
  67423. matrix: Float32Array;
  67424. }
  67425. interface XRHitResult {
  67426. hitMatrix: Float32Array;
  67427. }
  67428. interface XRAnchor {
  67429. // remove?
  67430. id?: string;
  67431. anchorSpace: XRSpace;
  67432. lastChangedTime: number;
  67433. detach(): void;
  67434. }
  67435. interface XRPlane extends XRAnchorCreator {
  67436. orientation: "Horizontal" | "Vertical";
  67437. planeSpace: XRSpace;
  67438. polygon: Array<DOMPointReadOnly>;
  67439. lastChangedTime: number;
  67440. }
  67441. interface XRAnchorCreator {
  67442. // AR Anchors
  67443. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67444. }
  67445. /**
  67446. * @ignore
  67447. */
  67448. declare module BABYLON.GLTF2.Exporter {
  67449. }
  67450. /**
  67451. * @ignore
  67452. */
  67453. declare module BABYLON.GLTF1 {
  67454. }
  67455. declare module BABYLON.GUI {
  67456. /**
  67457. * Class used to specific a value and its associated unit
  67458. */
  67459. export class ValueAndUnit {
  67460. /** defines the unit to store */
  67461. unit: number;
  67462. /** defines a boolean indicating if the value can be negative */
  67463. negativeValueAllowed: boolean;
  67464. private _value;
  67465. private _originalUnit;
  67466. /**
  67467. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  67468. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67469. */
  67470. ignoreAdaptiveScaling: boolean;
  67471. /**
  67472. * Creates a new ValueAndUnit
  67473. * @param value defines the value to store
  67474. * @param unit defines the unit to store
  67475. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  67476. */
  67477. constructor(value: number,
  67478. /** defines the unit to store */
  67479. unit?: number,
  67480. /** defines a boolean indicating if the value can be negative */
  67481. negativeValueAllowed?: boolean);
  67482. /** Gets a boolean indicating if the value is a percentage */
  67483. get isPercentage(): boolean;
  67484. /** Gets a boolean indicating if the value is store as pixel */
  67485. get isPixel(): boolean;
  67486. /** Gets direct internal value */
  67487. get internalValue(): number;
  67488. /**
  67489. * Gets value as pixel
  67490. * @param host defines the root host
  67491. * @param refValue defines the reference value for percentages
  67492. * @returns the value as pixel
  67493. */
  67494. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  67495. /**
  67496. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  67497. * @param value defines the value to store
  67498. * @param unit defines the unit to store
  67499. * @returns the current ValueAndUnit
  67500. */
  67501. updateInPlace(value: number, unit?: number): ValueAndUnit;
  67502. /**
  67503. * Gets the value accordingly to its unit
  67504. * @param host defines the root host
  67505. * @returns the value
  67506. */
  67507. getValue(host: AdvancedDynamicTexture): number;
  67508. /**
  67509. * Gets a string representation of the value
  67510. * @param host defines the root host
  67511. * @param decimals defines an optional number of decimals to display
  67512. * @returns a string
  67513. */
  67514. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  67515. /**
  67516. * Store a value parsed from a string
  67517. * @param source defines the source string
  67518. * @returns true if the value was successfully parsed
  67519. */
  67520. fromString(source: string | number): boolean;
  67521. private static _Regex;
  67522. private static _UNITMODE_PERCENTAGE;
  67523. private static _UNITMODE_PIXEL;
  67524. /** UNITMODE_PERCENTAGE */
  67525. static get UNITMODE_PERCENTAGE(): number;
  67526. /** UNITMODE_PIXEL */
  67527. static get UNITMODE_PIXEL(): number;
  67528. }
  67529. }
  67530. declare module BABYLON.GUI {
  67531. /**
  67532. * Define a style used by control to automatically setup properties based on a template.
  67533. * Only support font related properties so far
  67534. */
  67535. export class Style implements BABYLON.IDisposable {
  67536. private _fontFamily;
  67537. private _fontStyle;
  67538. private _fontWeight;
  67539. /** @hidden */
  67540. _host: AdvancedDynamicTexture;
  67541. /** @hidden */
  67542. _fontSize: ValueAndUnit;
  67543. /**
  67544. * BABYLON.Observable raised when the style values are changed
  67545. */
  67546. onChangedObservable: BABYLON.Observable<Style>;
  67547. /**
  67548. * Creates a new style object
  67549. * @param host defines the AdvancedDynamicTexture which hosts this style
  67550. */
  67551. constructor(host: AdvancedDynamicTexture);
  67552. /**
  67553. * Gets or sets the font size
  67554. */
  67555. get fontSize(): string | number;
  67556. set fontSize(value: string | number);
  67557. /**
  67558. * Gets or sets the font family
  67559. */
  67560. get fontFamily(): string;
  67561. set fontFamily(value: string);
  67562. /**
  67563. * Gets or sets the font style
  67564. */
  67565. get fontStyle(): string;
  67566. set fontStyle(value: string);
  67567. /** Gets or sets font weight */
  67568. get fontWeight(): string;
  67569. set fontWeight(value: string);
  67570. /** Dispose all associated resources */
  67571. dispose(): void;
  67572. }
  67573. }
  67574. declare module BABYLON.GUI {
  67575. /**
  67576. * Class used to transport BABYLON.Vector2 information for pointer events
  67577. */
  67578. export class Vector2WithInfo extends BABYLON.Vector2 {
  67579. /** defines the current mouse button index */
  67580. buttonIndex: number;
  67581. /**
  67582. * Creates a new Vector2WithInfo
  67583. * @param source defines the vector2 data to transport
  67584. * @param buttonIndex defines the current mouse button index
  67585. */
  67586. constructor(source: BABYLON.Vector2,
  67587. /** defines the current mouse button index */
  67588. buttonIndex?: number);
  67589. }
  67590. /** Class used to provide 2D matrix features */
  67591. export class Matrix2D {
  67592. /** Gets the internal array of 6 floats used to store matrix data */
  67593. m: Float32Array;
  67594. /**
  67595. * Creates a new matrix
  67596. * @param m00 defines value for (0, 0)
  67597. * @param m01 defines value for (0, 1)
  67598. * @param m10 defines value for (1, 0)
  67599. * @param m11 defines value for (1, 1)
  67600. * @param m20 defines value for (2, 0)
  67601. * @param m21 defines value for (2, 1)
  67602. */
  67603. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  67604. /**
  67605. * Fills the matrix from direct values
  67606. * @param m00 defines value for (0, 0)
  67607. * @param m01 defines value for (0, 1)
  67608. * @param m10 defines value for (1, 0)
  67609. * @param m11 defines value for (1, 1)
  67610. * @param m20 defines value for (2, 0)
  67611. * @param m21 defines value for (2, 1)
  67612. * @returns the current modified matrix
  67613. */
  67614. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  67615. /**
  67616. * Gets matrix determinant
  67617. * @returns the determinant
  67618. */
  67619. determinant(): number;
  67620. /**
  67621. * Inverses the matrix and stores it in a target matrix
  67622. * @param result defines the target matrix
  67623. * @returns the current matrix
  67624. */
  67625. invertToRef(result: Matrix2D): Matrix2D;
  67626. /**
  67627. * Multiplies the current matrix with another one
  67628. * @param other defines the second operand
  67629. * @param result defines the target matrix
  67630. * @returns the current matrix
  67631. */
  67632. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67633. /**
  67634. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67635. * @param x defines the x coordinate to transform
  67636. * @param y defines the x coordinate to transform
  67637. * @param result defines the target vector2
  67638. * @returns the current matrix
  67639. */
  67640. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67641. /**
  67642. * Creates an identity matrix
  67643. * @returns a new matrix
  67644. */
  67645. static Identity(): Matrix2D;
  67646. /**
  67647. * Creates a translation matrix and stores it in a target matrix
  67648. * @param x defines the x coordinate of the translation
  67649. * @param y defines the y coordinate of the translation
  67650. * @param result defines the target matrix
  67651. */
  67652. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67653. /**
  67654. * Creates a scaling matrix and stores it in a target matrix
  67655. * @param x defines the x coordinate of the scaling
  67656. * @param y defines the y coordinate of the scaling
  67657. * @param result defines the target matrix
  67658. */
  67659. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67660. /**
  67661. * Creates a rotation matrix and stores it in a target matrix
  67662. * @param angle defines the rotation angle
  67663. * @param result defines the target matrix
  67664. */
  67665. static RotationToRef(angle: number, result: Matrix2D): void;
  67666. private static _TempPreTranslationMatrix;
  67667. private static _TempPostTranslationMatrix;
  67668. private static _TempRotationMatrix;
  67669. private static _TempScalingMatrix;
  67670. private static _TempCompose0;
  67671. private static _TempCompose1;
  67672. private static _TempCompose2;
  67673. /**
  67674. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67675. * @param tx defines the x coordinate of the translation
  67676. * @param ty defines the y coordinate of the translation
  67677. * @param angle defines the rotation angle
  67678. * @param scaleX defines the x coordinate of the scaling
  67679. * @param scaleY defines the y coordinate of the scaling
  67680. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67681. * @param result defines the target matrix
  67682. */
  67683. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67684. }
  67685. }
  67686. declare module BABYLON.GUI {
  67687. /**
  67688. * Class used to store 2D control sizes
  67689. */
  67690. export class Measure {
  67691. /** defines left coordinate */
  67692. left: number;
  67693. /** defines top coordinate */
  67694. top: number;
  67695. /** defines width dimension */
  67696. width: number;
  67697. /** defines height dimension */
  67698. height: number;
  67699. /**
  67700. * Creates a new measure
  67701. * @param left defines left coordinate
  67702. * @param top defines top coordinate
  67703. * @param width defines width dimension
  67704. * @param height defines height dimension
  67705. */
  67706. constructor(
  67707. /** defines left coordinate */
  67708. left: number,
  67709. /** defines top coordinate */
  67710. top: number,
  67711. /** defines width dimension */
  67712. width: number,
  67713. /** defines height dimension */
  67714. height: number);
  67715. /**
  67716. * Copy from another measure
  67717. * @param other defines the other measure to copy from
  67718. */
  67719. copyFrom(other: Measure): void;
  67720. /**
  67721. * Copy from a group of 4 floats
  67722. * @param left defines left coordinate
  67723. * @param top defines top coordinate
  67724. * @param width defines width dimension
  67725. * @param height defines height dimension
  67726. */
  67727. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67728. /**
  67729. * Computes the axis aligned bounding box measure for two given measures
  67730. * @param a Input measure
  67731. * @param b Input measure
  67732. * @param result the resulting bounding measure
  67733. */
  67734. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67735. /**
  67736. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67737. * @param transform the matrix to transform the measure before computing the AABB
  67738. * @param result the resulting AABB
  67739. */
  67740. transformToRef(transform: Matrix2D, result: Measure): void;
  67741. /**
  67742. * Check equality between this measure and another one
  67743. * @param other defines the other measures
  67744. * @returns true if both measures are equals
  67745. */
  67746. isEqualsTo(other: Measure): boolean;
  67747. /**
  67748. * Creates an empty measure
  67749. * @returns a new measure
  67750. */
  67751. static Empty(): Measure;
  67752. }
  67753. }
  67754. declare module BABYLON.GUI {
  67755. /**
  67756. * Interface used to define a control that can receive focus
  67757. */
  67758. export interface IFocusableControl {
  67759. /**
  67760. * Function called when the control receives the focus
  67761. */
  67762. onFocus(): void;
  67763. /**
  67764. * Function called when the control loses the focus
  67765. */
  67766. onBlur(): void;
  67767. /**
  67768. * Function called to let the control handle keyboard events
  67769. * @param evt defines the current keyboard event
  67770. */
  67771. processKeyboard(evt: KeyboardEvent): void;
  67772. /**
  67773. * Function called to get the list of controls that should not steal the focus from this control
  67774. * @returns an array of controls
  67775. */
  67776. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67777. }
  67778. /**
  67779. * Class used to create texture to support 2D GUI elements
  67780. * @see http://doc.babylonjs.com/how_to/gui
  67781. */
  67782. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67783. private _isDirty;
  67784. private _renderObserver;
  67785. private _resizeObserver;
  67786. private _preKeyboardObserver;
  67787. private _pointerMoveObserver;
  67788. private _pointerObserver;
  67789. private _canvasPointerOutObserver;
  67790. private _background;
  67791. /** @hidden */
  67792. _rootContainer: Container;
  67793. /** @hidden */
  67794. _lastPickedControl: Control;
  67795. /** @hidden */
  67796. _lastControlOver: {
  67797. [pointerId: number]: Control;
  67798. };
  67799. /** @hidden */
  67800. _lastControlDown: {
  67801. [pointerId: number]: Control;
  67802. };
  67803. /** @hidden */
  67804. _capturingControl: {
  67805. [pointerId: number]: Control;
  67806. };
  67807. /** @hidden */
  67808. _shouldBlockPointer: boolean;
  67809. /** @hidden */
  67810. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67811. /** @hidden */
  67812. _linkedControls: Control[];
  67813. private _isFullscreen;
  67814. private _fullscreenViewport;
  67815. private _idealWidth;
  67816. private _idealHeight;
  67817. private _useSmallestIdeal;
  67818. private _renderAtIdealSize;
  67819. private _focusedControl;
  67820. private _blockNextFocusCheck;
  67821. private _renderScale;
  67822. private _rootElement;
  67823. private _cursorChanged;
  67824. /**
  67825. * Define type to string to ensure compatibility across browsers
  67826. * Safari doesn't support DataTransfer constructor
  67827. */
  67828. private _clipboardData;
  67829. /**
  67830. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67831. */
  67832. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67833. /**
  67834. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67835. */
  67836. onControlPickedObservable: BABYLON.Observable<Control>;
  67837. /**
  67838. * BABYLON.Observable event triggered before layout is evaluated
  67839. */
  67840. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67841. /**
  67842. * BABYLON.Observable event triggered after the layout was evaluated
  67843. */
  67844. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67845. /**
  67846. * BABYLON.Observable event triggered before the texture is rendered
  67847. */
  67848. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67849. /**
  67850. * BABYLON.Observable event triggered after the texture was rendered
  67851. */
  67852. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67853. /**
  67854. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67855. */
  67856. premulAlpha: boolean;
  67857. /**
  67858. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67859. * Useful when you want more antialiasing
  67860. */
  67861. get renderScale(): number;
  67862. set renderScale(value: number);
  67863. /** Gets or sets the background color */
  67864. get background(): string;
  67865. set background(value: string);
  67866. /**
  67867. * Gets or sets the ideal width used to design controls.
  67868. * The GUI will then rescale everything accordingly
  67869. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67870. */
  67871. get idealWidth(): number;
  67872. set idealWidth(value: number);
  67873. /**
  67874. * Gets or sets the ideal height used to design controls.
  67875. * The GUI will then rescale everything accordingly
  67876. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67877. */
  67878. get idealHeight(): number;
  67879. set idealHeight(value: number);
  67880. /**
  67881. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67882. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67883. */
  67884. get useSmallestIdeal(): boolean;
  67885. set useSmallestIdeal(value: boolean);
  67886. /**
  67887. * Gets or sets a boolean indicating if adaptive scaling must be used
  67888. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67889. */
  67890. get renderAtIdealSize(): boolean;
  67891. set renderAtIdealSize(value: boolean);
  67892. /**
  67893. * Gets the underlying layer used to render the texture when in fullscreen mode
  67894. */
  67895. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  67896. /**
  67897. * Gets the root container control
  67898. */
  67899. get rootContainer(): Container;
  67900. /**
  67901. * Returns an array containing the root container.
  67902. * This is mostly used to let the Inspector introspects the ADT
  67903. * @returns an array containing the rootContainer
  67904. */
  67905. getChildren(): Array<Container>;
  67906. /**
  67907. * Will return all controls that are inside this texture
  67908. * @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
  67909. * @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
  67910. * @return all child controls
  67911. */
  67912. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67913. /**
  67914. * Gets or sets the current focused control
  67915. */
  67916. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  67917. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  67918. /**
  67919. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67920. */
  67921. get isForeground(): boolean;
  67922. set isForeground(value: boolean);
  67923. /**
  67924. * Gets or set information about clipboardData
  67925. */
  67926. get clipboardData(): string;
  67927. set clipboardData(value: string);
  67928. /**
  67929. * Creates a new AdvancedDynamicTexture
  67930. * @param name defines the name of the texture
  67931. * @param width defines the width of the texture
  67932. * @param height defines the height of the texture
  67933. * @param scene defines the hosting scene
  67934. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67935. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67936. */
  67937. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67938. /**
  67939. * Get the current class name of the texture useful for serialization or dynamic coding.
  67940. * @returns "AdvancedDynamicTexture"
  67941. */
  67942. getClassName(): string;
  67943. /**
  67944. * Function used to execute a function on all controls
  67945. * @param func defines the function to execute
  67946. * @param container defines the container where controls belong. If null the root container will be used
  67947. */
  67948. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  67949. private _useInvalidateRectOptimization;
  67950. /**
  67951. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  67952. */
  67953. get useInvalidateRectOptimization(): boolean;
  67954. set useInvalidateRectOptimization(value: boolean);
  67955. private _invalidatedRectangle;
  67956. /**
  67957. * Invalidates a rectangle area on the gui texture
  67958. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  67959. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  67960. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  67961. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  67962. */
  67963. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  67964. /**
  67965. * Marks the texture as dirty forcing a complete update
  67966. */
  67967. markAsDirty(): void;
  67968. /**
  67969. * Helper function used to create a new style
  67970. * @returns a new style
  67971. * @see http://doc.babylonjs.com/how_to/gui#styles
  67972. */
  67973. createStyle(): Style;
  67974. /**
  67975. * Adds a new control to the root container
  67976. * @param control defines the control to add
  67977. * @returns the current texture
  67978. */
  67979. addControl(control: Control): AdvancedDynamicTexture;
  67980. /**
  67981. * Removes a control from the root container
  67982. * @param control defines the control to remove
  67983. * @returns the current texture
  67984. */
  67985. removeControl(control: Control): AdvancedDynamicTexture;
  67986. /**
  67987. * Release all resources
  67988. */
  67989. dispose(): void;
  67990. private _onResize;
  67991. /** @hidden */
  67992. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  67993. /**
  67994. * Get screen coordinates for a vector3
  67995. * @param position defines the position to project
  67996. * @param worldMatrix defines the world matrix to use
  67997. * @returns the projected position
  67998. */
  67999. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  68000. private _checkUpdate;
  68001. private _clearMeasure;
  68002. private _render;
  68003. /** @hidden */
  68004. _changeCursor(cursor: string): void;
  68005. /** @hidden */
  68006. _registerLastControlDown(control: Control, pointerId: number): void;
  68007. private _doPicking;
  68008. /** @hidden */
  68009. _cleanControlAfterRemovalFromList(list: {
  68010. [pointerId: number]: Control;
  68011. }, control: Control): void;
  68012. /** @hidden */
  68013. _cleanControlAfterRemoval(control: Control): void;
  68014. /** Attach to all scene events required to support pointer events */
  68015. attach(): void;
  68016. /** @hidden */
  68017. private onClipboardCopy;
  68018. /** @hidden */
  68019. private onClipboardCut;
  68020. /** @hidden */
  68021. private onClipboardPaste;
  68022. /**
  68023. * Register the clipboard Events onto the canvas
  68024. */
  68025. registerClipboardEvents(): void;
  68026. /**
  68027. * Unregister the clipboard Events from the canvas
  68028. */
  68029. unRegisterClipboardEvents(): void;
  68030. /**
  68031. * Connect the texture to a hosting mesh to enable interactions
  68032. * @param mesh defines the mesh to attach to
  68033. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68034. */
  68035. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68036. /**
  68037. * Move the focus to a specific control
  68038. * @param control defines the control which will receive the focus
  68039. */
  68040. moveFocusToControl(control: IFocusableControl): void;
  68041. private _manageFocus;
  68042. private _attachToOnPointerOut;
  68043. /**
  68044. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68045. * @param mesh defines the mesh which will receive the texture
  68046. * @param width defines the texture width (1024 by default)
  68047. * @param height defines the texture height (1024 by default)
  68048. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68049. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68050. * @returns a new AdvancedDynamicTexture
  68051. */
  68052. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68053. /**
  68054. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68055. * In this mode the texture will rely on a layer for its rendering.
  68056. * This allows it to be treated like any other layer.
  68057. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68058. * LayerMask is set through advancedTexture.layer.layerMask
  68059. * @param name defines name for the texture
  68060. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68061. * @param scene defines the hsoting scene
  68062. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68063. * @returns a new AdvancedDynamicTexture
  68064. */
  68065. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68066. }
  68067. }
  68068. declare module BABYLON.GUI {
  68069. /**
  68070. * Root class used for all 2D controls
  68071. * @see http://doc.babylonjs.com/how_to/gui#controls
  68072. */
  68073. export class Control {
  68074. /** defines the name of the control */
  68075. name?: string | undefined;
  68076. /**
  68077. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68078. */
  68079. static AllowAlphaInheritance: boolean;
  68080. private _alpha;
  68081. private _alphaSet;
  68082. private _zIndex;
  68083. /** @hidden */
  68084. _host: AdvancedDynamicTexture;
  68085. /** Gets or sets the control parent */
  68086. parent: BABYLON.Nullable<Container>;
  68087. /** @hidden */
  68088. _currentMeasure: Measure;
  68089. private _fontFamily;
  68090. private _fontStyle;
  68091. private _fontWeight;
  68092. private _fontSize;
  68093. private _font;
  68094. /** @hidden */
  68095. _width: ValueAndUnit;
  68096. /** @hidden */
  68097. _height: ValueAndUnit;
  68098. /** @hidden */
  68099. protected _fontOffset: {
  68100. ascent: number;
  68101. height: number;
  68102. descent: number;
  68103. };
  68104. private _color;
  68105. private _style;
  68106. private _styleObserver;
  68107. /** @hidden */
  68108. protected _horizontalAlignment: number;
  68109. /** @hidden */
  68110. protected _verticalAlignment: number;
  68111. /** @hidden */
  68112. protected _isDirty: boolean;
  68113. /** @hidden */
  68114. protected _wasDirty: boolean;
  68115. /** @hidden */
  68116. _tempParentMeasure: Measure;
  68117. /** @hidden */
  68118. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68119. /** @hidden */
  68120. protected _cachedParentMeasure: Measure;
  68121. private _paddingLeft;
  68122. private _paddingRight;
  68123. private _paddingTop;
  68124. private _paddingBottom;
  68125. /** @hidden */
  68126. _left: ValueAndUnit;
  68127. /** @hidden */
  68128. _top: ValueAndUnit;
  68129. private _scaleX;
  68130. private _scaleY;
  68131. private _rotation;
  68132. private _transformCenterX;
  68133. private _transformCenterY;
  68134. /** @hidden */
  68135. _transformMatrix: Matrix2D;
  68136. /** @hidden */
  68137. protected _invertTransformMatrix: Matrix2D;
  68138. /** @hidden */
  68139. protected _transformedPosition: BABYLON.Vector2;
  68140. private _isMatrixDirty;
  68141. private _cachedOffsetX;
  68142. private _cachedOffsetY;
  68143. private _isVisible;
  68144. private _isHighlighted;
  68145. /** @hidden */
  68146. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68147. private _fontSet;
  68148. private _dummyVector2;
  68149. private _downCount;
  68150. private _enterCount;
  68151. private _doNotRender;
  68152. private _downPointerIds;
  68153. protected _isEnabled: boolean;
  68154. protected _disabledColor: string;
  68155. /** @hidden */
  68156. protected _rebuildLayout: boolean;
  68157. /** @hidden */
  68158. _isClipped: boolean;
  68159. /** @hidden */
  68160. _automaticSize: boolean;
  68161. /** @hidden */
  68162. _tag: any;
  68163. /**
  68164. * 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
  68165. */
  68166. uniqueId: number;
  68167. /**
  68168. * Gets or sets an object used to store user defined information for the node
  68169. */
  68170. metadata: any;
  68171. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68172. isHitTestVisible: boolean;
  68173. /** Gets or sets a boolean indicating if the control can block pointer events */
  68174. isPointerBlocker: boolean;
  68175. /** Gets or sets a boolean indicating if the control can be focusable */
  68176. isFocusInvisible: boolean;
  68177. /**
  68178. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  68179. * 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
  68180. */
  68181. clipChildren: boolean;
  68182. /**
  68183. * Gets or sets a boolean indicating that control content must be clipped
  68184. * 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
  68185. */
  68186. clipContent: boolean;
  68187. /**
  68188. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68189. */
  68190. useBitmapCache: boolean;
  68191. private _cacheData;
  68192. private _shadowOffsetX;
  68193. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68194. get shadowOffsetX(): number;
  68195. set shadowOffsetX(value: number);
  68196. private _shadowOffsetY;
  68197. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68198. get shadowOffsetY(): number;
  68199. set shadowOffsetY(value: number);
  68200. private _shadowBlur;
  68201. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68202. get shadowBlur(): number;
  68203. set shadowBlur(value: number);
  68204. private _shadowColor;
  68205. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68206. get shadowColor(): string;
  68207. set shadowColor(value: string);
  68208. /** Gets or sets the cursor to use when the control is hovered */
  68209. hoverCursor: string;
  68210. /** @hidden */
  68211. protected _linkOffsetX: ValueAndUnit;
  68212. /** @hidden */
  68213. protected _linkOffsetY: ValueAndUnit;
  68214. /** Gets the control type name */
  68215. get typeName(): string;
  68216. /**
  68217. * Get the current class name of the control.
  68218. * @returns current class name
  68219. */
  68220. getClassName(): string;
  68221. /**
  68222. * An event triggered when the pointer move over the control.
  68223. */
  68224. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68225. /**
  68226. * An event triggered when the pointer move out of the control.
  68227. */
  68228. onPointerOutObservable: BABYLON.Observable<Control>;
  68229. /**
  68230. * An event triggered when the pointer taps the control
  68231. */
  68232. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68233. /**
  68234. * An event triggered when pointer up
  68235. */
  68236. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  68237. /**
  68238. * An event triggered when a control is clicked on
  68239. */
  68240. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  68241. /**
  68242. * An event triggered when pointer enters the control
  68243. */
  68244. onPointerEnterObservable: BABYLON.Observable<Control>;
  68245. /**
  68246. * An event triggered when the control is marked as dirty
  68247. */
  68248. onDirtyObservable: BABYLON.Observable<Control>;
  68249. /**
  68250. * An event triggered before drawing the control
  68251. */
  68252. onBeforeDrawObservable: BABYLON.Observable<Control>;
  68253. /**
  68254. * An event triggered after the control was drawn
  68255. */
  68256. onAfterDrawObservable: BABYLON.Observable<Control>;
  68257. /**
  68258. * Get the hosting AdvancedDynamicTexture
  68259. */
  68260. get host(): AdvancedDynamicTexture;
  68261. /** Gets or set information about font offsets (used to render and align text) */
  68262. get fontOffset(): {
  68263. ascent: number;
  68264. height: number;
  68265. descent: number;
  68266. };
  68267. set fontOffset(offset: {
  68268. ascent: number;
  68269. height: number;
  68270. descent: number;
  68271. });
  68272. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  68273. get alpha(): number;
  68274. set alpha(value: number);
  68275. /**
  68276. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  68277. */
  68278. get isHighlighted(): boolean;
  68279. set isHighlighted(value: boolean);
  68280. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  68281. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68282. */
  68283. get scaleX(): number;
  68284. set scaleX(value: number);
  68285. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  68286. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68287. */
  68288. get scaleY(): number;
  68289. set scaleY(value: number);
  68290. /** Gets or sets the rotation angle (0 by default)
  68291. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68292. */
  68293. get rotation(): number;
  68294. set rotation(value: number);
  68295. /** Gets or sets the transformation center on Y axis (0 by default)
  68296. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68297. */
  68298. get transformCenterY(): number;
  68299. set transformCenterY(value: number);
  68300. /** Gets or sets the transformation center on X axis (0 by default)
  68301. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68302. */
  68303. get transformCenterX(): number;
  68304. set transformCenterX(value: number);
  68305. /**
  68306. * Gets or sets the horizontal alignment
  68307. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68308. */
  68309. get horizontalAlignment(): number;
  68310. set horizontalAlignment(value: number);
  68311. /**
  68312. * Gets or sets the vertical alignment
  68313. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68314. */
  68315. get verticalAlignment(): number;
  68316. set verticalAlignment(value: number);
  68317. /**
  68318. * Gets or sets control width
  68319. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68320. */
  68321. get width(): string | number;
  68322. set width(value: string | number);
  68323. /**
  68324. * Gets or sets the control width in pixel
  68325. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68326. */
  68327. get widthInPixels(): number;
  68328. set widthInPixels(value: number);
  68329. /**
  68330. * Gets or sets control height
  68331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68332. */
  68333. get height(): string | number;
  68334. set height(value: string | number);
  68335. /**
  68336. * Gets or sets control height in pixel
  68337. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68338. */
  68339. get heightInPixels(): number;
  68340. set heightInPixels(value: number);
  68341. /** Gets or set font family */
  68342. get fontFamily(): string;
  68343. set fontFamily(value: string);
  68344. /** Gets or sets font style */
  68345. get fontStyle(): string;
  68346. set fontStyle(value: string);
  68347. /** Gets or sets font weight */
  68348. get fontWeight(): string;
  68349. set fontWeight(value: string);
  68350. /**
  68351. * Gets or sets style
  68352. * @see http://doc.babylonjs.com/how_to/gui#styles
  68353. */
  68354. get style(): BABYLON.Nullable<Style>;
  68355. set style(value: BABYLON.Nullable<Style>);
  68356. /** @hidden */
  68357. get _isFontSizeInPercentage(): boolean;
  68358. /** Gets or sets font size in pixels */
  68359. get fontSizeInPixels(): number;
  68360. set fontSizeInPixels(value: number);
  68361. /** Gets or sets font size */
  68362. get fontSize(): string | number;
  68363. set fontSize(value: string | number);
  68364. /** Gets or sets foreground color */
  68365. get color(): string;
  68366. set color(value: string);
  68367. /** Gets or sets z index which is used to reorder controls on the z axis */
  68368. get zIndex(): number;
  68369. set zIndex(value: number);
  68370. /** Gets or sets a boolean indicating if the control can be rendered */
  68371. get notRenderable(): boolean;
  68372. set notRenderable(value: boolean);
  68373. /** Gets or sets a boolean indicating if the control is visible */
  68374. get isVisible(): boolean;
  68375. set isVisible(value: boolean);
  68376. /** Gets a boolean indicating that the control needs to update its rendering */
  68377. get isDirty(): boolean;
  68378. /**
  68379. * Gets the current linked mesh (or null if none)
  68380. */
  68381. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  68382. /**
  68383. * Gets or sets a value indicating the padding to use on the left of the control
  68384. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68385. */
  68386. get paddingLeft(): string | number;
  68387. set paddingLeft(value: string | number);
  68388. /**
  68389. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  68390. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68391. */
  68392. get paddingLeftInPixels(): number;
  68393. set paddingLeftInPixels(value: number);
  68394. /**
  68395. * Gets or sets a value indicating the padding to use on the right of the control
  68396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68397. */
  68398. get paddingRight(): string | number;
  68399. set paddingRight(value: string | number);
  68400. /**
  68401. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  68402. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68403. */
  68404. get paddingRightInPixels(): number;
  68405. set paddingRightInPixels(value: number);
  68406. /**
  68407. * Gets or sets a value indicating the padding to use on the top of the control
  68408. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68409. */
  68410. get paddingTop(): string | number;
  68411. set paddingTop(value: string | number);
  68412. /**
  68413. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  68414. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68415. */
  68416. get paddingTopInPixels(): number;
  68417. set paddingTopInPixels(value: number);
  68418. /**
  68419. * Gets or sets a value indicating the padding to use on the bottom of the control
  68420. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68421. */
  68422. get paddingBottom(): string | number;
  68423. set paddingBottom(value: string | number);
  68424. /**
  68425. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  68426. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68427. */
  68428. get paddingBottomInPixels(): number;
  68429. set paddingBottomInPixels(value: number);
  68430. /**
  68431. * Gets or sets a value indicating the left coordinate of the control
  68432. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68433. */
  68434. get left(): string | number;
  68435. set left(value: string | number);
  68436. /**
  68437. * Gets or sets a value indicating the left coordinate in pixels of the control
  68438. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68439. */
  68440. get leftInPixels(): number;
  68441. set leftInPixels(value: number);
  68442. /**
  68443. * Gets or sets a value indicating the top coordinate of the control
  68444. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68445. */
  68446. get top(): string | number;
  68447. set top(value: string | number);
  68448. /**
  68449. * Gets or sets a value indicating the top coordinate in pixels of the control
  68450. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68451. */
  68452. get topInPixels(): number;
  68453. set topInPixels(value: number);
  68454. /**
  68455. * Gets or sets a value indicating the offset on X axis to the linked mesh
  68456. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68457. */
  68458. get linkOffsetX(): string | number;
  68459. set linkOffsetX(value: string | number);
  68460. /**
  68461. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  68462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68463. */
  68464. get linkOffsetXInPixels(): number;
  68465. set linkOffsetXInPixels(value: number);
  68466. /**
  68467. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  68468. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68469. */
  68470. get linkOffsetY(): string | number;
  68471. set linkOffsetY(value: string | number);
  68472. /**
  68473. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  68474. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68475. */
  68476. get linkOffsetYInPixels(): number;
  68477. set linkOffsetYInPixels(value: number);
  68478. /** Gets the center coordinate on X axis */
  68479. get centerX(): number;
  68480. /** Gets the center coordinate on Y axis */
  68481. get centerY(): number;
  68482. /** Gets or sets if control is Enabled*/
  68483. get isEnabled(): boolean;
  68484. set isEnabled(value: boolean);
  68485. /** Gets or sets background color of control if it's disabled*/
  68486. get disabledColor(): string;
  68487. set disabledColor(value: string);
  68488. /**
  68489. * Creates a new control
  68490. * @param name defines the name of the control
  68491. */
  68492. constructor(
  68493. /** defines the name of the control */
  68494. name?: string | undefined);
  68495. /** @hidden */
  68496. protected _getTypeName(): string;
  68497. /**
  68498. * Gets the first ascendant in the hierarchy of the given type
  68499. * @param className defines the required type
  68500. * @returns the ascendant or null if not found
  68501. */
  68502. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  68503. /** @hidden */
  68504. _resetFontCache(): void;
  68505. /**
  68506. * Determines if a container is an ascendant of the current control
  68507. * @param container defines the container to look for
  68508. * @returns true if the container is one of the ascendant of the control
  68509. */
  68510. isAscendant(container: Control): boolean;
  68511. /**
  68512. * Gets coordinates in local control space
  68513. * @param globalCoordinates defines the coordinates to transform
  68514. * @returns the new coordinates in local space
  68515. */
  68516. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68517. /**
  68518. * Gets coordinates in local control space
  68519. * @param globalCoordinates defines the coordinates to transform
  68520. * @param result defines the target vector2 where to store the result
  68521. * @returns the current control
  68522. */
  68523. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  68524. /**
  68525. * Gets coordinates in parent local control space
  68526. * @param globalCoordinates defines the coordinates to transform
  68527. * @returns the new coordinates in parent local space
  68528. */
  68529. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68530. /**
  68531. * Move the current control to a vector3 position projected onto the screen.
  68532. * @param position defines the target position
  68533. * @param scene defines the hosting scene
  68534. */
  68535. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  68536. /**
  68537. * Will store all controls that have this control as ascendant in a given array
  68538. * @param results defines the array where to store the descendants
  68539. * @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
  68540. * @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
  68541. */
  68542. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68543. /**
  68544. * Will return all controls that have this control as ascendant
  68545. * @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
  68546. * @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
  68547. * @return all child controls
  68548. */
  68549. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68550. /**
  68551. * Link current control with a target mesh
  68552. * @param mesh defines the mesh to link with
  68553. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68554. */
  68555. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  68556. /** @hidden */
  68557. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  68558. /** @hidden */
  68559. _offsetLeft(offset: number): void;
  68560. /** @hidden */
  68561. _offsetTop(offset: number): void;
  68562. /** @hidden */
  68563. _markMatrixAsDirty(): void;
  68564. /** @hidden */
  68565. _flagDescendantsAsMatrixDirty(): void;
  68566. /** @hidden */
  68567. _intersectsRect(rect: Measure): boolean;
  68568. /** @hidden */
  68569. protected invalidateRect(): void;
  68570. /** @hidden */
  68571. _markAsDirty(force?: boolean): void;
  68572. /** @hidden */
  68573. _markAllAsDirty(): void;
  68574. /** @hidden */
  68575. _link(host: AdvancedDynamicTexture): void;
  68576. /** @hidden */
  68577. protected _transform(context?: CanvasRenderingContext2D): void;
  68578. /** @hidden */
  68579. _renderHighlight(context: CanvasRenderingContext2D): void;
  68580. /** @hidden */
  68581. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68582. /** @hidden */
  68583. protected _applyStates(context: CanvasRenderingContext2D): void;
  68584. /** @hidden */
  68585. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68586. /** @hidden */
  68587. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68588. protected _evaluateClippingState(parentMeasure: Measure): void;
  68589. /** @hidden */
  68590. _measure(): void;
  68591. /** @hidden */
  68592. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68593. /** @hidden */
  68594. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68595. /** @hidden */
  68596. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68597. /** @hidden */
  68598. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68599. private static _ClipMeasure;
  68600. private _tmpMeasureA;
  68601. private _clip;
  68602. /** @hidden */
  68603. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  68604. /** @hidden */
  68605. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68606. /**
  68607. * Tests if a given coordinates belong to the current control
  68608. * @param x defines x coordinate to test
  68609. * @param y defines y coordinate to test
  68610. * @returns true if the coordinates are inside the control
  68611. */
  68612. contains(x: number, y: number): boolean;
  68613. /** @hidden */
  68614. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68615. /** @hidden */
  68616. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68617. /** @hidden */
  68618. _onPointerEnter(target: Control): boolean;
  68619. /** @hidden */
  68620. _onPointerOut(target: Control, force?: boolean): void;
  68621. /** @hidden */
  68622. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68623. /** @hidden */
  68624. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68625. /** @hidden */
  68626. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68627. /** @hidden */
  68628. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  68629. private _prepareFont;
  68630. /** Releases associated resources */
  68631. dispose(): void;
  68632. private static _HORIZONTAL_ALIGNMENT_LEFT;
  68633. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  68634. private static _HORIZONTAL_ALIGNMENT_CENTER;
  68635. private static _VERTICAL_ALIGNMENT_TOP;
  68636. private static _VERTICAL_ALIGNMENT_BOTTOM;
  68637. private static _VERTICAL_ALIGNMENT_CENTER;
  68638. /** HORIZONTAL_ALIGNMENT_LEFT */
  68639. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  68640. /** HORIZONTAL_ALIGNMENT_RIGHT */
  68641. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  68642. /** HORIZONTAL_ALIGNMENT_CENTER */
  68643. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  68644. /** VERTICAL_ALIGNMENT_TOP */
  68645. static get VERTICAL_ALIGNMENT_TOP(): number;
  68646. /** VERTICAL_ALIGNMENT_BOTTOM */
  68647. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  68648. /** VERTICAL_ALIGNMENT_CENTER */
  68649. static get VERTICAL_ALIGNMENT_CENTER(): number;
  68650. private static _FontHeightSizes;
  68651. /** @hidden */
  68652. static _GetFontOffset(font: string): {
  68653. ascent: number;
  68654. height: number;
  68655. descent: number;
  68656. };
  68657. /**
  68658. * Creates a stack panel that can be used to render headers
  68659. * @param control defines the control to associate with the header
  68660. * @param text defines the text of the header
  68661. * @param size defines the size of the header
  68662. * @param options defines options used to configure the header
  68663. * @returns a new StackPanel
  68664. * @ignore
  68665. * @hidden
  68666. */
  68667. static AddHeader: (control: Control, text: string, size: string | number, options: {
  68668. isHorizontal: boolean;
  68669. controlFirst: boolean;
  68670. }) => any;
  68671. /** @hidden */
  68672. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  68673. }
  68674. }
  68675. declare module BABYLON.GUI {
  68676. /**
  68677. * Root class for 2D containers
  68678. * @see http://doc.babylonjs.com/how_to/gui#containers
  68679. */
  68680. export class Container extends Control {
  68681. name?: string | undefined;
  68682. /** @hidden */
  68683. protected _children: Control[];
  68684. /** @hidden */
  68685. protected _measureForChildren: Measure;
  68686. /** @hidden */
  68687. protected _background: string;
  68688. /** @hidden */
  68689. protected _adaptWidthToChildren: boolean;
  68690. /** @hidden */
  68691. protected _adaptHeightToChildren: boolean;
  68692. /**
  68693. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68694. */
  68695. logLayoutCycleErrors: boolean;
  68696. /**
  68697. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68698. */
  68699. maxLayoutCycle: number;
  68700. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68701. get adaptHeightToChildren(): boolean;
  68702. set adaptHeightToChildren(value: boolean);
  68703. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68704. get adaptWidthToChildren(): boolean;
  68705. set adaptWidthToChildren(value: boolean);
  68706. /** Gets or sets background color */
  68707. get background(): string;
  68708. set background(value: string);
  68709. /** Gets the list of children */
  68710. get children(): Control[];
  68711. /**
  68712. * Creates a new Container
  68713. * @param name defines the name of the container
  68714. */
  68715. constructor(name?: string | undefined);
  68716. protected _getTypeName(): string;
  68717. _flagDescendantsAsMatrixDirty(): void;
  68718. /**
  68719. * Gets a child using its name
  68720. * @param name defines the child name to look for
  68721. * @returns the child control if found
  68722. */
  68723. getChildByName(name: string): BABYLON.Nullable<Control>;
  68724. /**
  68725. * Gets a child using its type and its name
  68726. * @param name defines the child name to look for
  68727. * @param type defines the child type to look for
  68728. * @returns the child control if found
  68729. */
  68730. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68731. /**
  68732. * Search for a specific control in children
  68733. * @param control defines the control to look for
  68734. * @returns true if the control is in child list
  68735. */
  68736. containsControl(control: Control): boolean;
  68737. /**
  68738. * Adds a new control to the current container
  68739. * @param control defines the control to add
  68740. * @returns the current container
  68741. */
  68742. addControl(control: BABYLON.Nullable<Control>): Container;
  68743. /**
  68744. * Removes all controls from the current container
  68745. * @returns the current container
  68746. */
  68747. clearControls(): Container;
  68748. /**
  68749. * Removes a control from the current container
  68750. * @param control defines the control to remove
  68751. * @returns the current container
  68752. */
  68753. removeControl(control: Control): Container;
  68754. /** @hidden */
  68755. _reOrderControl(control: Control): void;
  68756. /** @hidden */
  68757. _offsetLeft(offset: number): void;
  68758. /** @hidden */
  68759. _offsetTop(offset: number): void;
  68760. /** @hidden */
  68761. _markAllAsDirty(): void;
  68762. /** @hidden */
  68763. protected _localDraw(context: CanvasRenderingContext2D): void;
  68764. /** @hidden */
  68765. _link(host: AdvancedDynamicTexture): void;
  68766. /** @hidden */
  68767. protected _beforeLayout(): void;
  68768. /** @hidden */
  68769. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68770. /** @hidden */
  68771. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68772. protected _postMeasure(): void;
  68773. /** @hidden */
  68774. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68775. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68776. /** @hidden */
  68777. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68778. /** @hidden */
  68779. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68780. /** Releases associated resources */
  68781. dispose(): void;
  68782. }
  68783. }
  68784. declare module BABYLON.GUI {
  68785. /** Class used to create rectangle container */
  68786. export class Rectangle extends Container {
  68787. name?: string | undefined;
  68788. private _thickness;
  68789. private _cornerRadius;
  68790. /** Gets or sets border thickness */
  68791. get thickness(): number;
  68792. set thickness(value: number);
  68793. /** Gets or sets the corner radius angle */
  68794. get cornerRadius(): number;
  68795. set cornerRadius(value: number);
  68796. /**
  68797. * Creates a new Rectangle
  68798. * @param name defines the control name
  68799. */
  68800. constructor(name?: string | undefined);
  68801. protected _getTypeName(): string;
  68802. protected _localDraw(context: CanvasRenderingContext2D): void;
  68803. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68804. private _drawRoundedRect;
  68805. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68806. }
  68807. }
  68808. declare module BABYLON.GUI {
  68809. /**
  68810. * Enum that determines the text-wrapping mode to use.
  68811. */
  68812. export enum TextWrapping {
  68813. /**
  68814. * Clip the text when it's larger than Control.width; this is the default mode.
  68815. */
  68816. Clip = 0,
  68817. /**
  68818. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68819. */
  68820. WordWrap = 1,
  68821. /**
  68822. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68823. */
  68824. Ellipsis = 2
  68825. }
  68826. /**
  68827. * Class used to create text block control
  68828. */
  68829. export class TextBlock extends Control {
  68830. /**
  68831. * Defines the name of the control
  68832. */
  68833. name?: string | undefined;
  68834. private _text;
  68835. private _textWrapping;
  68836. private _textHorizontalAlignment;
  68837. private _textVerticalAlignment;
  68838. private _lines;
  68839. private _resizeToFit;
  68840. private _lineSpacing;
  68841. private _outlineWidth;
  68842. private _outlineColor;
  68843. /**
  68844. * An event triggered after the text is changed
  68845. */
  68846. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68847. /**
  68848. * An event triggered after the text was broken up into lines
  68849. */
  68850. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68851. /**
  68852. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68853. */
  68854. get lines(): any[];
  68855. /**
  68856. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68857. */
  68858. get resizeToFit(): boolean;
  68859. /**
  68860. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68861. */
  68862. set resizeToFit(value: boolean);
  68863. /**
  68864. * Gets or sets a boolean indicating if text must be wrapped
  68865. */
  68866. get textWrapping(): TextWrapping | boolean;
  68867. /**
  68868. * Gets or sets a boolean indicating if text must be wrapped
  68869. */
  68870. set textWrapping(value: TextWrapping | boolean);
  68871. /**
  68872. * Gets or sets text to display
  68873. */
  68874. get text(): string;
  68875. /**
  68876. * Gets or sets text to display
  68877. */
  68878. set text(value: string);
  68879. /**
  68880. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68881. */
  68882. get textHorizontalAlignment(): number;
  68883. /**
  68884. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68885. */
  68886. set textHorizontalAlignment(value: number);
  68887. /**
  68888. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68889. */
  68890. get textVerticalAlignment(): number;
  68891. /**
  68892. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68893. */
  68894. set textVerticalAlignment(value: number);
  68895. /**
  68896. * Gets or sets line spacing value
  68897. */
  68898. set lineSpacing(value: string | number);
  68899. /**
  68900. * Gets or sets line spacing value
  68901. */
  68902. get lineSpacing(): string | number;
  68903. /**
  68904. * Gets or sets outlineWidth of the text to display
  68905. */
  68906. get outlineWidth(): number;
  68907. /**
  68908. * Gets or sets outlineWidth of the text to display
  68909. */
  68910. set outlineWidth(value: number);
  68911. /**
  68912. * Gets or sets outlineColor of the text to display
  68913. */
  68914. get outlineColor(): string;
  68915. /**
  68916. * Gets or sets outlineColor of the text to display
  68917. */
  68918. set outlineColor(value: string);
  68919. /**
  68920. * Creates a new TextBlock object
  68921. * @param name defines the name of the control
  68922. * @param text defines the text to display (emptry string by default)
  68923. */
  68924. constructor(
  68925. /**
  68926. * Defines the name of the control
  68927. */
  68928. name?: string | undefined, text?: string);
  68929. protected _getTypeName(): string;
  68930. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68931. private _drawText;
  68932. /** @hidden */
  68933. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68934. protected _applyStates(context: CanvasRenderingContext2D): void;
  68935. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68936. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68937. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68938. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68939. protected _renderLines(context: CanvasRenderingContext2D): void;
  68940. /**
  68941. * Given a width constraint applied on the text block, find the expected height
  68942. * @returns expected height
  68943. */
  68944. computeExpectedHeight(): number;
  68945. dispose(): void;
  68946. }
  68947. }
  68948. declare module BABYLON.GUI {
  68949. /**
  68950. * Class used to create 2D images
  68951. */
  68952. export class Image extends Control {
  68953. name?: string | undefined;
  68954. private _workingCanvas;
  68955. private _domImage;
  68956. private _imageWidth;
  68957. private _imageHeight;
  68958. private _loaded;
  68959. private _stretch;
  68960. private _source;
  68961. private _autoScale;
  68962. private _sourceLeft;
  68963. private _sourceTop;
  68964. private _sourceWidth;
  68965. private _sourceHeight;
  68966. private _cellWidth;
  68967. private _cellHeight;
  68968. private _cellId;
  68969. private _populateNinePatchSlicesFromImage;
  68970. private _sliceLeft;
  68971. private _sliceRight;
  68972. private _sliceTop;
  68973. private _sliceBottom;
  68974. private _detectPointerOnOpaqueOnly;
  68975. /**
  68976. * BABYLON.Observable notified when the content is loaded
  68977. */
  68978. onImageLoadedObservable: BABYLON.Observable<Image>;
  68979. /**
  68980. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  68981. */
  68982. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  68983. /**
  68984. * Gets a boolean indicating that the content is loaded
  68985. */
  68986. get isLoaded(): boolean;
  68987. /**
  68988. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  68989. */
  68990. get populateNinePatchSlicesFromImage(): boolean;
  68991. set populateNinePatchSlicesFromImage(value: boolean);
  68992. /**
  68993. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  68994. * Beware using this as this will comsume more memory as the image has to be stored twice
  68995. */
  68996. get detectPointerOnOpaqueOnly(): boolean;
  68997. set detectPointerOnOpaqueOnly(value: boolean);
  68998. /**
  68999. * Gets or sets the left value for slicing (9-patch)
  69000. */
  69001. get sliceLeft(): number;
  69002. set sliceLeft(value: number);
  69003. /**
  69004. * Gets or sets the right value for slicing (9-patch)
  69005. */
  69006. get sliceRight(): number;
  69007. set sliceRight(value: number);
  69008. /**
  69009. * Gets or sets the top value for slicing (9-patch)
  69010. */
  69011. get sliceTop(): number;
  69012. set sliceTop(value: number);
  69013. /**
  69014. * Gets or sets the bottom value for slicing (9-patch)
  69015. */
  69016. get sliceBottom(): number;
  69017. set sliceBottom(value: number);
  69018. /**
  69019. * Gets or sets the left coordinate in the source image
  69020. */
  69021. get sourceLeft(): number;
  69022. set sourceLeft(value: number);
  69023. /**
  69024. * Gets or sets the top coordinate in the source image
  69025. */
  69026. get sourceTop(): number;
  69027. set sourceTop(value: number);
  69028. /**
  69029. * Gets or sets the width to capture in the source image
  69030. */
  69031. get sourceWidth(): number;
  69032. set sourceWidth(value: number);
  69033. /**
  69034. * Gets or sets the height to capture in the source image
  69035. */
  69036. get sourceHeight(): number;
  69037. set sourceHeight(value: number);
  69038. /**
  69039. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69040. * @see http://doc.babylonjs.com/how_to/gui#image
  69041. */
  69042. get autoScale(): boolean;
  69043. set autoScale(value: boolean);
  69044. /** Gets or sets the streching mode used by the image */
  69045. get stretch(): number;
  69046. set stretch(value: number);
  69047. /** @hidden */
  69048. _rotate90(n: number): Image;
  69049. /**
  69050. * Gets or sets the internal DOM image used to render the control
  69051. */
  69052. set domImage(value: HTMLImageElement);
  69053. get domImage(): HTMLImageElement;
  69054. private _onImageLoaded;
  69055. private _extractNinePatchSliceDataFromImage;
  69056. /**
  69057. * Gets or sets image source url
  69058. */
  69059. set source(value: BABYLON.Nullable<string>);
  69060. /**
  69061. * Checks for svg document with icon id present
  69062. */
  69063. private _svgCheck;
  69064. /**
  69065. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69066. * given external svg file and icon id
  69067. */
  69068. private _getSVGAttribs;
  69069. /**
  69070. * Gets or sets the cell width to use when animation sheet is enabled
  69071. * @see http://doc.babylonjs.com/how_to/gui#image
  69072. */
  69073. get cellWidth(): number;
  69074. set cellWidth(value: number);
  69075. /**
  69076. * Gets or sets the cell height to use when animation sheet is enabled
  69077. * @see http://doc.babylonjs.com/how_to/gui#image
  69078. */
  69079. get cellHeight(): number;
  69080. set cellHeight(value: number);
  69081. /**
  69082. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69083. * @see http://doc.babylonjs.com/how_to/gui#image
  69084. */
  69085. get cellId(): number;
  69086. set cellId(value: number);
  69087. /**
  69088. * Creates a new Image
  69089. * @param name defines the control name
  69090. * @param url defines the image url
  69091. */
  69092. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69093. /**
  69094. * Tests if a given coordinates belong to the current control
  69095. * @param x defines x coordinate to test
  69096. * @param y defines y coordinate to test
  69097. * @returns true if the coordinates are inside the control
  69098. */
  69099. contains(x: number, y: number): boolean;
  69100. protected _getTypeName(): string;
  69101. /** Force the control to synchronize with its content */
  69102. synchronizeSizeWithContent(): void;
  69103. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69104. private _prepareWorkingCanvasForOpaqueDetection;
  69105. private _drawImage;
  69106. _draw(context: CanvasRenderingContext2D): void;
  69107. private _renderCornerPatch;
  69108. private _renderNinePatch;
  69109. dispose(): void;
  69110. /** STRETCH_NONE */
  69111. static readonly STRETCH_NONE: number;
  69112. /** STRETCH_FILL */
  69113. static readonly STRETCH_FILL: number;
  69114. /** STRETCH_UNIFORM */
  69115. static readonly STRETCH_UNIFORM: number;
  69116. /** STRETCH_EXTEND */
  69117. static readonly STRETCH_EXTEND: number;
  69118. /** NINE_PATCH */
  69119. static readonly STRETCH_NINE_PATCH: number;
  69120. }
  69121. }
  69122. declare module BABYLON.GUI {
  69123. /**
  69124. * Class used to create 2D buttons
  69125. */
  69126. export class Button extends Rectangle {
  69127. name?: string | undefined;
  69128. /**
  69129. * Function called to generate a pointer enter animation
  69130. */
  69131. pointerEnterAnimation: () => void;
  69132. /**
  69133. * Function called to generate a pointer out animation
  69134. */
  69135. pointerOutAnimation: () => void;
  69136. /**
  69137. * Function called to generate a pointer down animation
  69138. */
  69139. pointerDownAnimation: () => void;
  69140. /**
  69141. * Function called to generate a pointer up animation
  69142. */
  69143. pointerUpAnimation: () => void;
  69144. /**
  69145. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69146. */
  69147. delegatePickingToChildren: boolean;
  69148. private _image;
  69149. /**
  69150. * Returns the image part of the button (if any)
  69151. */
  69152. get image(): BABYLON.Nullable<Image>;
  69153. private _textBlock;
  69154. /**
  69155. * Returns the image part of the button (if any)
  69156. */
  69157. get textBlock(): BABYLON.Nullable<TextBlock>;
  69158. /**
  69159. * Creates a new Button
  69160. * @param name defines the name of the button
  69161. */
  69162. constructor(name?: string | undefined);
  69163. protected _getTypeName(): string;
  69164. /** @hidden */
  69165. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69166. /** @hidden */
  69167. _onPointerEnter(target: Control): boolean;
  69168. /** @hidden */
  69169. _onPointerOut(target: Control, force?: boolean): void;
  69170. /** @hidden */
  69171. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69172. /** @hidden */
  69173. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69174. /**
  69175. * Creates a new button made with an image and a text
  69176. * @param name defines the name of the button
  69177. * @param text defines the text of the button
  69178. * @param imageUrl defines the url of the image
  69179. * @returns a new Button
  69180. */
  69181. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69182. /**
  69183. * Creates a new button made with an image
  69184. * @param name defines the name of the button
  69185. * @param imageUrl defines the url of the image
  69186. * @returns a new Button
  69187. */
  69188. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69189. /**
  69190. * Creates a new button made with a text
  69191. * @param name defines the name of the button
  69192. * @param text defines the text of the button
  69193. * @returns a new Button
  69194. */
  69195. static CreateSimpleButton(name: string, text: string): Button;
  69196. /**
  69197. * Creates a new button made with an image and a centered text
  69198. * @param name defines the name of the button
  69199. * @param text defines the text of the button
  69200. * @param imageUrl defines the url of the image
  69201. * @returns a new Button
  69202. */
  69203. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69204. }
  69205. }
  69206. declare module BABYLON.GUI {
  69207. /**
  69208. * Class used to create a 2D stack panel container
  69209. */
  69210. export class StackPanel extends Container {
  69211. name?: string | undefined;
  69212. private _isVertical;
  69213. private _manualWidth;
  69214. private _manualHeight;
  69215. private _doNotTrackManualChanges;
  69216. /**
  69217. * Gets or sets a boolean indicating that layou warnings should be ignored
  69218. */
  69219. ignoreLayoutWarnings: boolean;
  69220. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69221. get isVertical(): boolean;
  69222. set isVertical(value: boolean);
  69223. /**
  69224. * Gets or sets panel width.
  69225. * This value should not be set when in horizontal mode as it will be computed automatically
  69226. */
  69227. set width(value: string | number);
  69228. get width(): string | number;
  69229. /**
  69230. * Gets or sets panel height.
  69231. * This value should not be set when in vertical mode as it will be computed automatically
  69232. */
  69233. set height(value: string | number);
  69234. get height(): string | number;
  69235. /**
  69236. * Creates a new StackPanel
  69237. * @param name defines control name
  69238. */
  69239. constructor(name?: string | undefined);
  69240. protected _getTypeName(): string;
  69241. /** @hidden */
  69242. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69243. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69244. protected _postMeasure(): void;
  69245. }
  69246. }
  69247. declare module BABYLON.GUI {
  69248. /**
  69249. * Class used to represent a 2D checkbox
  69250. */
  69251. export class Checkbox extends Control {
  69252. name?: string | undefined;
  69253. private _isChecked;
  69254. private _background;
  69255. private _checkSizeRatio;
  69256. private _thickness;
  69257. /** Gets or sets border thickness */
  69258. get thickness(): number;
  69259. set thickness(value: number);
  69260. /**
  69261. * BABYLON.Observable raised when isChecked property changes
  69262. */
  69263. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69264. /** Gets or sets a value indicating the ratio between overall size and check size */
  69265. get checkSizeRatio(): number;
  69266. set checkSizeRatio(value: number);
  69267. /** Gets or sets background color */
  69268. get background(): string;
  69269. set background(value: string);
  69270. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69271. get isChecked(): boolean;
  69272. set isChecked(value: boolean);
  69273. /**
  69274. * Creates a new CheckBox
  69275. * @param name defines the control name
  69276. */
  69277. constructor(name?: string | undefined);
  69278. protected _getTypeName(): string;
  69279. /** @hidden */
  69280. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69281. /** @hidden */
  69282. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69283. /**
  69284. * Utility function to easily create a checkbox with a header
  69285. * @param title defines the label to use for the header
  69286. * @param onValueChanged defines the callback to call when value changes
  69287. * @returns a StackPanel containing the checkbox and a textBlock
  69288. */
  69289. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  69290. }
  69291. }
  69292. declare module BABYLON.GUI {
  69293. /**
  69294. * Class used to store key control properties
  69295. */
  69296. export class KeyPropertySet {
  69297. /** Width */
  69298. width?: string;
  69299. /** Height */
  69300. height?: string;
  69301. /** Left padding */
  69302. paddingLeft?: string;
  69303. /** Right padding */
  69304. paddingRight?: string;
  69305. /** Top padding */
  69306. paddingTop?: string;
  69307. /** Bottom padding */
  69308. paddingBottom?: string;
  69309. /** Foreground color */
  69310. color?: string;
  69311. /** Background color */
  69312. background?: string;
  69313. }
  69314. /**
  69315. * Class used to create virtual keyboard
  69316. */
  69317. export class VirtualKeyboard extends StackPanel {
  69318. /** BABYLON.Observable raised when a key is pressed */
  69319. onKeyPressObservable: BABYLON.Observable<string>;
  69320. /** Gets or sets default key button width */
  69321. defaultButtonWidth: string;
  69322. /** Gets or sets default key button height */
  69323. defaultButtonHeight: string;
  69324. /** Gets or sets default key button left padding */
  69325. defaultButtonPaddingLeft: string;
  69326. /** Gets or sets default key button right padding */
  69327. defaultButtonPaddingRight: string;
  69328. /** Gets or sets default key button top padding */
  69329. defaultButtonPaddingTop: string;
  69330. /** Gets or sets default key button bottom padding */
  69331. defaultButtonPaddingBottom: string;
  69332. /** Gets or sets default key button foreground color */
  69333. defaultButtonColor: string;
  69334. /** Gets or sets default key button background color */
  69335. defaultButtonBackground: string;
  69336. /** Gets or sets shift button foreground color */
  69337. shiftButtonColor: string;
  69338. /** Gets or sets shift button thickness*/
  69339. selectedShiftThickness: number;
  69340. /** Gets shift key state */
  69341. shiftState: number;
  69342. protected _getTypeName(): string;
  69343. private _createKey;
  69344. /**
  69345. * Adds a new row of keys
  69346. * @param keys defines the list of keys to add
  69347. * @param propertySets defines the associated property sets
  69348. */
  69349. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  69350. /**
  69351. * Set the shift key to a specific state
  69352. * @param shiftState defines the new shift state
  69353. */
  69354. applyShiftState(shiftState: number): void;
  69355. private _currentlyConnectedInputText;
  69356. private _connectedInputTexts;
  69357. private _onKeyPressObserver;
  69358. /** Gets the input text control currently attached to the keyboard */
  69359. get connectedInputText(): BABYLON.Nullable<InputText>;
  69360. /**
  69361. * Connects the keyboard with an input text control
  69362. *
  69363. * @param input defines the target control
  69364. */
  69365. connect(input: InputText): void;
  69366. /**
  69367. * Disconnects the keyboard from connected InputText controls
  69368. *
  69369. * @param input optionally defines a target control, otherwise all are disconnected
  69370. */
  69371. disconnect(input?: InputText): void;
  69372. private _removeConnectedInputObservables;
  69373. /**
  69374. * Release all resources
  69375. */
  69376. dispose(): void;
  69377. /**
  69378. * Creates a new keyboard using a default layout
  69379. *
  69380. * @param name defines control name
  69381. * @returns a new VirtualKeyboard
  69382. */
  69383. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  69384. }
  69385. }
  69386. declare module BABYLON.GUI {
  69387. /**
  69388. * Class used to create input text control
  69389. */
  69390. export class InputText extends Control implements IFocusableControl {
  69391. name?: string | undefined;
  69392. private _text;
  69393. private _placeholderText;
  69394. private _background;
  69395. private _focusedBackground;
  69396. private _focusedColor;
  69397. private _placeholderColor;
  69398. private _thickness;
  69399. private _margin;
  69400. private _autoStretchWidth;
  69401. private _maxWidth;
  69402. private _isFocused;
  69403. private _blinkTimeout;
  69404. private _blinkIsEven;
  69405. private _cursorOffset;
  69406. private _scrollLeft;
  69407. private _textWidth;
  69408. private _clickedCoordinate;
  69409. private _deadKey;
  69410. private _addKey;
  69411. private _currentKey;
  69412. private _isTextHighlightOn;
  69413. private _textHighlightColor;
  69414. private _highligherOpacity;
  69415. private _highlightedText;
  69416. private _startHighlightIndex;
  69417. private _endHighlightIndex;
  69418. private _cursorIndex;
  69419. private _onFocusSelectAll;
  69420. private _isPointerDown;
  69421. private _onClipboardObserver;
  69422. private _onPointerDblTapObserver;
  69423. /** @hidden */
  69424. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  69425. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  69426. promptMessage: string;
  69427. /** Force disable prompt on mobile device */
  69428. disableMobilePrompt: boolean;
  69429. /** BABYLON.Observable raised when the text changes */
  69430. onTextChangedObservable: BABYLON.Observable<InputText>;
  69431. /** BABYLON.Observable raised just before an entered character is to be added */
  69432. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  69433. /** BABYLON.Observable raised when the control gets the focus */
  69434. onFocusObservable: BABYLON.Observable<InputText>;
  69435. /** BABYLON.Observable raised when the control loses the focus */
  69436. onBlurObservable: BABYLON.Observable<InputText>;
  69437. /**Observable raised when the text is highlighted */
  69438. onTextHighlightObservable: BABYLON.Observable<InputText>;
  69439. /**Observable raised when copy event is triggered */
  69440. onTextCopyObservable: BABYLON.Observable<InputText>;
  69441. /** BABYLON.Observable raised when cut event is triggered */
  69442. onTextCutObservable: BABYLON.Observable<InputText>;
  69443. /** BABYLON.Observable raised when paste event is triggered */
  69444. onTextPasteObservable: BABYLON.Observable<InputText>;
  69445. /** BABYLON.Observable raised when a key event was processed */
  69446. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  69447. /** Gets or sets the maximum width allowed by the control */
  69448. get maxWidth(): string | number;
  69449. /** Gets the maximum width allowed by the control in pixels */
  69450. get maxWidthInPixels(): number;
  69451. set maxWidth(value: string | number);
  69452. /** Gets or sets the text highlighter transparency; default: 0.4 */
  69453. get highligherOpacity(): number;
  69454. set highligherOpacity(value: number);
  69455. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  69456. get onFocusSelectAll(): boolean;
  69457. set onFocusSelectAll(value: boolean);
  69458. /** Gets or sets the text hightlight color */
  69459. get textHighlightColor(): string;
  69460. set textHighlightColor(value: string);
  69461. /** Gets or sets control margin */
  69462. get margin(): string;
  69463. /** Gets control margin in pixels */
  69464. get marginInPixels(): number;
  69465. set margin(value: string);
  69466. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  69467. get autoStretchWidth(): boolean;
  69468. set autoStretchWidth(value: boolean);
  69469. /** Gets or sets border thickness */
  69470. get thickness(): number;
  69471. set thickness(value: number);
  69472. /** Gets or sets the background color when focused */
  69473. get focusedBackground(): string;
  69474. set focusedBackground(value: string);
  69475. /** Gets or sets the background color when focused */
  69476. get focusedColor(): string;
  69477. set focusedColor(value: string);
  69478. /** Gets or sets the background color */
  69479. get background(): string;
  69480. set background(value: string);
  69481. /** Gets or sets the placeholder color */
  69482. get placeholderColor(): string;
  69483. set placeholderColor(value: string);
  69484. /** Gets or sets the text displayed when the control is empty */
  69485. get placeholderText(): string;
  69486. set placeholderText(value: string);
  69487. /** Gets or sets the dead key flag */
  69488. get deadKey(): boolean;
  69489. set deadKey(flag: boolean);
  69490. /** Gets or sets the highlight text */
  69491. get highlightedText(): string;
  69492. set highlightedText(text: string);
  69493. /** Gets or sets if the current key should be added */
  69494. get addKey(): boolean;
  69495. set addKey(flag: boolean);
  69496. /** Gets or sets the value of the current key being entered */
  69497. get currentKey(): string;
  69498. set currentKey(key: string);
  69499. /** Gets or sets the text displayed in the control */
  69500. get text(): string;
  69501. set text(value: string);
  69502. /** Gets or sets control width */
  69503. get width(): string | number;
  69504. set width(value: string | number);
  69505. /**
  69506. * Creates a new InputText
  69507. * @param name defines the control name
  69508. * @param text defines the text of the control
  69509. */
  69510. constructor(name?: string | undefined, text?: string);
  69511. /** @hidden */
  69512. onBlur(): void;
  69513. /** @hidden */
  69514. onFocus(): void;
  69515. protected _getTypeName(): string;
  69516. /**
  69517. * Function called to get the list of controls that should not steal the focus from this control
  69518. * @returns an array of controls
  69519. */
  69520. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69521. /** @hidden */
  69522. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  69523. /** @hidden */
  69524. private _updateValueFromCursorIndex;
  69525. /** @hidden */
  69526. private _processDblClick;
  69527. /** @hidden */
  69528. private _selectAllText;
  69529. /**
  69530. * Handles the keyboard event
  69531. * @param evt Defines the KeyboardEvent
  69532. */
  69533. processKeyboard(evt: KeyboardEvent): void;
  69534. /** @hidden */
  69535. private _onCopyText;
  69536. /** @hidden */
  69537. private _onCutText;
  69538. /** @hidden */
  69539. private _onPasteText;
  69540. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69541. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69542. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69543. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69544. protected _beforeRenderText(text: string): string;
  69545. dispose(): void;
  69546. }
  69547. }
  69548. declare module BABYLON.GUI {
  69549. /**
  69550. * Class used to create a 2D grid container
  69551. */
  69552. export class Grid extends Container {
  69553. name?: string | undefined;
  69554. private _rowDefinitions;
  69555. private _columnDefinitions;
  69556. private _cells;
  69557. private _childControls;
  69558. /**
  69559. * Gets the number of columns
  69560. */
  69561. get columnCount(): number;
  69562. /**
  69563. * Gets the number of rows
  69564. */
  69565. get rowCount(): number;
  69566. /** Gets the list of children */
  69567. get children(): Control[];
  69568. /** Gets the list of cells (e.g. the containers) */
  69569. get cells(): {
  69570. [key: string]: Container;
  69571. };
  69572. /**
  69573. * Gets the definition of a specific row
  69574. * @param index defines the index of the row
  69575. * @returns the row definition
  69576. */
  69577. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69578. /**
  69579. * Gets the definition of a specific column
  69580. * @param index defines the index of the column
  69581. * @returns the column definition
  69582. */
  69583. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69584. /**
  69585. * Adds a new row to the grid
  69586. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69587. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  69588. * @returns the current grid
  69589. */
  69590. addRowDefinition(height: number, isPixel?: boolean): Grid;
  69591. /**
  69592. * Adds a new column to the grid
  69593. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69594. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69595. * @returns the current grid
  69596. */
  69597. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  69598. /**
  69599. * Update a row definition
  69600. * @param index defines the index of the row to update
  69601. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69602. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  69603. * @returns the current grid
  69604. */
  69605. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  69606. /**
  69607. * Update a column definition
  69608. * @param index defines the index of the column to update
  69609. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69610. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69611. * @returns the current grid
  69612. */
  69613. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  69614. /**
  69615. * Gets the list of children stored in a specific cell
  69616. * @param row defines the row to check
  69617. * @param column defines the column to check
  69618. * @returns the list of controls
  69619. */
  69620. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  69621. /**
  69622. * Gets a string representing the child cell info (row x column)
  69623. * @param child defines the control to get info from
  69624. * @returns a string containing the child cell info (row x column)
  69625. */
  69626. getChildCellInfo(child: Control): string;
  69627. private _removeCell;
  69628. private _offsetCell;
  69629. /**
  69630. * Remove a column definition at specified index
  69631. * @param index defines the index of the column to remove
  69632. * @returns the current grid
  69633. */
  69634. removeColumnDefinition(index: number): Grid;
  69635. /**
  69636. * Remove a row definition at specified index
  69637. * @param index defines the index of the row to remove
  69638. * @returns the current grid
  69639. */
  69640. removeRowDefinition(index: number): Grid;
  69641. /**
  69642. * Adds a new control to the current grid
  69643. * @param control defines the control to add
  69644. * @param row defines the row where to add the control (0 by default)
  69645. * @param column defines the column where to add the control (0 by default)
  69646. * @returns the current grid
  69647. */
  69648. addControl(control: Control, row?: number, column?: number): Grid;
  69649. /**
  69650. * Removes a control from the current container
  69651. * @param control defines the control to remove
  69652. * @returns the current container
  69653. */
  69654. removeControl(control: Control): Container;
  69655. /**
  69656. * Creates a new Grid
  69657. * @param name defines control name
  69658. */
  69659. constructor(name?: string | undefined);
  69660. protected _getTypeName(): string;
  69661. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  69662. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69663. _flagDescendantsAsMatrixDirty(): void;
  69664. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69665. /** Releases associated resources */
  69666. dispose(): void;
  69667. }
  69668. }
  69669. declare module BABYLON.GUI {
  69670. /** Class used to create color pickers */
  69671. export class ColorPicker extends Control {
  69672. name?: string | undefined;
  69673. private static _Epsilon;
  69674. private _colorWheelCanvas;
  69675. private _value;
  69676. private _tmpColor;
  69677. private _pointerStartedOnSquare;
  69678. private _pointerStartedOnWheel;
  69679. private _squareLeft;
  69680. private _squareTop;
  69681. private _squareSize;
  69682. private _h;
  69683. private _s;
  69684. private _v;
  69685. private _lastPointerDownID;
  69686. /**
  69687. * BABYLON.Observable raised when the value changes
  69688. */
  69689. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  69690. /** Gets or sets the color of the color picker */
  69691. get value(): BABYLON.Color3;
  69692. set value(value: BABYLON.Color3);
  69693. /**
  69694. * Gets or sets control width
  69695. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69696. */
  69697. get width(): string | number;
  69698. set width(value: string | number);
  69699. /**
  69700. * Gets or sets control height
  69701. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69702. */
  69703. get height(): string | number;
  69704. /** Gets or sets control height */
  69705. set height(value: string | number);
  69706. /** Gets or sets control size */
  69707. get size(): string | number;
  69708. set size(value: string | number);
  69709. /**
  69710. * Creates a new ColorPicker
  69711. * @param name defines the control name
  69712. */
  69713. constructor(name?: string | undefined);
  69714. protected _getTypeName(): string;
  69715. /** @hidden */
  69716. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69717. private _updateSquareProps;
  69718. private _drawGradientSquare;
  69719. private _drawCircle;
  69720. private _createColorWheelCanvas;
  69721. /** @hidden */
  69722. _draw(context: CanvasRenderingContext2D): void;
  69723. private _pointerIsDown;
  69724. private _updateValueFromPointer;
  69725. private _isPointOnSquare;
  69726. private _isPointOnWheel;
  69727. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69728. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69729. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69730. /**
  69731. * This function expands the color picker by creating a color picker dialog with manual
  69732. * color value input and the ability to save colors into an array to be used later in
  69733. * subsequent launches of the dialogue.
  69734. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69735. * @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.
  69736. * @returns picked color as a hex string and the saved colors array as hex strings.
  69737. */
  69738. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69739. pickerWidth?: string;
  69740. pickerHeight?: string;
  69741. headerHeight?: string;
  69742. lastColor?: string;
  69743. swatchLimit?: number;
  69744. numSwatchesPerLine?: number;
  69745. savedColors?: Array<string>;
  69746. }): Promise<{
  69747. savedColors?: string[];
  69748. pickedColor: string;
  69749. }>;
  69750. }
  69751. }
  69752. declare module BABYLON.GUI {
  69753. /** Class used to create 2D ellipse containers */
  69754. export class Ellipse extends Container {
  69755. name?: string | undefined;
  69756. private _thickness;
  69757. /** Gets or sets border thickness */
  69758. get thickness(): number;
  69759. set thickness(value: number);
  69760. /**
  69761. * Creates a new Ellipse
  69762. * @param name defines the control name
  69763. */
  69764. constructor(name?: string | undefined);
  69765. protected _getTypeName(): string;
  69766. protected _localDraw(context: CanvasRenderingContext2D): void;
  69767. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69768. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69769. }
  69770. }
  69771. declare module BABYLON.GUI {
  69772. /**
  69773. * Class used to create a password control
  69774. */
  69775. export class InputPassword extends InputText {
  69776. protected _beforeRenderText(text: string): string;
  69777. }
  69778. }
  69779. declare module BABYLON.GUI {
  69780. /** Class used to render 2D lines */
  69781. export class Line extends Control {
  69782. name?: string | undefined;
  69783. private _lineWidth;
  69784. private _x1;
  69785. private _y1;
  69786. private _x2;
  69787. private _y2;
  69788. private _dash;
  69789. private _connectedControl;
  69790. private _connectedControlDirtyObserver;
  69791. /** Gets or sets the dash pattern */
  69792. get dash(): Array<number>;
  69793. set dash(value: Array<number>);
  69794. /** Gets or sets the control connected with the line end */
  69795. get connectedControl(): Control;
  69796. set connectedControl(value: Control);
  69797. /** Gets or sets start coordinates on X axis */
  69798. get x1(): string | number;
  69799. set x1(value: string | number);
  69800. /** Gets or sets start coordinates on Y axis */
  69801. get y1(): string | number;
  69802. set y1(value: string | number);
  69803. /** Gets or sets end coordinates on X axis */
  69804. get x2(): string | number;
  69805. set x2(value: string | number);
  69806. /** Gets or sets end coordinates on Y axis */
  69807. get y2(): string | number;
  69808. set y2(value: string | number);
  69809. /** Gets or sets line width */
  69810. get lineWidth(): number;
  69811. set lineWidth(value: number);
  69812. /** Gets or sets horizontal alignment */
  69813. set horizontalAlignment(value: number);
  69814. /** Gets or sets vertical alignment */
  69815. set verticalAlignment(value: number);
  69816. private get _effectiveX2();
  69817. private get _effectiveY2();
  69818. /**
  69819. * Creates a new Line
  69820. * @param name defines the control name
  69821. */
  69822. constructor(name?: string | undefined);
  69823. protected _getTypeName(): string;
  69824. _draw(context: CanvasRenderingContext2D): void;
  69825. _measure(): void;
  69826. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69827. /**
  69828. * Move one end of the line given 3D cartesian coordinates.
  69829. * @param position Targeted world position
  69830. * @param scene BABYLON.Scene
  69831. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69832. */
  69833. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69834. /**
  69835. * Move one end of the line to a position in screen absolute space.
  69836. * @param projectedPosition Position in screen absolute space (X, Y)
  69837. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69838. */
  69839. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69840. }
  69841. }
  69842. declare module BABYLON.GUI {
  69843. /**
  69844. * Class used to store a point for a MultiLine object.
  69845. * The point can be pure 2D coordinates, a mesh or a control
  69846. */
  69847. export class MultiLinePoint {
  69848. private _multiLine;
  69849. private _x;
  69850. private _y;
  69851. private _control;
  69852. private _mesh;
  69853. private _controlObserver;
  69854. private _meshObserver;
  69855. /** @hidden */
  69856. _point: BABYLON.Vector2;
  69857. /**
  69858. * Creates a new MultiLinePoint
  69859. * @param multiLine defines the source MultiLine object
  69860. */
  69861. constructor(multiLine: MultiLine);
  69862. /** Gets or sets x coordinate */
  69863. get x(): string | number;
  69864. set x(value: string | number);
  69865. /** Gets or sets y coordinate */
  69866. get y(): string | number;
  69867. set y(value: string | number);
  69868. /** Gets or sets the control associated with this point */
  69869. get control(): BABYLON.Nullable<Control>;
  69870. set control(value: BABYLON.Nullable<Control>);
  69871. /** Gets or sets the mesh associated with this point */
  69872. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69873. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  69874. /** Resets links */
  69875. resetLinks(): void;
  69876. /**
  69877. * Gets a translation vector
  69878. * @returns the translation vector
  69879. */
  69880. translate(): BABYLON.Vector2;
  69881. private _translatePoint;
  69882. /** Release associated resources */
  69883. dispose(): void;
  69884. }
  69885. }
  69886. declare module BABYLON.GUI {
  69887. /**
  69888. * Class used to create multi line control
  69889. */
  69890. export class MultiLine extends Control {
  69891. name?: string | undefined;
  69892. private _lineWidth;
  69893. private _dash;
  69894. private _points;
  69895. private _minX;
  69896. private _minY;
  69897. private _maxX;
  69898. private _maxY;
  69899. /**
  69900. * Creates a new MultiLine
  69901. * @param name defines the control name
  69902. */
  69903. constructor(name?: string | undefined);
  69904. /** Gets or sets dash pattern */
  69905. get dash(): Array<number>;
  69906. set dash(value: Array<number>);
  69907. /**
  69908. * Gets point stored at specified index
  69909. * @param index defines the index to look for
  69910. * @returns the requested point if found
  69911. */
  69912. getAt(index: number): MultiLinePoint;
  69913. /** Function called when a point is updated */
  69914. onPointUpdate: () => void;
  69915. /**
  69916. * Adds new points to the point collection
  69917. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69918. * @returns the list of created MultiLinePoint
  69919. */
  69920. add(...items: (AbstractMesh | Control | {
  69921. x: string | number;
  69922. y: string | number;
  69923. })[]): MultiLinePoint[];
  69924. /**
  69925. * Adds a new point to the point collection
  69926. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69927. * @returns the created MultiLinePoint
  69928. */
  69929. push(item?: (AbstractMesh | Control | {
  69930. x: string | number;
  69931. y: string | number;
  69932. })): MultiLinePoint;
  69933. /**
  69934. * Remove a specific value or point from the active point collection
  69935. * @param value defines the value or point to remove
  69936. */
  69937. remove(value: number | MultiLinePoint): void;
  69938. /**
  69939. * Resets this object to initial state (no point)
  69940. */
  69941. reset(): void;
  69942. /**
  69943. * Resets all links
  69944. */
  69945. resetLinks(): void;
  69946. /** Gets or sets line width */
  69947. get lineWidth(): number;
  69948. set lineWidth(value: number);
  69949. set horizontalAlignment(value: number);
  69950. set verticalAlignment(value: number);
  69951. protected _getTypeName(): string;
  69952. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69953. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69954. _measure(): void;
  69955. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69956. dispose(): void;
  69957. }
  69958. }
  69959. declare module BABYLON.GUI {
  69960. /**
  69961. * Class used to create radio button controls
  69962. */
  69963. export class RadioButton extends Control {
  69964. name?: string | undefined;
  69965. private _isChecked;
  69966. private _background;
  69967. private _checkSizeRatio;
  69968. private _thickness;
  69969. /** Gets or sets border thickness */
  69970. get thickness(): number;
  69971. set thickness(value: number);
  69972. /** Gets or sets group name */
  69973. group: string;
  69974. /** BABYLON.Observable raised when isChecked is changed */
  69975. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69976. /** Gets or sets a value indicating the ratio between overall size and check size */
  69977. get checkSizeRatio(): number;
  69978. set checkSizeRatio(value: number);
  69979. /** Gets or sets background color */
  69980. get background(): string;
  69981. set background(value: string);
  69982. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69983. get isChecked(): boolean;
  69984. set isChecked(value: boolean);
  69985. /**
  69986. * Creates a new RadioButton
  69987. * @param name defines the control name
  69988. */
  69989. constructor(name?: string | undefined);
  69990. protected _getTypeName(): string;
  69991. _draw(context: CanvasRenderingContext2D): void;
  69992. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69993. /**
  69994. * Utility function to easily create a radio button with a header
  69995. * @param title defines the label to use for the header
  69996. * @param group defines the group to use for the radio button
  69997. * @param isChecked defines the initial state of the radio button
  69998. * @param onValueChanged defines the callback to call when value changes
  69999. * @returns a StackPanel containing the radio button and a textBlock
  70000. */
  70001. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  70002. }
  70003. }
  70004. declare module BABYLON.GUI {
  70005. /**
  70006. * Class used to create slider controls
  70007. */
  70008. export class BaseSlider extends Control {
  70009. name?: string | undefined;
  70010. protected _thumbWidth: ValueAndUnit;
  70011. private _minimum;
  70012. private _maximum;
  70013. private _value;
  70014. private _isVertical;
  70015. protected _barOffset: ValueAndUnit;
  70016. private _isThumbClamped;
  70017. protected _displayThumb: boolean;
  70018. private _step;
  70019. private _lastPointerDownID;
  70020. protected _effectiveBarOffset: number;
  70021. protected _renderLeft: number;
  70022. protected _renderTop: number;
  70023. protected _renderWidth: number;
  70024. protected _renderHeight: number;
  70025. protected _backgroundBoxLength: number;
  70026. protected _backgroundBoxThickness: number;
  70027. protected _effectiveThumbThickness: number;
  70028. /** BABYLON.Observable raised when the sldier value changes */
  70029. onValueChangedObservable: BABYLON.Observable<number>;
  70030. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70031. get displayThumb(): boolean;
  70032. set displayThumb(value: boolean);
  70033. /** Gets or sets a step to apply to values (0 by default) */
  70034. get step(): number;
  70035. set step(value: number);
  70036. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70037. get barOffset(): string | number;
  70038. /** Gets main bar offset in pixels*/
  70039. get barOffsetInPixels(): number;
  70040. set barOffset(value: string | number);
  70041. /** Gets or sets thumb width */
  70042. get thumbWidth(): string | number;
  70043. /** Gets thumb width in pixels */
  70044. get thumbWidthInPixels(): number;
  70045. set thumbWidth(value: string | number);
  70046. /** Gets or sets minimum value */
  70047. get minimum(): number;
  70048. set minimum(value: number);
  70049. /** Gets or sets maximum value */
  70050. get maximum(): number;
  70051. set maximum(value: number);
  70052. /** Gets or sets current value */
  70053. get value(): number;
  70054. set value(value: number);
  70055. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70056. get isVertical(): boolean;
  70057. set isVertical(value: boolean);
  70058. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70059. get isThumbClamped(): boolean;
  70060. set isThumbClamped(value: boolean);
  70061. /**
  70062. * Creates a new BaseSlider
  70063. * @param name defines the control name
  70064. */
  70065. constructor(name?: string | undefined);
  70066. protected _getTypeName(): string;
  70067. protected _getThumbPosition(): number;
  70068. protected _getThumbThickness(type: string): number;
  70069. protected _prepareRenderingData(type: string): void;
  70070. private _pointerIsDown;
  70071. /** @hidden */
  70072. protected _updateValueFromPointer(x: number, y: number): void;
  70073. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70074. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70075. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70076. }
  70077. }
  70078. declare module BABYLON.GUI {
  70079. /**
  70080. * Class used to create slider controls
  70081. */
  70082. export class Slider extends BaseSlider {
  70083. name?: string | undefined;
  70084. private _background;
  70085. private _borderColor;
  70086. private _isThumbCircle;
  70087. protected _displayValueBar: boolean;
  70088. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70089. get displayValueBar(): boolean;
  70090. set displayValueBar(value: boolean);
  70091. /** Gets or sets border color */
  70092. get borderColor(): string;
  70093. set borderColor(value: string);
  70094. /** Gets or sets background color */
  70095. get background(): string;
  70096. set background(value: string);
  70097. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70098. get isThumbCircle(): boolean;
  70099. set isThumbCircle(value: boolean);
  70100. /**
  70101. * Creates a new Slider
  70102. * @param name defines the control name
  70103. */
  70104. constructor(name?: string | undefined);
  70105. protected _getTypeName(): string;
  70106. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70107. }
  70108. }
  70109. declare module BABYLON.GUI {
  70110. /** Class used to create a RadioGroup
  70111. * which contains groups of radio buttons
  70112. */
  70113. export class SelectorGroup {
  70114. /** name of SelectorGroup */
  70115. name: string;
  70116. private _groupPanel;
  70117. private _selectors;
  70118. private _groupHeader;
  70119. /**
  70120. * Creates a new SelectorGroup
  70121. * @param name of group, used as a group heading
  70122. */
  70123. constructor(
  70124. /** name of SelectorGroup */
  70125. name: string);
  70126. /** Gets the groupPanel of the SelectorGroup */
  70127. get groupPanel(): StackPanel;
  70128. /** Gets the selectors array */
  70129. get selectors(): StackPanel[];
  70130. /** Gets and sets the group header */
  70131. get header(): string;
  70132. set header(label: string);
  70133. /** @hidden */
  70134. private _addGroupHeader;
  70135. /** @hidden*/
  70136. _getSelector(selectorNb: number): StackPanel | undefined;
  70137. /** Removes the selector at the given position
  70138. * @param selectorNb the position of the selector within the group
  70139. */
  70140. removeSelector(selectorNb: number): void;
  70141. }
  70142. /** Class used to create a CheckboxGroup
  70143. * which contains groups of checkbox buttons
  70144. */
  70145. export class CheckboxGroup extends SelectorGroup {
  70146. /** Adds a checkbox as a control
  70147. * @param text is the label for the selector
  70148. * @param func is the function called when the Selector is checked
  70149. * @param checked is true when Selector is checked
  70150. */
  70151. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70152. /** @hidden */
  70153. _setSelectorLabel(selectorNb: number, label: string): void;
  70154. /** @hidden */
  70155. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70156. /** @hidden */
  70157. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70158. /** @hidden */
  70159. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70160. }
  70161. /** Class used to create a RadioGroup
  70162. * which contains groups of radio buttons
  70163. */
  70164. export class RadioGroup extends SelectorGroup {
  70165. private _selectNb;
  70166. /** Adds a radio button as a control
  70167. * @param label is the label for the selector
  70168. * @param func is the function called when the Selector is checked
  70169. * @param checked is true when Selector is checked
  70170. */
  70171. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70172. /** @hidden */
  70173. _setSelectorLabel(selectorNb: number, label: string): void;
  70174. /** @hidden */
  70175. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70176. /** @hidden */
  70177. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70178. /** @hidden */
  70179. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70180. }
  70181. /** Class used to create a SliderGroup
  70182. * which contains groups of slider buttons
  70183. */
  70184. export class SliderGroup extends SelectorGroup {
  70185. /**
  70186. * Adds a slider to the SelectorGroup
  70187. * @param label is the label for the SliderBar
  70188. * @param func is the function called when the Slider moves
  70189. * @param unit is a string describing the units used, eg degrees or metres
  70190. * @param min is the minimum value for the Slider
  70191. * @param max is the maximum value for the Slider
  70192. * @param value is the start value for the Slider between min and max
  70193. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70194. */
  70195. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70196. /** @hidden */
  70197. _setSelectorLabel(selectorNb: number, label: string): void;
  70198. /** @hidden */
  70199. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70200. /** @hidden */
  70201. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70202. /** @hidden */
  70203. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70204. }
  70205. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70206. * @see http://doc.babylonjs.com/how_to/selector
  70207. */
  70208. export class SelectionPanel extends Rectangle {
  70209. /** name of SelectionPanel */
  70210. name: string;
  70211. /** an array of SelectionGroups */
  70212. groups: SelectorGroup[];
  70213. private _panel;
  70214. private _buttonColor;
  70215. private _buttonBackground;
  70216. private _headerColor;
  70217. private _barColor;
  70218. private _barHeight;
  70219. private _spacerHeight;
  70220. private _labelColor;
  70221. private _groups;
  70222. private _bars;
  70223. /**
  70224. * Creates a new SelectionPanel
  70225. * @param name of SelectionPanel
  70226. * @param groups is an array of SelectionGroups
  70227. */
  70228. constructor(
  70229. /** name of SelectionPanel */
  70230. name: string,
  70231. /** an array of SelectionGroups */
  70232. groups?: SelectorGroup[]);
  70233. protected _getTypeName(): string;
  70234. /** Gets or sets the headerColor */
  70235. get headerColor(): string;
  70236. set headerColor(color: string);
  70237. private _setHeaderColor;
  70238. /** Gets or sets the button color */
  70239. get buttonColor(): string;
  70240. set buttonColor(color: string);
  70241. private _setbuttonColor;
  70242. /** Gets or sets the label color */
  70243. get labelColor(): string;
  70244. set labelColor(color: string);
  70245. private _setLabelColor;
  70246. /** Gets or sets the button background */
  70247. get buttonBackground(): string;
  70248. set buttonBackground(color: string);
  70249. private _setButtonBackground;
  70250. /** Gets or sets the color of separator bar */
  70251. get barColor(): string;
  70252. set barColor(color: string);
  70253. private _setBarColor;
  70254. /** Gets or sets the height of separator bar */
  70255. get barHeight(): string;
  70256. set barHeight(value: string);
  70257. private _setBarHeight;
  70258. /** Gets or sets the height of spacers*/
  70259. get spacerHeight(): string;
  70260. set spacerHeight(value: string);
  70261. private _setSpacerHeight;
  70262. /** Adds a bar between groups */
  70263. private _addSpacer;
  70264. /** Add a group to the selection panel
  70265. * @param group is the selector group to add
  70266. */
  70267. addGroup(group: SelectorGroup): void;
  70268. /** Remove the group from the given position
  70269. * @param groupNb is the position of the group in the list
  70270. */
  70271. removeGroup(groupNb: number): void;
  70272. /** Change a group header label
  70273. * @param label is the new group header label
  70274. * @param groupNb is the number of the group to relabel
  70275. * */
  70276. setHeaderName(label: string, groupNb: number): void;
  70277. /** Change selector label to the one given
  70278. * @param label is the new selector label
  70279. * @param groupNb is the number of the groupcontaining the selector
  70280. * @param selectorNb is the number of the selector within a group to relabel
  70281. * */
  70282. relabel(label: string, groupNb: number, selectorNb: number): void;
  70283. /** For a given group position remove the selector at the given position
  70284. * @param groupNb is the number of the group to remove the selector from
  70285. * @param selectorNb is the number of the selector within the group
  70286. */
  70287. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  70288. /** For a given group position of correct type add a checkbox button
  70289. * @param groupNb is the number of the group to remove the selector from
  70290. * @param label is the label for the selector
  70291. * @param func is the function called when the Selector is checked
  70292. * @param checked is true when Selector is checked
  70293. */
  70294. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70295. /** For a given group position of correct type add a radio button
  70296. * @param groupNb is the number of the group to remove the selector from
  70297. * @param label is the label for the selector
  70298. * @param func is the function called when the Selector is checked
  70299. * @param checked is true when Selector is checked
  70300. */
  70301. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70302. /**
  70303. * For a given slider group add a slider
  70304. * @param groupNb is the number of the group to add the slider to
  70305. * @param label is the label for the Slider
  70306. * @param func is the function called when the Slider moves
  70307. * @param unit is a string describing the units used, eg degrees or metres
  70308. * @param min is the minimum value for the Slider
  70309. * @param max is the maximum value for the Slider
  70310. * @param value is the start value for the Slider between min and max
  70311. * @param onVal is the function used to format the value displayed, eg radians to degrees
  70312. */
  70313. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  70314. }
  70315. }
  70316. declare module BABYLON.GUI {
  70317. /**
  70318. * Class used to hold a the container for ScrollViewer
  70319. * @hidden
  70320. */
  70321. export class _ScrollViewerWindow extends Container {
  70322. parentClientWidth: number;
  70323. parentClientHeight: number;
  70324. /**
  70325. * Creates a new ScrollViewerWindow
  70326. * @param name of ScrollViewerWindow
  70327. */
  70328. constructor(name?: string);
  70329. protected _getTypeName(): string;
  70330. /** @hidden */
  70331. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70332. protected _postMeasure(): void;
  70333. }
  70334. }
  70335. declare module BABYLON.GUI {
  70336. /**
  70337. * Class used to create slider controls
  70338. */
  70339. export class ScrollBar extends BaseSlider {
  70340. name?: string | undefined;
  70341. private _background;
  70342. private _borderColor;
  70343. private _tempMeasure;
  70344. /** Gets or sets border color */
  70345. get borderColor(): string;
  70346. set borderColor(value: string);
  70347. /** Gets or sets background color */
  70348. get background(): string;
  70349. set background(value: string);
  70350. /**
  70351. * Creates a new Slider
  70352. * @param name defines the control name
  70353. */
  70354. constructor(name?: string | undefined);
  70355. protected _getTypeName(): string;
  70356. protected _getThumbThickness(): number;
  70357. _draw(context: CanvasRenderingContext2D): void;
  70358. private _first;
  70359. private _originX;
  70360. private _originY;
  70361. /** @hidden */
  70362. protected _updateValueFromPointer(x: number, y: number): void;
  70363. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70364. }
  70365. }
  70366. declare module BABYLON.GUI {
  70367. /**
  70368. * Class used to create slider controls
  70369. */
  70370. export class ImageScrollBar extends BaseSlider {
  70371. name?: string | undefined;
  70372. private _backgroundBaseImage;
  70373. private _backgroundImage;
  70374. private _thumbImage;
  70375. private _thumbBaseImage;
  70376. private _thumbLength;
  70377. private _thumbHeight;
  70378. private _barImageHeight;
  70379. private _tempMeasure;
  70380. /**
  70381. * Gets or sets the image used to render the background for horizontal bar
  70382. */
  70383. get backgroundImage(): Image;
  70384. set backgroundImage(value: Image);
  70385. /**
  70386. * Gets or sets the image used to render the thumb
  70387. */
  70388. get thumbImage(): Image;
  70389. set thumbImage(value: Image);
  70390. /**
  70391. * Gets or sets the length of the thumb
  70392. */
  70393. get thumbLength(): number;
  70394. set thumbLength(value: number);
  70395. /**
  70396. * Gets or sets the height of the thumb
  70397. */
  70398. get thumbHeight(): number;
  70399. set thumbHeight(value: number);
  70400. /**
  70401. * Gets or sets the height of the bar image
  70402. */
  70403. get barImageHeight(): number;
  70404. set barImageHeight(value: number);
  70405. /**
  70406. * Creates a new ImageScrollBar
  70407. * @param name defines the control name
  70408. */
  70409. constructor(name?: string | undefined);
  70410. protected _getTypeName(): string;
  70411. protected _getThumbThickness(): number;
  70412. _draw(context: CanvasRenderingContext2D): void;
  70413. private _first;
  70414. private _originX;
  70415. private _originY;
  70416. /** @hidden */
  70417. protected _updateValueFromPointer(x: number, y: number): void;
  70418. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70419. }
  70420. }
  70421. declare module BABYLON.GUI {
  70422. /**
  70423. * Class used to hold a viewer window and sliders in a grid
  70424. */
  70425. export class ScrollViewer extends Rectangle {
  70426. private _grid;
  70427. private _horizontalBarSpace;
  70428. private _verticalBarSpace;
  70429. private _dragSpace;
  70430. private _horizontalBar;
  70431. private _verticalBar;
  70432. private _barColor;
  70433. private _barBackground;
  70434. private _barImage;
  70435. private _barBackgroundImage;
  70436. private _barSize;
  70437. private _endLeft;
  70438. private _endTop;
  70439. private _window;
  70440. private _pointerIsOver;
  70441. private _wheelPrecision;
  70442. private _onPointerObserver;
  70443. private _clientWidth;
  70444. private _clientHeight;
  70445. private _useImageBar;
  70446. private _thumbLength;
  70447. private _thumbHeight;
  70448. private _barImageHeight;
  70449. /**
  70450. * Gets the horizontal scrollbar
  70451. */
  70452. get horizontalBar(): ScrollBar | ImageScrollBar;
  70453. /**
  70454. * Gets the vertical scrollbar
  70455. */
  70456. get verticalBar(): ScrollBar | ImageScrollBar;
  70457. /**
  70458. * Adds a new control to the current container
  70459. * @param control defines the control to add
  70460. * @returns the current container
  70461. */
  70462. addControl(control: BABYLON.Nullable<Control>): Container;
  70463. /**
  70464. * Removes a control from the current container
  70465. * @param control defines the control to remove
  70466. * @returns the current container
  70467. */
  70468. removeControl(control: Control): Container;
  70469. /** Gets the list of children */
  70470. get children(): Control[];
  70471. _flagDescendantsAsMatrixDirty(): void;
  70472. /**
  70473. * Creates a new ScrollViewer
  70474. * @param name of ScrollViewer
  70475. */
  70476. constructor(name?: string, isImageBased?: boolean);
  70477. /** Reset the scroll viewer window to initial size */
  70478. resetWindow(): void;
  70479. protected _getTypeName(): string;
  70480. private _buildClientSizes;
  70481. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70482. protected _postMeasure(): void;
  70483. /**
  70484. * Gets or sets the mouse wheel precision
  70485. * from 0 to 1 with a default value of 0.05
  70486. * */
  70487. get wheelPrecision(): number;
  70488. set wheelPrecision(value: number);
  70489. /** Gets or sets the scroll bar container background color */
  70490. get scrollBackground(): string;
  70491. set scrollBackground(color: string);
  70492. /** Gets or sets the bar color */
  70493. get barColor(): string;
  70494. set barColor(color: string);
  70495. /** Gets or sets the bar image */
  70496. get thumbImage(): Image;
  70497. set thumbImage(value: Image);
  70498. /** Gets or sets the size of the bar */
  70499. get barSize(): number;
  70500. set barSize(value: number);
  70501. /** Gets or sets the length of the thumb */
  70502. get thumbLength(): number;
  70503. set thumbLength(value: number);
  70504. /** Gets or sets the height of the thumb */
  70505. get thumbHeight(): number;
  70506. set thumbHeight(value: number);
  70507. /** Gets or sets the height of the bar image */
  70508. get barImageHeight(): number;
  70509. set barImageHeight(value: number);
  70510. /** Gets or sets the bar background */
  70511. get barBackground(): string;
  70512. set barBackground(color: string);
  70513. /** Gets or sets the bar background image */
  70514. get barImage(): Image;
  70515. set barImage(value: Image);
  70516. /** @hidden */
  70517. private _updateScroller;
  70518. _link(host: AdvancedDynamicTexture): void;
  70519. /** @hidden */
  70520. private _addBar;
  70521. /** @hidden */
  70522. private _attachWheel;
  70523. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70524. /** Releases associated resources */
  70525. dispose(): void;
  70526. }
  70527. }
  70528. declare module BABYLON.GUI {
  70529. /** Class used to render a grid */
  70530. export class DisplayGrid extends Control {
  70531. name?: string | undefined;
  70532. private _cellWidth;
  70533. private _cellHeight;
  70534. private _minorLineTickness;
  70535. private _minorLineColor;
  70536. private _majorLineTickness;
  70537. private _majorLineColor;
  70538. private _majorLineFrequency;
  70539. private _background;
  70540. private _displayMajorLines;
  70541. private _displayMinorLines;
  70542. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  70543. get displayMinorLines(): boolean;
  70544. set displayMinorLines(value: boolean);
  70545. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  70546. get displayMajorLines(): boolean;
  70547. set displayMajorLines(value: boolean);
  70548. /** Gets or sets background color (Black by default) */
  70549. get background(): string;
  70550. set background(value: string);
  70551. /** Gets or sets the width of each cell (20 by default) */
  70552. get cellWidth(): number;
  70553. set cellWidth(value: number);
  70554. /** Gets or sets the height of each cell (20 by default) */
  70555. get cellHeight(): number;
  70556. set cellHeight(value: number);
  70557. /** Gets or sets the tickness of minor lines (1 by default) */
  70558. get minorLineTickness(): number;
  70559. set minorLineTickness(value: number);
  70560. /** Gets or sets the color of minor lines (DarkGray by default) */
  70561. get minorLineColor(): string;
  70562. set minorLineColor(value: string);
  70563. /** Gets or sets the tickness of major lines (2 by default) */
  70564. get majorLineTickness(): number;
  70565. set majorLineTickness(value: number);
  70566. /** Gets or sets the color of major lines (White by default) */
  70567. get majorLineColor(): string;
  70568. set majorLineColor(value: string);
  70569. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  70570. get majorLineFrequency(): number;
  70571. set majorLineFrequency(value: number);
  70572. /**
  70573. * Creates a new GridDisplayRectangle
  70574. * @param name defines the control name
  70575. */
  70576. constructor(name?: string | undefined);
  70577. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70578. protected _getTypeName(): string;
  70579. }
  70580. }
  70581. declare module BABYLON.GUI {
  70582. /**
  70583. * Class used to create slider controls based on images
  70584. */
  70585. export class ImageBasedSlider extends BaseSlider {
  70586. name?: string | undefined;
  70587. private _backgroundImage;
  70588. private _thumbImage;
  70589. private _valueBarImage;
  70590. private _tempMeasure;
  70591. get displayThumb(): boolean;
  70592. set displayThumb(value: boolean);
  70593. /**
  70594. * Gets or sets the image used to render the background
  70595. */
  70596. get backgroundImage(): Image;
  70597. set backgroundImage(value: Image);
  70598. /**
  70599. * Gets or sets the image used to render the value bar
  70600. */
  70601. get valueBarImage(): Image;
  70602. set valueBarImage(value: Image);
  70603. /**
  70604. * Gets or sets the image used to render the thumb
  70605. */
  70606. get thumbImage(): Image;
  70607. set thumbImage(value: Image);
  70608. /**
  70609. * Creates a new ImageBasedSlider
  70610. * @param name defines the control name
  70611. */
  70612. constructor(name?: string | undefined);
  70613. protected _getTypeName(): string;
  70614. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70615. }
  70616. }
  70617. declare module BABYLON.GUI {
  70618. /**
  70619. * Forcing an export so that this code will execute
  70620. * @hidden
  70621. */
  70622. const name = "Statics";
  70623. }
  70624. declare module BABYLON.GUI {
  70625. /**
  70626. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  70627. */
  70628. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  70629. /**
  70630. * Define the instrumented AdvancedDynamicTexture.
  70631. */
  70632. texture: AdvancedDynamicTexture;
  70633. private _captureRenderTime;
  70634. private _renderTime;
  70635. private _captureLayoutTime;
  70636. private _layoutTime;
  70637. private _onBeginRenderObserver;
  70638. private _onEndRenderObserver;
  70639. private _onBeginLayoutObserver;
  70640. private _onEndLayoutObserver;
  70641. /**
  70642. * Gets the perf counter used to capture render time
  70643. */
  70644. get renderTimeCounter(): BABYLON.PerfCounter;
  70645. /**
  70646. * Gets the perf counter used to capture layout time
  70647. */
  70648. get layoutTimeCounter(): BABYLON.PerfCounter;
  70649. /**
  70650. * Enable or disable the render time capture
  70651. */
  70652. get captureRenderTime(): boolean;
  70653. set captureRenderTime(value: boolean);
  70654. /**
  70655. * Enable or disable the layout time capture
  70656. */
  70657. get captureLayoutTime(): boolean;
  70658. set captureLayoutTime(value: boolean);
  70659. /**
  70660. * Instantiates a new advanced dynamic texture instrumentation.
  70661. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  70662. * @param texture Defines the AdvancedDynamicTexture to instrument
  70663. */
  70664. constructor(
  70665. /**
  70666. * Define the instrumented AdvancedDynamicTexture.
  70667. */
  70668. texture: AdvancedDynamicTexture);
  70669. /**
  70670. * Dispose and release associated resources.
  70671. */
  70672. dispose(): void;
  70673. }
  70674. }
  70675. declare module BABYLON.GUI {
  70676. /**
  70677. * Class used to load GUI via XML.
  70678. */
  70679. export class XmlLoader {
  70680. private _nodes;
  70681. private _nodeTypes;
  70682. private _isLoaded;
  70683. private _objectAttributes;
  70684. private _parentClass;
  70685. /**
  70686. * Create a new xml loader
  70687. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  70688. */
  70689. constructor(parentClass?: null);
  70690. private _getChainElement;
  70691. private _getClassAttribute;
  70692. private _createGuiElement;
  70693. private _parseGrid;
  70694. private _parseElement;
  70695. private _prepareSourceElement;
  70696. private _parseElementsFromSource;
  70697. private _parseXml;
  70698. /**
  70699. * Gets if the loading has finished.
  70700. * @returns whether the loading has finished or not
  70701. */
  70702. isLoaded(): boolean;
  70703. /**
  70704. * Gets a loaded node / control by id.
  70705. * @param id the Controls id set in the xml
  70706. * @returns element of type Control
  70707. */
  70708. getNodeById(id: string): any;
  70709. /**
  70710. * Gets all loaded nodes / controls
  70711. * @returns Array of controls
  70712. */
  70713. getNodes(): any;
  70714. /**
  70715. * Initiates the xml layout loading
  70716. * @param xmlFile defines the xml layout to load
  70717. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  70718. * @param callback defines the callback called on layout load.
  70719. */
  70720. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  70721. }
  70722. }
  70723. declare module BABYLON.GUI {
  70724. /**
  70725. * Class used to create containers for controls
  70726. */
  70727. export class Container3D extends Control3D {
  70728. private _blockLayout;
  70729. /**
  70730. * Gets the list of child controls
  70731. */
  70732. protected _children: Control3D[];
  70733. /**
  70734. * Gets the list of child controls
  70735. */
  70736. get children(): Array<Control3D>;
  70737. /**
  70738. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  70739. * This is helpful to optimize layout operation when adding multiple children in a row
  70740. */
  70741. get blockLayout(): boolean;
  70742. set blockLayout(value: boolean);
  70743. /**
  70744. * Creates a new container
  70745. * @param name defines the container name
  70746. */
  70747. constructor(name?: string);
  70748. /**
  70749. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  70750. * @returns the current container
  70751. */
  70752. updateLayout(): Container3D;
  70753. /**
  70754. * Gets a boolean indicating if the given control is in the children of this control
  70755. * @param control defines the control to check
  70756. * @returns true if the control is in the child list
  70757. */
  70758. containsControl(control: Control3D): boolean;
  70759. /**
  70760. * Adds a control to the children of this control
  70761. * @param control defines the control to add
  70762. * @returns the current container
  70763. */
  70764. addControl(control: Control3D): Container3D;
  70765. /**
  70766. * This function will be called everytime a new control is added
  70767. */
  70768. protected _arrangeChildren(): void;
  70769. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70770. /**
  70771. * Removes a control from the children of this control
  70772. * @param control defines the control to remove
  70773. * @returns the current container
  70774. */
  70775. removeControl(control: Control3D): Container3D;
  70776. protected _getTypeName(): string;
  70777. /**
  70778. * Releases all associated resources
  70779. */
  70780. dispose(): void;
  70781. /** Control rotation will remain unchanged */
  70782. static readonly UNSET_ORIENTATION: number;
  70783. /** Control will rotate to make it look at sphere central axis */
  70784. static readonly FACEORIGIN_ORIENTATION: number;
  70785. /** Control will rotate to make it look back at sphere central axis */
  70786. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  70787. /** Control will rotate to look at z axis (0, 0, 1) */
  70788. static readonly FACEFORWARD_ORIENTATION: number;
  70789. /** Control will rotate to look at negative z axis (0, 0, -1) */
  70790. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  70791. }
  70792. }
  70793. declare module BABYLON.GUI {
  70794. /**
  70795. * Class used to manage 3D user interface
  70796. * @see http://doc.babylonjs.com/how_to/gui3d
  70797. */
  70798. export class GUI3DManager implements BABYLON.IDisposable {
  70799. private _scene;
  70800. private _sceneDisposeObserver;
  70801. private _utilityLayer;
  70802. private _rootContainer;
  70803. private _pointerObserver;
  70804. private _pointerOutObserver;
  70805. /** @hidden */
  70806. _lastPickedControl: Control3D;
  70807. /** @hidden */
  70808. _lastControlOver: {
  70809. [pointerId: number]: Control3D;
  70810. };
  70811. /** @hidden */
  70812. _lastControlDown: {
  70813. [pointerId: number]: Control3D;
  70814. };
  70815. /**
  70816. * BABYLON.Observable raised when the point picked by the pointer events changed
  70817. */
  70818. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70819. /** @hidden */
  70820. _sharedMaterials: {
  70821. [key: string]: BABYLON.Material;
  70822. };
  70823. /** Gets the hosting scene */
  70824. get scene(): BABYLON.Scene;
  70825. /** Gets associated utility layer */
  70826. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70827. /**
  70828. * Creates a new GUI3DManager
  70829. * @param scene
  70830. */
  70831. constructor(scene?: BABYLON.Scene);
  70832. private _handlePointerOut;
  70833. private _doPicking;
  70834. /**
  70835. * Gets the root container
  70836. */
  70837. get rootContainer(): Container3D;
  70838. /**
  70839. * Gets a boolean indicating if the given control is in the root child list
  70840. * @param control defines the control to check
  70841. * @returns true if the control is in the root child list
  70842. */
  70843. containsControl(control: Control3D): boolean;
  70844. /**
  70845. * Adds a control to the root child list
  70846. * @param control defines the control to add
  70847. * @returns the current manager
  70848. */
  70849. addControl(control: Control3D): GUI3DManager;
  70850. /**
  70851. * Removes a control from the root child list
  70852. * @param control defines the control to remove
  70853. * @returns the current container
  70854. */
  70855. removeControl(control: Control3D): GUI3DManager;
  70856. /**
  70857. * Releases all associated resources
  70858. */
  70859. dispose(): void;
  70860. }
  70861. }
  70862. declare module BABYLON.GUI {
  70863. /**
  70864. * Class used to transport BABYLON.Vector3 information for pointer events
  70865. */
  70866. export class Vector3WithInfo extends BABYLON.Vector3 {
  70867. /** defines the current mouse button index */
  70868. buttonIndex: number;
  70869. /**
  70870. * Creates a new Vector3WithInfo
  70871. * @param source defines the vector3 data to transport
  70872. * @param buttonIndex defines the current mouse button index
  70873. */
  70874. constructor(source: BABYLON.Vector3,
  70875. /** defines the current mouse button index */
  70876. buttonIndex?: number);
  70877. }
  70878. }
  70879. declare module BABYLON.GUI {
  70880. /**
  70881. * Class used as base class for controls
  70882. */
  70883. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70884. /** Defines the control name */
  70885. name?: string | undefined;
  70886. /** @hidden */
  70887. _host: GUI3DManager;
  70888. private _node;
  70889. private _downCount;
  70890. private _enterCount;
  70891. private _downPointerIds;
  70892. private _isVisible;
  70893. /** Gets or sets the control position in world space */
  70894. get position(): BABYLON.Vector3;
  70895. set position(value: BABYLON.Vector3);
  70896. /** Gets or sets the control scaling in world space */
  70897. get scaling(): BABYLON.Vector3;
  70898. set scaling(value: BABYLON.Vector3);
  70899. /** Callback used to start pointer enter animation */
  70900. pointerEnterAnimation: () => void;
  70901. /** Callback used to start pointer out animation */
  70902. pointerOutAnimation: () => void;
  70903. /** Callback used to start pointer down animation */
  70904. pointerDownAnimation: () => void;
  70905. /** Callback used to start pointer up animation */
  70906. pointerUpAnimation: () => void;
  70907. /**
  70908. * An event triggered when the pointer move over the control
  70909. */
  70910. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70911. /**
  70912. * An event triggered when the pointer move out of the control
  70913. */
  70914. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70915. /**
  70916. * An event triggered when the pointer taps the control
  70917. */
  70918. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70919. /**
  70920. * An event triggered when pointer is up
  70921. */
  70922. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70923. /**
  70924. * An event triggered when a control is clicked on (with a mouse)
  70925. */
  70926. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70927. /**
  70928. * An event triggered when pointer enters the control
  70929. */
  70930. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70931. /**
  70932. * Gets or sets the parent container
  70933. */
  70934. parent: BABYLON.Nullable<Container3D>;
  70935. private _behaviors;
  70936. /**
  70937. * Gets the list of attached behaviors
  70938. * @see http://doc.babylonjs.com/features/behaviour
  70939. */
  70940. get behaviors(): BABYLON.Behavior<Control3D>[];
  70941. /**
  70942. * Attach a behavior to the control
  70943. * @see http://doc.babylonjs.com/features/behaviour
  70944. * @param behavior defines the behavior to attach
  70945. * @returns the current control
  70946. */
  70947. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70948. /**
  70949. * Remove an attached behavior
  70950. * @see http://doc.babylonjs.com/features/behaviour
  70951. * @param behavior defines the behavior to attach
  70952. * @returns the current control
  70953. */
  70954. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70955. /**
  70956. * Gets an attached behavior by name
  70957. * @param name defines the name of the behavior to look for
  70958. * @see http://doc.babylonjs.com/features/behaviour
  70959. * @returns null if behavior was not found else the requested behavior
  70960. */
  70961. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  70962. /** Gets or sets a boolean indicating if the control is visible */
  70963. get isVisible(): boolean;
  70964. set isVisible(value: boolean);
  70965. /**
  70966. * Creates a new control
  70967. * @param name defines the control name
  70968. */
  70969. constructor(
  70970. /** Defines the control name */
  70971. name?: string | undefined);
  70972. /**
  70973. * Gets a string representing the class name
  70974. */
  70975. get typeName(): string;
  70976. /**
  70977. * Get the current class name of the control.
  70978. * @returns current class name
  70979. */
  70980. getClassName(): string;
  70981. protected _getTypeName(): string;
  70982. /**
  70983. * Gets the transform node used by this control
  70984. */
  70985. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  70986. /**
  70987. * Gets the mesh used to render this control
  70988. */
  70989. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70990. /**
  70991. * Link the control as child of the given node
  70992. * @param node defines the node to link to. Use null to unlink the control
  70993. * @returns the current control
  70994. */
  70995. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  70996. /** @hidden **/
  70997. _prepareNode(scene: BABYLON.Scene): void;
  70998. /**
  70999. * Node creation.
  71000. * Can be overriden by children
  71001. * @param scene defines the scene where the node must be attached
  71002. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  71003. */
  71004. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71005. /**
  71006. * Affect a material to the given mesh
  71007. * @param mesh defines the mesh which will represent the control
  71008. */
  71009. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71010. /** @hidden */
  71011. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71012. /** @hidden */
  71013. _onPointerEnter(target: Control3D): boolean;
  71014. /** @hidden */
  71015. _onPointerOut(target: Control3D): void;
  71016. /** @hidden */
  71017. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71018. /** @hidden */
  71019. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71020. /** @hidden */
  71021. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71022. /** @hidden */
  71023. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71024. /** @hidden */
  71025. _disposeNode(): void;
  71026. /**
  71027. * Releases all associated resources
  71028. */
  71029. dispose(): void;
  71030. }
  71031. }
  71032. declare module BABYLON.GUI {
  71033. /**
  71034. * Class used as a root to all buttons
  71035. */
  71036. export class AbstractButton3D extends Control3D {
  71037. /**
  71038. * Creates a new button
  71039. * @param name defines the control name
  71040. */
  71041. constructor(name?: string);
  71042. protected _getTypeName(): string;
  71043. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71044. }
  71045. }
  71046. declare module BABYLON.GUI {
  71047. /**
  71048. * Class used to create a button in 3D
  71049. */
  71050. export class Button3D extends AbstractButton3D {
  71051. /** @hidden */
  71052. protected _currentMaterial: BABYLON.Material;
  71053. private _facadeTexture;
  71054. private _content;
  71055. private _contentResolution;
  71056. private _contentScaleRatio;
  71057. /**
  71058. * Gets or sets the texture resolution used to render content (512 by default)
  71059. */
  71060. get contentResolution(): BABYLON.int;
  71061. set contentResolution(value: BABYLON.int);
  71062. /**
  71063. * Gets or sets the texture scale ratio used to render content (2 by default)
  71064. */
  71065. get contentScaleRatio(): number;
  71066. set contentScaleRatio(value: number);
  71067. protected _disposeFacadeTexture(): void;
  71068. protected _resetContent(): void;
  71069. /**
  71070. * Creates a new button
  71071. * @param name defines the control name
  71072. */
  71073. constructor(name?: string);
  71074. /**
  71075. * Gets or sets the GUI 2D content used to display the button's facade
  71076. */
  71077. get content(): Control;
  71078. set content(value: Control);
  71079. /**
  71080. * Apply the facade texture (created from the content property).
  71081. * This function can be overloaded by child classes
  71082. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71083. */
  71084. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71085. protected _getTypeName(): string;
  71086. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71087. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71088. /**
  71089. * Releases all associated resources
  71090. */
  71091. dispose(): void;
  71092. }
  71093. }
  71094. declare module BABYLON.GUI {
  71095. /**
  71096. * Abstract class used to create a container panel deployed on the surface of a volume
  71097. */
  71098. export abstract class VolumeBasedPanel extends Container3D {
  71099. private _columns;
  71100. private _rows;
  71101. private _rowThenColum;
  71102. private _orientation;
  71103. protected _cellWidth: number;
  71104. protected _cellHeight: number;
  71105. /**
  71106. * Gets or sets the distance between elements
  71107. */
  71108. margin: number;
  71109. /**
  71110. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71111. * | Value | Type | Description |
  71112. * | ----- | ----------------------------------- | ----------- |
  71113. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71114. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71115. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71116. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71117. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71118. */
  71119. get orientation(): number;
  71120. set orientation(value: number);
  71121. /**
  71122. * Gets or sets the number of columns requested (10 by default).
  71123. * The panel will automatically compute the number of rows based on number of child controls.
  71124. */
  71125. get columns(): BABYLON.int;
  71126. set columns(value: BABYLON.int);
  71127. /**
  71128. * Gets or sets a the number of rows requested.
  71129. * The panel will automatically compute the number of columns based on number of child controls.
  71130. */
  71131. get rows(): BABYLON.int;
  71132. set rows(value: BABYLON.int);
  71133. /**
  71134. * Creates new VolumeBasedPanel
  71135. */
  71136. constructor();
  71137. protected _arrangeChildren(): void;
  71138. /** Child classes must implement this function to provide correct control positioning */
  71139. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71140. /** Child classes can implement this function to provide additional processing */
  71141. protected _finalProcessing(): void;
  71142. }
  71143. }
  71144. declare module BABYLON.GUI {
  71145. /**
  71146. * Class used to create a container panel deployed on the surface of a cylinder
  71147. */
  71148. export class CylinderPanel extends VolumeBasedPanel {
  71149. private _radius;
  71150. /**
  71151. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71152. */
  71153. get radius(): BABYLON.float;
  71154. set radius(value: BABYLON.float);
  71155. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71156. private _cylindricalMapping;
  71157. }
  71158. }
  71159. declare module BABYLON.GUI {
  71160. /** @hidden */
  71161. export var fluentVertexShader: {
  71162. name: string;
  71163. shader: string;
  71164. };
  71165. }
  71166. declare module BABYLON.GUI {
  71167. /** @hidden */
  71168. export var fluentPixelShader: {
  71169. name: string;
  71170. shader: string;
  71171. };
  71172. }
  71173. declare module BABYLON.GUI {
  71174. /** @hidden */
  71175. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71176. INNERGLOW: boolean;
  71177. BORDER: boolean;
  71178. HOVERLIGHT: boolean;
  71179. TEXTURE: boolean;
  71180. constructor();
  71181. }
  71182. /**
  71183. * Class used to render controls with fluent desgin
  71184. */
  71185. export class FluentMaterial extends BABYLON.PushMaterial {
  71186. /**
  71187. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71188. */
  71189. innerGlowColorIntensity: number;
  71190. /**
  71191. * Gets or sets the inner glow color (white by default)
  71192. */
  71193. innerGlowColor: BABYLON.Color3;
  71194. /**
  71195. * Gets or sets alpha value (default is 1.0)
  71196. */
  71197. alpha: number;
  71198. /**
  71199. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71200. */
  71201. albedoColor: BABYLON.Color3;
  71202. /**
  71203. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71204. */
  71205. renderBorders: boolean;
  71206. /**
  71207. * Gets or sets border width (default is 0.5)
  71208. */
  71209. borderWidth: number;
  71210. /**
  71211. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71212. */
  71213. edgeSmoothingValue: number;
  71214. /**
  71215. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71216. */
  71217. borderMinValue: number;
  71218. /**
  71219. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71220. */
  71221. renderHoverLight: boolean;
  71222. /**
  71223. * Gets or sets the radius used to render the hover light (default is 1.0)
  71224. */
  71225. hoverRadius: number;
  71226. /**
  71227. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71228. */
  71229. hoverColor: BABYLON.Color4;
  71230. /**
  71231. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71232. */
  71233. hoverPosition: BABYLON.Vector3;
  71234. private _albedoTexture;
  71235. /** Gets or sets the texture to use for albedo color */
  71236. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71237. /**
  71238. * Creates a new Fluent material
  71239. * @param name defines the name of the material
  71240. * @param scene defines the hosting scene
  71241. */
  71242. constructor(name: string, scene: BABYLON.Scene);
  71243. needAlphaBlending(): boolean;
  71244. needAlphaTesting(): boolean;
  71245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71248. getActiveTextures(): BABYLON.BaseTexture[];
  71249. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71250. dispose(forceDisposeEffect?: boolean): void;
  71251. clone(name: string): FluentMaterial;
  71252. serialize(): any;
  71253. getClassName(): string;
  71254. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  71255. }
  71256. }
  71257. declare module BABYLON.GUI {
  71258. /**
  71259. * Class used to create a holographic button in 3D
  71260. */
  71261. export class HolographicButton extends Button3D {
  71262. private _backPlate;
  71263. private _textPlate;
  71264. private _frontPlate;
  71265. private _text;
  71266. private _imageUrl;
  71267. private _shareMaterials;
  71268. private _frontMaterial;
  71269. private _backMaterial;
  71270. private _plateMaterial;
  71271. private _pickedPointObserver;
  71272. private _tooltipFade;
  71273. private _tooltipTextBlock;
  71274. private _tooltipTexture;
  71275. private _tooltipMesh;
  71276. private _tooltipHoverObserver;
  71277. private _tooltipOutObserver;
  71278. private _disposeTooltip;
  71279. /**
  71280. * Rendering ground id of all the mesh in the button
  71281. */
  71282. set renderingGroupId(id: number);
  71283. get renderingGroupId(): number;
  71284. /**
  71285. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  71286. */
  71287. set tooltipText(text: BABYLON.Nullable<string>);
  71288. get tooltipText(): BABYLON.Nullable<string>;
  71289. /**
  71290. * Gets or sets text for the button
  71291. */
  71292. get text(): string;
  71293. set text(value: string);
  71294. /**
  71295. * Gets or sets the image url for the button
  71296. */
  71297. get imageUrl(): string;
  71298. set imageUrl(value: string);
  71299. /**
  71300. * Gets the back material used by this button
  71301. */
  71302. get backMaterial(): FluentMaterial;
  71303. /**
  71304. * Gets the front material used by this button
  71305. */
  71306. get frontMaterial(): FluentMaterial;
  71307. /**
  71308. * Gets the plate material used by this button
  71309. */
  71310. get plateMaterial(): BABYLON.StandardMaterial;
  71311. /**
  71312. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  71313. */
  71314. get shareMaterials(): boolean;
  71315. /**
  71316. * Creates a new button
  71317. * @param name defines the control name
  71318. */
  71319. constructor(name?: string, shareMaterials?: boolean);
  71320. protected _getTypeName(): string;
  71321. private _rebuildContent;
  71322. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71323. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71324. private _createBackMaterial;
  71325. private _createFrontMaterial;
  71326. private _createPlateMaterial;
  71327. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  71328. /**
  71329. * Releases all associated resources
  71330. */
  71331. dispose(): void;
  71332. }
  71333. }
  71334. declare module BABYLON.GUI {
  71335. /**
  71336. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  71337. */
  71338. export class MeshButton3D extends Button3D {
  71339. /** @hidden */
  71340. protected _currentMesh: BABYLON.Mesh;
  71341. /**
  71342. * Creates a new 3D button based on a mesh
  71343. * @param mesh mesh to become a 3D button
  71344. * @param name defines the control name
  71345. */
  71346. constructor(mesh: BABYLON.Mesh, name?: string);
  71347. protected _getTypeName(): string;
  71348. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71349. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71350. }
  71351. }
  71352. declare module BABYLON.GUI {
  71353. /**
  71354. * Class used to create a container panel deployed on the surface of a plane
  71355. */
  71356. export class PlanePanel extends VolumeBasedPanel {
  71357. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71358. }
  71359. }
  71360. declare module BABYLON.GUI {
  71361. /**
  71362. * Class used to create a container panel where items get randomized planar mapping
  71363. */
  71364. export class ScatterPanel extends VolumeBasedPanel {
  71365. private _iteration;
  71366. /**
  71367. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  71368. */
  71369. get iteration(): BABYLON.float;
  71370. set iteration(value: BABYLON.float);
  71371. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71372. private _scatterMapping;
  71373. protected _finalProcessing(): void;
  71374. }
  71375. }
  71376. declare module BABYLON.GUI {
  71377. /**
  71378. * Class used to create a container panel deployed on the surface of a sphere
  71379. */
  71380. export class SpherePanel extends VolumeBasedPanel {
  71381. private _radius;
  71382. /**
  71383. * Gets or sets the radius of the sphere where to project controls (5 by default)
  71384. */
  71385. get radius(): BABYLON.float;
  71386. set radius(value: BABYLON.float);
  71387. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71388. private _sphericalMapping;
  71389. }
  71390. }
  71391. declare module BABYLON.GUI {
  71392. /**
  71393. * Class used to create a stack panel in 3D on XY plane
  71394. */
  71395. export class StackPanel3D extends Container3D {
  71396. private _isVertical;
  71397. /**
  71398. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  71399. */
  71400. get isVertical(): boolean;
  71401. set isVertical(value: boolean);
  71402. /**
  71403. * Gets or sets the distance between elements
  71404. */
  71405. margin: number;
  71406. /**
  71407. * Creates new StackPanel
  71408. * @param isVertical
  71409. */
  71410. constructor(isVertical?: boolean);
  71411. protected _arrangeChildren(): void;
  71412. }
  71413. }
  71414. declare module BABYLON {
  71415. /**
  71416. * Configuration for glTF validation
  71417. */
  71418. export interface IGLTFValidationConfiguration {
  71419. /**
  71420. * The url of the glTF validator.
  71421. */
  71422. url: string;
  71423. }
  71424. /**
  71425. * glTF validation
  71426. */
  71427. export class GLTFValidation {
  71428. /**
  71429. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  71430. */
  71431. static Configuration: IGLTFValidationConfiguration;
  71432. private static _LoadScriptPromise;
  71433. /**
  71434. * Validate a glTF asset using the glTF-Validator.
  71435. * @param data The JSON of a glTF or the array buffer of a binary glTF
  71436. * @param rootUrl The root url for the glTF
  71437. * @param fileName The file name for the glTF
  71438. * @param getExternalResource The callback to get external resources for the glTF validator
  71439. * @returns A promise that resolves with the glTF validation results once complete
  71440. */
  71441. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  71442. }
  71443. }
  71444. declare module BABYLON {
  71445. /**
  71446. * Mode that determines the coordinate system to use.
  71447. */
  71448. export enum GLTFLoaderCoordinateSystemMode {
  71449. /**
  71450. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  71451. */
  71452. AUTO = 0,
  71453. /**
  71454. * Sets the useRightHandedSystem flag on the scene.
  71455. */
  71456. FORCE_RIGHT_HANDED = 1
  71457. }
  71458. /**
  71459. * Mode that determines what animations will start.
  71460. */
  71461. export enum GLTFLoaderAnimationStartMode {
  71462. /**
  71463. * No animation will start.
  71464. */
  71465. NONE = 0,
  71466. /**
  71467. * The first animation will start.
  71468. */
  71469. FIRST = 1,
  71470. /**
  71471. * All animations will start.
  71472. */
  71473. ALL = 2
  71474. }
  71475. /**
  71476. * Interface that contains the data for the glTF asset.
  71477. */
  71478. export interface IGLTFLoaderData {
  71479. /**
  71480. * The object that represents the glTF JSON.
  71481. */
  71482. json: Object;
  71483. /**
  71484. * The BIN chunk of a binary glTF.
  71485. */
  71486. bin: Nullable<IDataBuffer>;
  71487. }
  71488. /**
  71489. * Interface for extending the loader.
  71490. */
  71491. export interface IGLTFLoaderExtension {
  71492. /**
  71493. * The name of this extension.
  71494. */
  71495. readonly name: string;
  71496. /**
  71497. * Defines whether this extension is enabled.
  71498. */
  71499. enabled: boolean;
  71500. /**
  71501. * Defines the order of this extension.
  71502. * The loader sorts the extensions using these values when loading.
  71503. */
  71504. order?: number;
  71505. }
  71506. /**
  71507. * Loader state.
  71508. */
  71509. export enum GLTFLoaderState {
  71510. /**
  71511. * The asset is loading.
  71512. */
  71513. LOADING = 0,
  71514. /**
  71515. * The asset is ready for rendering.
  71516. */
  71517. READY = 1,
  71518. /**
  71519. * The asset is completely loaded.
  71520. */
  71521. COMPLETE = 2
  71522. }
  71523. /** @hidden */
  71524. export interface IGLTFLoader extends IDisposable {
  71525. readonly state: Nullable<GLTFLoaderState>;
  71526. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  71527. meshes: AbstractMesh[];
  71528. particleSystems: IParticleSystem[];
  71529. skeletons: Skeleton[];
  71530. animationGroups: AnimationGroup[];
  71531. }>;
  71532. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  71533. }
  71534. /**
  71535. * File loader for loading glTF files into a scene.
  71536. */
  71537. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71538. /** @hidden */
  71539. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71540. /** @hidden */
  71541. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71542. /**
  71543. * Raised when the asset has been parsed
  71544. */
  71545. onParsedObservable: Observable<IGLTFLoaderData>;
  71546. private _onParsedObserver;
  71547. /**
  71548. * Raised when the asset has been parsed
  71549. */
  71550. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  71551. /**
  71552. * 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.
  71553. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  71554. * Defaults to true.
  71555. * @hidden
  71556. */
  71557. static IncrementalLoading: boolean;
  71558. /**
  71559. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  71560. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  71561. * @hidden
  71562. */
  71563. static HomogeneousCoordinates: boolean;
  71564. /**
  71565. * The coordinate system mode. Defaults to AUTO.
  71566. */
  71567. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  71568. /**
  71569. * The animation start mode. Defaults to FIRST.
  71570. */
  71571. animationStartMode: GLTFLoaderAnimationStartMode;
  71572. /**
  71573. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  71574. */
  71575. compileMaterials: boolean;
  71576. /**
  71577. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  71578. */
  71579. useClipPlane: boolean;
  71580. /**
  71581. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  71582. */
  71583. compileShadowGenerators: boolean;
  71584. /**
  71585. * Defines if the Alpha blended materials are only applied as coverage.
  71586. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  71587. * If true, no extra effects are applied to transparent pixels.
  71588. */
  71589. transparencyAsCoverage: boolean;
  71590. /**
  71591. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  71592. * Enabling will disable offline support and glTF validator.
  71593. * Defaults to false.
  71594. */
  71595. useRangeRequests: boolean;
  71596. /**
  71597. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  71598. */
  71599. createInstances: boolean;
  71600. /**
  71601. * Function called before loading a url referenced by the asset.
  71602. */
  71603. preprocessUrlAsync: (url: string) => Promise<string>;
  71604. /**
  71605. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71606. */
  71607. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  71608. private _onMeshLoadedObserver;
  71609. /**
  71610. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71611. */
  71612. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  71613. /**
  71614. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  71615. */
  71616. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  71617. private _onTextureLoadedObserver;
  71618. /**
  71619. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  71620. */
  71621. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  71622. /**
  71623. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  71624. */
  71625. readonly onMaterialLoadedObservable: Observable<Material>;
  71626. private _onMaterialLoadedObserver;
  71627. /**
  71628. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  71629. */
  71630. set onMaterialLoaded(callback: (material: Material) => void);
  71631. /**
  71632. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  71633. */
  71634. readonly onCameraLoadedObservable: Observable<Camera>;
  71635. private _onCameraLoadedObserver;
  71636. /**
  71637. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  71638. */
  71639. set onCameraLoaded(callback: (camera: Camera) => void);
  71640. /**
  71641. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  71642. * For assets with LODs, raised when all of the LODs are complete.
  71643. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71644. */
  71645. readonly onCompleteObservable: Observable<void>;
  71646. private _onCompleteObserver;
  71647. /**
  71648. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  71649. * For assets with LODs, raised when all of the LODs are complete.
  71650. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71651. */
  71652. set onComplete(callback: () => void);
  71653. /**
  71654. * Observable raised when an error occurs.
  71655. */
  71656. readonly onErrorObservable: Observable<any>;
  71657. private _onErrorObserver;
  71658. /**
  71659. * Callback raised when an error occurs.
  71660. */
  71661. set onError(callback: (reason: any) => void);
  71662. /**
  71663. * Observable raised after the loader is disposed.
  71664. */
  71665. readonly onDisposeObservable: Observable<void>;
  71666. private _onDisposeObserver;
  71667. /**
  71668. * Callback raised after the loader is disposed.
  71669. */
  71670. set onDispose(callback: () => void);
  71671. /**
  71672. * Observable raised after a loader extension is created.
  71673. * Set additional options for a loader extension in this event.
  71674. */
  71675. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  71676. private _onExtensionLoadedObserver;
  71677. /**
  71678. * Callback raised after a loader extension is created.
  71679. */
  71680. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  71681. /**
  71682. * Defines if the loader logging is enabled.
  71683. */
  71684. get loggingEnabled(): boolean;
  71685. set loggingEnabled(value: boolean);
  71686. /**
  71687. * Defines if the loader should capture performance counters.
  71688. */
  71689. get capturePerformanceCounters(): boolean;
  71690. set capturePerformanceCounters(value: boolean);
  71691. /**
  71692. * Defines if the loader should validate the asset.
  71693. */
  71694. validate: boolean;
  71695. /**
  71696. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  71697. */
  71698. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  71699. private _onValidatedObserver;
  71700. /**
  71701. * Callback raised after a loader extension is created.
  71702. */
  71703. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  71704. private _loader;
  71705. /**
  71706. * Name of the loader ("gltf")
  71707. */
  71708. name: string;
  71709. /** @hidden */
  71710. extensions: ISceneLoaderPluginExtensions;
  71711. /**
  71712. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  71713. */
  71714. dispose(): void;
  71715. /** @hidden */
  71716. _clear(): void;
  71717. /** @hidden */
  71718. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71719. /** @hidden */
  71720. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71721. /** @hidden */
  71722. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71723. meshes: AbstractMesh[];
  71724. particleSystems: IParticleSystem[];
  71725. skeletons: Skeleton[];
  71726. animationGroups: AnimationGroup[];
  71727. }>;
  71728. /** @hidden */
  71729. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71730. /** @hidden */
  71731. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71732. /** @hidden */
  71733. canDirectLoad(data: string): boolean;
  71734. /** @hidden */
  71735. directLoad(scene: Scene, data: string): any;
  71736. /**
  71737. * The callback that allows custom handling of the root url based on the response url.
  71738. * @param rootUrl the original root url
  71739. * @param responseURL the response url if available
  71740. * @returns the new root url
  71741. */
  71742. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  71743. /** @hidden */
  71744. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  71745. /**
  71746. * The loader state or null if the loader is not active.
  71747. */
  71748. get loaderState(): Nullable<GLTFLoaderState>;
  71749. /**
  71750. * Returns a promise that resolves when the asset is completely loaded.
  71751. * @returns a promise that resolves when the asset is completely loaded.
  71752. */
  71753. whenCompleteAsync(): Promise<void>;
  71754. private _validate;
  71755. private _getLoader;
  71756. private _parseJson;
  71757. private _unpackBinaryAsync;
  71758. private _unpackBinaryV1Async;
  71759. private _unpackBinaryV2Async;
  71760. private static _parseVersion;
  71761. private static _compareVersion;
  71762. private static readonly _logSpaces;
  71763. private _logIndentLevel;
  71764. private _loggingEnabled;
  71765. /** @hidden */
  71766. _log: (message: string) => void;
  71767. /** @hidden */
  71768. _logOpen(message: string): void;
  71769. /** @hidden */
  71770. _logClose(): void;
  71771. private _logEnabled;
  71772. private _logDisabled;
  71773. private _capturePerformanceCounters;
  71774. /** @hidden */
  71775. _startPerformanceCounter: (counterName: string) => void;
  71776. /** @hidden */
  71777. _endPerformanceCounter: (counterName: string) => void;
  71778. private _startPerformanceCounterEnabled;
  71779. private _startPerformanceCounterDisabled;
  71780. private _endPerformanceCounterEnabled;
  71781. private _endPerformanceCounterDisabled;
  71782. }
  71783. }
  71784. declare module BABYLON.GLTF1 {
  71785. /**
  71786. * Enums
  71787. * @hidden
  71788. */
  71789. export enum EComponentType {
  71790. BYTE = 5120,
  71791. UNSIGNED_BYTE = 5121,
  71792. SHORT = 5122,
  71793. UNSIGNED_SHORT = 5123,
  71794. FLOAT = 5126
  71795. }
  71796. /** @hidden */
  71797. export enum EShaderType {
  71798. FRAGMENT = 35632,
  71799. VERTEX = 35633
  71800. }
  71801. /** @hidden */
  71802. export enum EParameterType {
  71803. BYTE = 5120,
  71804. UNSIGNED_BYTE = 5121,
  71805. SHORT = 5122,
  71806. UNSIGNED_SHORT = 5123,
  71807. INT = 5124,
  71808. UNSIGNED_INT = 5125,
  71809. FLOAT = 5126,
  71810. FLOAT_VEC2 = 35664,
  71811. FLOAT_VEC3 = 35665,
  71812. FLOAT_VEC4 = 35666,
  71813. INT_VEC2 = 35667,
  71814. INT_VEC3 = 35668,
  71815. INT_VEC4 = 35669,
  71816. BOOL = 35670,
  71817. BOOL_VEC2 = 35671,
  71818. BOOL_VEC3 = 35672,
  71819. BOOL_VEC4 = 35673,
  71820. FLOAT_MAT2 = 35674,
  71821. FLOAT_MAT3 = 35675,
  71822. FLOAT_MAT4 = 35676,
  71823. SAMPLER_2D = 35678
  71824. }
  71825. /** @hidden */
  71826. export enum ETextureWrapMode {
  71827. CLAMP_TO_EDGE = 33071,
  71828. MIRRORED_REPEAT = 33648,
  71829. REPEAT = 10497
  71830. }
  71831. /** @hidden */
  71832. export enum ETextureFilterType {
  71833. NEAREST = 9728,
  71834. LINEAR = 9728,
  71835. NEAREST_MIPMAP_NEAREST = 9984,
  71836. LINEAR_MIPMAP_NEAREST = 9985,
  71837. NEAREST_MIPMAP_LINEAR = 9986,
  71838. LINEAR_MIPMAP_LINEAR = 9987
  71839. }
  71840. /** @hidden */
  71841. export enum ETextureFormat {
  71842. ALPHA = 6406,
  71843. RGB = 6407,
  71844. RGBA = 6408,
  71845. LUMINANCE = 6409,
  71846. LUMINANCE_ALPHA = 6410
  71847. }
  71848. /** @hidden */
  71849. export enum ECullingType {
  71850. FRONT = 1028,
  71851. BACK = 1029,
  71852. FRONT_AND_BACK = 1032
  71853. }
  71854. /** @hidden */
  71855. export enum EBlendingFunction {
  71856. ZERO = 0,
  71857. ONE = 1,
  71858. SRC_COLOR = 768,
  71859. ONE_MINUS_SRC_COLOR = 769,
  71860. DST_COLOR = 774,
  71861. ONE_MINUS_DST_COLOR = 775,
  71862. SRC_ALPHA = 770,
  71863. ONE_MINUS_SRC_ALPHA = 771,
  71864. DST_ALPHA = 772,
  71865. ONE_MINUS_DST_ALPHA = 773,
  71866. CONSTANT_COLOR = 32769,
  71867. ONE_MINUS_CONSTANT_COLOR = 32770,
  71868. CONSTANT_ALPHA = 32771,
  71869. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71870. SRC_ALPHA_SATURATE = 776
  71871. }
  71872. /** @hidden */
  71873. export interface IGLTFProperty {
  71874. extensions?: {
  71875. [key: string]: any;
  71876. };
  71877. extras?: Object;
  71878. }
  71879. /** @hidden */
  71880. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71881. name?: string;
  71882. }
  71883. /** @hidden */
  71884. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71885. bufferView: string;
  71886. byteOffset: number;
  71887. byteStride: number;
  71888. count: number;
  71889. type: string;
  71890. componentType: EComponentType;
  71891. max?: number[];
  71892. min?: number[];
  71893. name?: string;
  71894. }
  71895. /** @hidden */
  71896. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71897. buffer: string;
  71898. byteOffset: number;
  71899. byteLength: number;
  71900. byteStride: number;
  71901. target?: number;
  71902. }
  71903. /** @hidden */
  71904. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71905. uri: string;
  71906. byteLength?: number;
  71907. type?: string;
  71908. }
  71909. /** @hidden */
  71910. export interface IGLTFShader extends IGLTFChildRootProperty {
  71911. uri: string;
  71912. type: EShaderType;
  71913. }
  71914. /** @hidden */
  71915. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71916. attributes: string[];
  71917. fragmentShader: string;
  71918. vertexShader: string;
  71919. }
  71920. /** @hidden */
  71921. export interface IGLTFTechniqueParameter {
  71922. type: number;
  71923. count?: number;
  71924. semantic?: string;
  71925. node?: string;
  71926. value?: number | boolean | string | Array<any>;
  71927. source?: string;
  71928. babylonValue?: any;
  71929. }
  71930. /** @hidden */
  71931. export interface IGLTFTechniqueCommonProfile {
  71932. lightingModel: string;
  71933. texcoordBindings: Object;
  71934. parameters?: Array<any>;
  71935. }
  71936. /** @hidden */
  71937. export interface IGLTFTechniqueStatesFunctions {
  71938. blendColor?: number[];
  71939. blendEquationSeparate?: number[];
  71940. blendFuncSeparate?: number[];
  71941. colorMask: boolean[];
  71942. cullFace: number[];
  71943. }
  71944. /** @hidden */
  71945. export interface IGLTFTechniqueStates {
  71946. enable: number[];
  71947. functions: IGLTFTechniqueStatesFunctions;
  71948. }
  71949. /** @hidden */
  71950. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  71951. parameters: {
  71952. [key: string]: IGLTFTechniqueParameter;
  71953. };
  71954. program: string;
  71955. attributes: {
  71956. [key: string]: string;
  71957. };
  71958. uniforms: {
  71959. [key: string]: string;
  71960. };
  71961. states: IGLTFTechniqueStates;
  71962. }
  71963. /** @hidden */
  71964. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  71965. technique?: string;
  71966. values: string[];
  71967. }
  71968. /** @hidden */
  71969. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  71970. attributes: {
  71971. [key: string]: string;
  71972. };
  71973. indices: string;
  71974. material: string;
  71975. mode?: number;
  71976. }
  71977. /** @hidden */
  71978. export interface IGLTFMesh extends IGLTFChildRootProperty {
  71979. primitives: IGLTFMeshPrimitive[];
  71980. }
  71981. /** @hidden */
  71982. export interface IGLTFImage extends IGLTFChildRootProperty {
  71983. uri: string;
  71984. }
  71985. /** @hidden */
  71986. export interface IGLTFSampler extends IGLTFChildRootProperty {
  71987. magFilter?: number;
  71988. minFilter?: number;
  71989. wrapS?: number;
  71990. wrapT?: number;
  71991. }
  71992. /** @hidden */
  71993. export interface IGLTFTexture extends IGLTFChildRootProperty {
  71994. sampler: string;
  71995. source: string;
  71996. format?: ETextureFormat;
  71997. internalFormat?: ETextureFormat;
  71998. target?: number;
  71999. type?: number;
  72000. babylonTexture?: Texture;
  72001. }
  72002. /** @hidden */
  72003. export interface IGLTFAmbienLight {
  72004. color?: number[];
  72005. }
  72006. /** @hidden */
  72007. export interface IGLTFDirectionalLight {
  72008. color?: number[];
  72009. }
  72010. /** @hidden */
  72011. export interface IGLTFPointLight {
  72012. color?: number[];
  72013. constantAttenuation?: number;
  72014. linearAttenuation?: number;
  72015. quadraticAttenuation?: number;
  72016. }
  72017. /** @hidden */
  72018. export interface IGLTFSpotLight {
  72019. color?: number[];
  72020. constantAttenuation?: number;
  72021. fallOfAngle?: number;
  72022. fallOffExponent?: number;
  72023. linearAttenuation?: number;
  72024. quadraticAttenuation?: number;
  72025. }
  72026. /** @hidden */
  72027. export interface IGLTFLight extends IGLTFChildRootProperty {
  72028. type: string;
  72029. }
  72030. /** @hidden */
  72031. export interface IGLTFCameraOrthographic {
  72032. xmag: number;
  72033. ymag: number;
  72034. zfar: number;
  72035. znear: number;
  72036. }
  72037. /** @hidden */
  72038. export interface IGLTFCameraPerspective {
  72039. aspectRatio: number;
  72040. yfov: number;
  72041. zfar: number;
  72042. znear: number;
  72043. }
  72044. /** @hidden */
  72045. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72046. type: string;
  72047. }
  72048. /** @hidden */
  72049. export interface IGLTFAnimationChannelTarget {
  72050. id: string;
  72051. path: string;
  72052. }
  72053. /** @hidden */
  72054. export interface IGLTFAnimationChannel {
  72055. sampler: string;
  72056. target: IGLTFAnimationChannelTarget;
  72057. }
  72058. /** @hidden */
  72059. export interface IGLTFAnimationSampler {
  72060. input: string;
  72061. output: string;
  72062. interpolation?: string;
  72063. }
  72064. /** @hidden */
  72065. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72066. channels?: IGLTFAnimationChannel[];
  72067. parameters?: {
  72068. [key: string]: string;
  72069. };
  72070. samplers?: {
  72071. [key: string]: IGLTFAnimationSampler;
  72072. };
  72073. }
  72074. /** @hidden */
  72075. export interface IGLTFNodeInstanceSkin {
  72076. skeletons: string[];
  72077. skin: string;
  72078. meshes: string[];
  72079. }
  72080. /** @hidden */
  72081. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72082. bindShapeMatrix: number[];
  72083. inverseBindMatrices: string;
  72084. jointNames: string[];
  72085. babylonSkeleton?: Skeleton;
  72086. }
  72087. /** @hidden */
  72088. export interface IGLTFNode extends IGLTFChildRootProperty {
  72089. camera?: string;
  72090. children: string[];
  72091. skin?: string;
  72092. jointName?: string;
  72093. light?: string;
  72094. matrix: number[];
  72095. mesh?: string;
  72096. meshes?: string[];
  72097. rotation?: number[];
  72098. scale?: number[];
  72099. translation?: number[];
  72100. babylonNode?: Node;
  72101. }
  72102. /** @hidden */
  72103. export interface IGLTFScene extends IGLTFChildRootProperty {
  72104. nodes: string[];
  72105. }
  72106. /** @hidden */
  72107. export interface IGLTFRuntime {
  72108. extensions: {
  72109. [key: string]: any;
  72110. };
  72111. accessors: {
  72112. [key: string]: IGLTFAccessor;
  72113. };
  72114. buffers: {
  72115. [key: string]: IGLTFBuffer;
  72116. };
  72117. bufferViews: {
  72118. [key: string]: IGLTFBufferView;
  72119. };
  72120. meshes: {
  72121. [key: string]: IGLTFMesh;
  72122. };
  72123. lights: {
  72124. [key: string]: IGLTFLight;
  72125. };
  72126. cameras: {
  72127. [key: string]: IGLTFCamera;
  72128. };
  72129. nodes: {
  72130. [key: string]: IGLTFNode;
  72131. };
  72132. images: {
  72133. [key: string]: IGLTFImage;
  72134. };
  72135. textures: {
  72136. [key: string]: IGLTFTexture;
  72137. };
  72138. shaders: {
  72139. [key: string]: IGLTFShader;
  72140. };
  72141. programs: {
  72142. [key: string]: IGLTFProgram;
  72143. };
  72144. samplers: {
  72145. [key: string]: IGLTFSampler;
  72146. };
  72147. techniques: {
  72148. [key: string]: IGLTFTechnique;
  72149. };
  72150. materials: {
  72151. [key: string]: IGLTFMaterial;
  72152. };
  72153. animations: {
  72154. [key: string]: IGLTFAnimation;
  72155. };
  72156. skins: {
  72157. [key: string]: IGLTFSkins;
  72158. };
  72159. currentScene?: Object;
  72160. scenes: {
  72161. [key: string]: IGLTFScene;
  72162. };
  72163. extensionsUsed: string[];
  72164. extensionsRequired?: string[];
  72165. buffersCount: number;
  72166. shaderscount: number;
  72167. scene: Scene;
  72168. rootUrl: string;
  72169. loadedBufferCount: number;
  72170. loadedBufferViews: {
  72171. [name: string]: ArrayBufferView;
  72172. };
  72173. loadedShaderCount: number;
  72174. importOnlyMeshes: boolean;
  72175. importMeshesNames?: string[];
  72176. dummyNodes: Node[];
  72177. }
  72178. /** @hidden */
  72179. export interface INodeToRoot {
  72180. bone: Bone;
  72181. node: IGLTFNode;
  72182. id: string;
  72183. }
  72184. /** @hidden */
  72185. export interface IJointNode {
  72186. node: IGLTFNode;
  72187. id: string;
  72188. }
  72189. }
  72190. declare module BABYLON.GLTF1 {
  72191. /**
  72192. * Utils functions for GLTF
  72193. * @hidden
  72194. */
  72195. export class GLTFUtils {
  72196. /**
  72197. * Sets the given "parameter" matrix
  72198. * @param scene: the Scene object
  72199. * @param source: the source node where to pick the matrix
  72200. * @param parameter: the GLTF technique parameter
  72201. * @param uniformName: the name of the shader's uniform
  72202. * @param shaderMaterial: the shader material
  72203. */
  72204. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72205. /**
  72206. * Sets the given "parameter" matrix
  72207. * @param shaderMaterial: the shader material
  72208. * @param uniform: the name of the shader's uniform
  72209. * @param value: the value of the uniform
  72210. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72211. */
  72212. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72213. /**
  72214. * Returns the wrap mode of the texture
  72215. * @param mode: the mode value
  72216. */
  72217. static GetWrapMode(mode: number): number;
  72218. /**
  72219. * Returns the byte stride giving an accessor
  72220. * @param accessor: the GLTF accessor objet
  72221. */
  72222. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72223. /**
  72224. * Returns the texture filter mode giving a mode value
  72225. * @param mode: the filter mode value
  72226. */
  72227. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72228. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72229. /**
  72230. * Returns a buffer from its accessor
  72231. * @param gltfRuntime: the GLTF runtime
  72232. * @param accessor: the GLTF accessor
  72233. */
  72234. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  72235. /**
  72236. * Decodes a buffer view into a string
  72237. * @param view: the buffer view
  72238. */
  72239. static DecodeBufferToText(view: ArrayBufferView): string;
  72240. /**
  72241. * Returns the default material of gltf. Related to
  72242. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  72243. * @param scene: the Babylon.js scene
  72244. */
  72245. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  72246. private static _DefaultMaterial;
  72247. }
  72248. }
  72249. declare module BABYLON.GLTF1 {
  72250. /**
  72251. * Implementation of the base glTF spec
  72252. * @hidden
  72253. */
  72254. export class GLTFLoaderBase {
  72255. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  72256. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72257. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  72258. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72259. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  72260. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72261. }
  72262. /**
  72263. * glTF V1 Loader
  72264. * @hidden
  72265. */
  72266. export class GLTFLoader implements IGLTFLoader {
  72267. static Extensions: {
  72268. [name: string]: GLTFLoaderExtension;
  72269. };
  72270. static RegisterExtension(extension: GLTFLoaderExtension): void;
  72271. state: Nullable<GLTFLoaderState>;
  72272. dispose(): void;
  72273. private _importMeshAsync;
  72274. /**
  72275. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  72276. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72277. * @param scene the scene the meshes should be added to
  72278. * @param data gltf data containing information of the meshes in a loaded file
  72279. * @param rootUrl root url to load from
  72280. * @param onProgress event that fires when loading progress has occured
  72281. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72282. */
  72283. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  72284. meshes: AbstractMesh[];
  72285. particleSystems: IParticleSystem[];
  72286. skeletons: Skeleton[];
  72287. animationGroups: AnimationGroup[];
  72288. }>;
  72289. private _loadAsync;
  72290. /**
  72291. * Imports all objects from a loaded gltf file and adds them to the scene
  72292. * @param scene the scene the objects should be added to
  72293. * @param data gltf data containing information of the meshes in a loaded file
  72294. * @param rootUrl root url to load from
  72295. * @param onProgress event that fires when loading progress has occured
  72296. * @returns a promise which completes when objects have been loaded to the scene
  72297. */
  72298. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  72299. private _loadShadersAsync;
  72300. private _loadBuffersAsync;
  72301. private _createNodes;
  72302. }
  72303. /** @hidden */
  72304. export abstract class GLTFLoaderExtension {
  72305. private _name;
  72306. constructor(name: string);
  72307. get name(): string;
  72308. /**
  72309. * Defines an override for loading the runtime
  72310. * Return true to stop further extensions from loading the runtime
  72311. */
  72312. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  72313. /**
  72314. * Defines an onverride for creating gltf runtime
  72315. * Return true to stop further extensions from creating the runtime
  72316. */
  72317. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  72318. /**
  72319. * Defines an override for loading buffers
  72320. * Return true to stop further extensions from loading this buffer
  72321. */
  72322. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  72323. /**
  72324. * Defines an override for loading texture buffers
  72325. * Return true to stop further extensions from loading this texture data
  72326. */
  72327. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72328. /**
  72329. * Defines an override for creating textures
  72330. * Return true to stop further extensions from loading this texture
  72331. */
  72332. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  72333. /**
  72334. * Defines an override for loading shader strings
  72335. * Return true to stop further extensions from loading this shader data
  72336. */
  72337. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72338. /**
  72339. * Defines an override for loading materials
  72340. * Return true to stop further extensions from loading this material
  72341. */
  72342. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72343. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  72344. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  72345. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72346. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72347. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  72348. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72349. private static LoadTextureBufferAsync;
  72350. private static CreateTextureAsync;
  72351. private static ApplyExtensions;
  72352. }
  72353. }
  72354. declare module BABYLON.GLTF1 {
  72355. /** @hidden */
  72356. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  72357. private _bin;
  72358. constructor();
  72359. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  72360. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72361. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72362. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72363. }
  72364. }
  72365. declare module BABYLON.GLTF1 {
  72366. /** @hidden */
  72367. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  72368. constructor();
  72369. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  72370. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72371. private _loadTexture;
  72372. }
  72373. }
  72374. declare module BABYLON.GLTF2.Loader {
  72375. /**
  72376. * Loader interface with an index field.
  72377. */
  72378. export interface IArrayItem {
  72379. /**
  72380. * The index of this item in the array.
  72381. */
  72382. index: number;
  72383. }
  72384. /**
  72385. * Loader interface with additional members.
  72386. */
  72387. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  72388. /** @hidden */
  72389. _data?: Promise<ArrayBufferView>;
  72390. /** @hidden */
  72391. _babylonVertexBuffer?: Promise<VertexBuffer>;
  72392. }
  72393. /**
  72394. * Loader interface with additional members.
  72395. */
  72396. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  72397. }
  72398. /** @hidden */
  72399. export interface _IAnimationSamplerData {
  72400. input: Float32Array;
  72401. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  72402. output: Float32Array;
  72403. }
  72404. /**
  72405. * Loader interface with additional members.
  72406. */
  72407. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  72408. /** @hidden */
  72409. _data?: Promise<_IAnimationSamplerData>;
  72410. }
  72411. /**
  72412. * Loader interface with additional members.
  72413. */
  72414. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  72415. channels: IAnimationChannel[];
  72416. samplers: IAnimationSampler[];
  72417. /** @hidden */
  72418. _babylonAnimationGroup?: AnimationGroup;
  72419. }
  72420. /**
  72421. * Loader interface with additional members.
  72422. */
  72423. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  72424. /** @hidden */
  72425. _data?: Promise<ArrayBufferView>;
  72426. }
  72427. /**
  72428. * Loader interface with additional members.
  72429. */
  72430. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  72431. /** @hidden */
  72432. _data?: Promise<ArrayBufferView>;
  72433. /** @hidden */
  72434. _babylonBuffer?: Promise<Buffer>;
  72435. }
  72436. /**
  72437. * Loader interface with additional members.
  72438. */
  72439. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  72440. }
  72441. /**
  72442. * Loader interface with additional members.
  72443. */
  72444. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  72445. /** @hidden */
  72446. _data?: Promise<ArrayBufferView>;
  72447. }
  72448. /**
  72449. * Loader interface with additional members.
  72450. */
  72451. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  72452. }
  72453. /**
  72454. * Loader interface with additional members.
  72455. */
  72456. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  72457. }
  72458. /**
  72459. * Loader interface with additional members.
  72460. */
  72461. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  72462. baseColorTexture?: ITextureInfo;
  72463. metallicRoughnessTexture?: ITextureInfo;
  72464. }
  72465. /**
  72466. * Loader interface with additional members.
  72467. */
  72468. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  72469. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72470. normalTexture?: IMaterialNormalTextureInfo;
  72471. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72472. emissiveTexture?: ITextureInfo;
  72473. /** @hidden */
  72474. _data?: {
  72475. [babylonDrawMode: number]: {
  72476. babylonMaterial: Material;
  72477. babylonMeshes: AbstractMesh[];
  72478. promise: Promise<void>;
  72479. };
  72480. };
  72481. }
  72482. /**
  72483. * Loader interface with additional members.
  72484. */
  72485. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  72486. primitives: IMeshPrimitive[];
  72487. }
  72488. /**
  72489. * Loader interface with additional members.
  72490. */
  72491. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  72492. /** @hidden */
  72493. _instanceData?: {
  72494. babylonSourceMesh: Mesh;
  72495. promise: Promise<any>;
  72496. };
  72497. }
  72498. /**
  72499. * Loader interface with additional members.
  72500. */
  72501. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  72502. /**
  72503. * The parent glTF node.
  72504. */
  72505. parent?: INode;
  72506. /** @hidden */
  72507. _babylonTransformNode?: TransformNode;
  72508. /** @hidden */
  72509. _primitiveBabylonMeshes?: AbstractMesh[];
  72510. /** @hidden */
  72511. _babylonBones?: Bone[];
  72512. /** @hidden */
  72513. _numMorphTargets?: number;
  72514. }
  72515. /** @hidden */
  72516. export interface _ISamplerData {
  72517. noMipMaps: boolean;
  72518. samplingMode: number;
  72519. wrapU: number;
  72520. wrapV: number;
  72521. }
  72522. /**
  72523. * Loader interface with additional members.
  72524. */
  72525. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  72526. /** @hidden */
  72527. _data?: _ISamplerData;
  72528. }
  72529. /**
  72530. * Loader interface with additional members.
  72531. */
  72532. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  72533. }
  72534. /**
  72535. * Loader interface with additional members.
  72536. */
  72537. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  72538. /** @hidden */
  72539. _data?: {
  72540. babylonSkeleton: Skeleton;
  72541. promise: Promise<void>;
  72542. };
  72543. }
  72544. /**
  72545. * Loader interface with additional members.
  72546. */
  72547. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  72548. }
  72549. /**
  72550. * Loader interface with additional members.
  72551. */
  72552. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  72553. }
  72554. /**
  72555. * Loader interface with additional members.
  72556. */
  72557. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  72558. accessors?: IAccessor[];
  72559. animations?: IAnimation[];
  72560. buffers?: IBuffer[];
  72561. bufferViews?: IBufferView[];
  72562. cameras?: ICamera[];
  72563. images?: IImage[];
  72564. materials?: IMaterial[];
  72565. meshes?: IMesh[];
  72566. nodes?: INode[];
  72567. samplers?: ISampler[];
  72568. scenes?: IScene[];
  72569. skins?: ISkin[];
  72570. textures?: ITexture[];
  72571. }
  72572. }
  72573. declare module BABYLON.GLTF2 {
  72574. /**
  72575. * Interface for a glTF loader extension.
  72576. */
  72577. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  72578. /**
  72579. * Called after the loader state changes to LOADING.
  72580. */
  72581. onLoading?(): void;
  72582. /**
  72583. * Called after the loader state changes to READY.
  72584. */
  72585. onReady?(): void;
  72586. /**
  72587. * Define this method to modify the default behavior when loading scenes.
  72588. * @param context The context when loading the asset
  72589. * @param scene The glTF scene property
  72590. * @returns A promise that resolves when the load is complete or null if not handled
  72591. */
  72592. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  72593. /**
  72594. * Define this method to modify the default behavior when loading nodes.
  72595. * @param context The context when loading the asset
  72596. * @param node The glTF node property
  72597. * @param assign A function called synchronously after parsing the glTF properties
  72598. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  72599. */
  72600. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72601. /**
  72602. * Define this method to modify the default behavior when loading cameras.
  72603. * @param context The context when loading the asset
  72604. * @param camera The glTF camera property
  72605. * @param assign A function called synchronously after parsing the glTF properties
  72606. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  72607. */
  72608. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72609. /**
  72610. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  72611. * @param context The context when loading the asset
  72612. * @param primitive The glTF mesh primitive property
  72613. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  72614. */
  72615. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72616. /**
  72617. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72618. * @param context The context when loading the asset
  72619. * @param name The mesh name when loading the asset
  72620. * @param node The glTF node when loading the asset
  72621. * @param mesh The glTF mesh when loading the asset
  72622. * @param primitive The glTF mesh primitive property
  72623. * @param assign A function called synchronously after parsing the glTF properties
  72624. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72625. */
  72626. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72627. /**
  72628. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  72629. * @param context The context when loading the asset
  72630. * @param material The glTF material property
  72631. * @param assign A function called synchronously after parsing the glTF properties
  72632. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  72633. */
  72634. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72635. /**
  72636. * Define this method to modify the default behavior when creating materials.
  72637. * @param context The context when loading the asset
  72638. * @param material The glTF material property
  72639. * @param babylonDrawMode The draw mode for the Babylon material
  72640. * @returns The Babylon material or null if not handled
  72641. */
  72642. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72643. /**
  72644. * Define this method to modify the default behavior when loading material properties.
  72645. * @param context The context when loading the asset
  72646. * @param material The glTF material property
  72647. * @param babylonMaterial The Babylon material
  72648. * @returns A promise that resolves when the load is complete or null if not handled
  72649. */
  72650. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72651. /**
  72652. * Define this method to modify the default behavior when loading texture infos.
  72653. * @param context The context when loading the asset
  72654. * @param textureInfo The glTF texture info property
  72655. * @param assign A function called synchronously after parsing the glTF properties
  72656. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  72657. */
  72658. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72659. /**
  72660. * Define this method to modify the default behavior when loading animations.
  72661. * @param context The context when loading the asset
  72662. * @param animation The glTF animation property
  72663. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  72664. */
  72665. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72666. /**
  72667. * @hidden Define this method to modify the default behavior when loading skins.
  72668. * @param context The context when loading the asset
  72669. * @param node The glTF node property
  72670. * @param skin The glTF skin property
  72671. * @returns A promise that resolves when the load is complete or null if not handled
  72672. */
  72673. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  72674. /**
  72675. * @hidden Define this method to modify the default behavior when loading uris.
  72676. * @param context The context when loading the asset
  72677. * @param property The glTF property associated with the uri
  72678. * @param uri The uri to load
  72679. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72680. */
  72681. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72682. /**
  72683. * Define this method to modify the default behavior when loading buffer views.
  72684. * @param context The context when loading the asset
  72685. * @param bufferView The glTF buffer view property
  72686. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72687. */
  72688. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  72689. /**
  72690. * Define this method to modify the default behavior when loading buffers.
  72691. * @param context The context when loading the asset
  72692. * @param buffer The glTF buffer property
  72693. * @param byteOffset The byte offset to load
  72694. * @param byteLength The byte length to load
  72695. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72696. */
  72697. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72698. }
  72699. }
  72700. declare module BABYLON.GLTF2 {
  72701. /**
  72702. * Helper class for working with arrays when loading the glTF asset
  72703. */
  72704. export class ArrayItem {
  72705. /**
  72706. * Gets an item from the given array.
  72707. * @param context The context when loading the asset
  72708. * @param array The array to get the item from
  72709. * @param index The index to the array
  72710. * @returns The array item
  72711. */
  72712. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  72713. /**
  72714. * Assign an `index` field to each item of the given array.
  72715. * @param array The array of items
  72716. */
  72717. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  72718. }
  72719. /**
  72720. * The glTF 2.0 loader
  72721. */
  72722. export class GLTFLoader implements IGLTFLoader {
  72723. /** @hidden */
  72724. _completePromises: Promise<any>[];
  72725. private _disposed;
  72726. private _parent;
  72727. private _state;
  72728. private _extensions;
  72729. private _rootUrl;
  72730. private _fileName;
  72731. private _uniqueRootUrl;
  72732. private _gltf;
  72733. private _bin;
  72734. private _babylonScene;
  72735. private _rootBabylonMesh;
  72736. private _defaultBabylonMaterialData;
  72737. private _progressCallback?;
  72738. private _requests;
  72739. private static readonly _DefaultSampler;
  72740. private static _RegisteredExtensions;
  72741. /**
  72742. * Registers a loader extension.
  72743. * @param name The name of the loader extension.
  72744. * @param factory The factory function that creates the loader extension.
  72745. */
  72746. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  72747. /**
  72748. * Unregisters a loader extension.
  72749. * @param name The name of the loader extension.
  72750. * @returns A boolean indicating whether the extension has been unregistered
  72751. */
  72752. static UnregisterExtension(name: string): boolean;
  72753. /**
  72754. * Gets the loader state.
  72755. */
  72756. get state(): Nullable<GLTFLoaderState>;
  72757. /**
  72758. * The object that represents the glTF JSON.
  72759. */
  72760. get gltf(): IGLTF;
  72761. /**
  72762. * The BIN chunk of a binary glTF.
  72763. */
  72764. get bin(): Nullable<IDataBuffer>;
  72765. /**
  72766. * The parent file loader.
  72767. */
  72768. get parent(): GLTFFileLoader;
  72769. /**
  72770. * The Babylon scene when loading the asset.
  72771. */
  72772. get babylonScene(): Scene;
  72773. /**
  72774. * The root Babylon mesh when loading the asset.
  72775. */
  72776. get rootBabylonMesh(): Mesh;
  72777. /** @hidden */
  72778. constructor(parent: GLTFFileLoader);
  72779. /** @hidden */
  72780. dispose(): void;
  72781. /** @hidden */
  72782. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72783. meshes: AbstractMesh[];
  72784. particleSystems: IParticleSystem[];
  72785. skeletons: Skeleton[];
  72786. animationGroups: AnimationGroup[];
  72787. }>;
  72788. /** @hidden */
  72789. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72790. private _loadAsync;
  72791. private _loadData;
  72792. private _setupData;
  72793. private _loadExtensions;
  72794. private _checkExtensions;
  72795. private _setState;
  72796. private _createRootNode;
  72797. /**
  72798. * Loads a glTF scene.
  72799. * @param context The context when loading the asset
  72800. * @param scene The glTF scene property
  72801. * @returns A promise that resolves when the load is complete
  72802. */
  72803. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  72804. private _forEachPrimitive;
  72805. private _getMeshes;
  72806. private _getSkeletons;
  72807. private _getAnimationGroups;
  72808. private _startAnimations;
  72809. /**
  72810. * Loads a glTF node.
  72811. * @param context The context when loading the asset
  72812. * @param node The glTF node property
  72813. * @param assign A function called synchronously after parsing the glTF properties
  72814. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  72815. */
  72816. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  72817. private _loadMeshAsync;
  72818. /**
  72819. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72820. * @param context The context when loading the asset
  72821. * @param name The mesh name when loading the asset
  72822. * @param node The glTF node when loading the asset
  72823. * @param mesh The glTF mesh when loading the asset
  72824. * @param primitive The glTF mesh primitive property
  72825. * @param assign A function called synchronously after parsing the glTF properties
  72826. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72827. */
  72828. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72829. private _loadVertexDataAsync;
  72830. private _createMorphTargets;
  72831. private _loadMorphTargetsAsync;
  72832. private _loadMorphTargetVertexDataAsync;
  72833. private static _LoadTransform;
  72834. private _loadSkinAsync;
  72835. private _loadBones;
  72836. private _loadBone;
  72837. private _loadSkinInverseBindMatricesDataAsync;
  72838. private _updateBoneMatrices;
  72839. private _getNodeMatrix;
  72840. /**
  72841. * Loads a glTF camera.
  72842. * @param context The context when loading the asset
  72843. * @param camera The glTF camera property
  72844. * @param assign A function called synchronously after parsing the glTF properties
  72845. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  72846. */
  72847. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  72848. private _loadAnimationsAsync;
  72849. /**
  72850. * Loads a glTF animation.
  72851. * @param context The context when loading the asset
  72852. * @param animation The glTF animation property
  72853. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  72854. */
  72855. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72856. /**
  72857. * @hidden Loads a glTF animation channel.
  72858. * @param context The context when loading the asset
  72859. * @param animationContext The context of the animation when loading the asset
  72860. * @param animation The glTF animation property
  72861. * @param channel The glTF animation channel property
  72862. * @param babylonAnimationGroup The babylon animation group property
  72863. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72864. * @returns A void promise when the channel load is complete
  72865. */
  72866. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72867. private _loadAnimationSamplerAsync;
  72868. private _loadBufferAsync;
  72869. /**
  72870. * Loads a glTF buffer view.
  72871. * @param context The context when loading the asset
  72872. * @param bufferView The glTF buffer view property
  72873. * @returns A promise that resolves with the loaded data when the load is complete
  72874. */
  72875. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72876. private _loadAccessorAsync;
  72877. private _loadFloatAccessorAsync;
  72878. private _loadIndicesAccessorAsync;
  72879. private _loadVertexBufferViewAsync;
  72880. private _loadVertexAccessorAsync;
  72881. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72882. /** @hidden */
  72883. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72884. private _createDefaultMaterial;
  72885. /**
  72886. * Creates a Babylon material from a glTF material.
  72887. * @param context The context when loading the asset
  72888. * @param material The glTF material property
  72889. * @param babylonDrawMode The draw mode for the Babylon material
  72890. * @returns The Babylon material
  72891. */
  72892. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72893. /**
  72894. * Loads properties from a glTF material into a Babylon material.
  72895. * @param context The context when loading the asset
  72896. * @param material The glTF material property
  72897. * @param babylonMaterial The Babylon material
  72898. * @returns A promise that resolves when the load is complete
  72899. */
  72900. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72901. /**
  72902. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72903. * @param context The context when loading the asset
  72904. * @param material The glTF material property
  72905. * @param babylonMaterial The Babylon material
  72906. * @returns A promise that resolves when the load is complete
  72907. */
  72908. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72909. /**
  72910. * Loads the alpha properties from a glTF material into a Babylon material.
  72911. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72912. * @param context The context when loading the asset
  72913. * @param material The glTF material property
  72914. * @param babylonMaterial The Babylon material
  72915. */
  72916. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72917. /**
  72918. * Loads a glTF texture info.
  72919. * @param context The context when loading the asset
  72920. * @param textureInfo The glTF texture info property
  72921. * @param assign A function called synchronously after parsing the glTF properties
  72922. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72923. */
  72924. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72925. private _loadTextureAsync;
  72926. private _loadSampler;
  72927. /**
  72928. * Loads a glTF image.
  72929. * @param context The context when loading the asset
  72930. * @param image The glTF image property
  72931. * @returns A promise that resolves with the loaded data when the load is complete
  72932. */
  72933. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72934. /**
  72935. * Loads a glTF uri.
  72936. * @param context The context when loading the asset
  72937. * @param property The glTF property associated with the uri
  72938. * @param uri The base64 or relative uri
  72939. * @returns A promise that resolves with the loaded data when the load is complete
  72940. */
  72941. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72942. private _onProgress;
  72943. /**
  72944. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72945. * @param babylonObject the Babylon object with metadata
  72946. * @param pointer the JSON pointer
  72947. */
  72948. static AddPointerMetadata(babylonObject: {
  72949. metadata: any;
  72950. }, pointer: string): void;
  72951. private static _GetTextureWrapMode;
  72952. private static _GetTextureSamplingMode;
  72953. private static _GetTypedArrayConstructor;
  72954. private static _GetTypedArray;
  72955. private static _GetNumComponents;
  72956. private static _ValidateUri;
  72957. private static _GetDrawMode;
  72958. private _compileMaterialsAsync;
  72959. private _compileShadowGeneratorsAsync;
  72960. private _forEachExtensions;
  72961. private _applyExtensions;
  72962. private _extensionsOnLoading;
  72963. private _extensionsOnReady;
  72964. private _extensionsLoadSceneAsync;
  72965. private _extensionsLoadNodeAsync;
  72966. private _extensionsLoadCameraAsync;
  72967. private _extensionsLoadVertexDataAsync;
  72968. private _extensionsLoadMeshPrimitiveAsync;
  72969. private _extensionsLoadMaterialAsync;
  72970. private _extensionsCreateMaterial;
  72971. private _extensionsLoadMaterialPropertiesAsync;
  72972. private _extensionsLoadTextureInfoAsync;
  72973. private _extensionsLoadAnimationAsync;
  72974. private _extensionsLoadSkinAsync;
  72975. private _extensionsLoadUriAsync;
  72976. private _extensionsLoadBufferViewAsync;
  72977. private _extensionsLoadBufferAsync;
  72978. /**
  72979. * Helper method called by a loader extension to load an glTF extension.
  72980. * @param context The context when loading the asset
  72981. * @param property The glTF property to load the extension from
  72982. * @param extensionName The name of the extension to load
  72983. * @param actionAsync The action to run
  72984. * @returns The promise returned by actionAsync or null if the extension does not exist
  72985. */
  72986. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72987. /**
  72988. * Helper method called by a loader extension to load a glTF extra.
  72989. * @param context The context when loading the asset
  72990. * @param property The glTF property to load the extra from
  72991. * @param extensionName The name of the extension to load
  72992. * @param actionAsync The action to run
  72993. * @returns The promise returned by actionAsync or null if the extra does not exist
  72994. */
  72995. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72996. /**
  72997. * Checks for presence of an extension.
  72998. * @param name The name of the extension to check
  72999. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  73000. */
  73001. isExtensionUsed(name: string): boolean;
  73002. /**
  73003. * Increments the indentation level and logs a message.
  73004. * @param message The message to log
  73005. */
  73006. logOpen(message: string): void;
  73007. /**
  73008. * Decrements the indentation level.
  73009. */
  73010. logClose(): void;
  73011. /**
  73012. * Logs a message
  73013. * @param message The message to log
  73014. */
  73015. log(message: string): void;
  73016. /**
  73017. * Starts a performance counter.
  73018. * @param counterName The name of the performance counter
  73019. */
  73020. startPerformanceCounter(counterName: string): void;
  73021. /**
  73022. * Ends a performance counter.
  73023. * @param counterName The name of the performance counter
  73024. */
  73025. endPerformanceCounter(counterName: string): void;
  73026. }
  73027. }
  73028. declare module BABYLON.GLTF2.Loader.Extensions {
  73029. /**
  73030. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  73031. */
  73032. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  73033. /**
  73034. * The name of this extension.
  73035. */
  73036. readonly name: string;
  73037. /**
  73038. * Defines whether this extension is enabled.
  73039. */
  73040. enabled: boolean;
  73041. private _loader;
  73042. private _lights?;
  73043. /** @hidden */
  73044. constructor(loader: GLTFLoader);
  73045. /** @hidden */
  73046. dispose(): void;
  73047. /** @hidden */
  73048. onLoading(): void;
  73049. /** @hidden */
  73050. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73051. private _loadLightAsync;
  73052. }
  73053. }
  73054. declare module BABYLON.GLTF2.Loader.Extensions {
  73055. /**
  73056. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73057. */
  73058. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73059. /**
  73060. * The name of this extension.
  73061. */
  73062. readonly name: string;
  73063. /**
  73064. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73065. */
  73066. dracoCompression?: DracoCompression;
  73067. /**
  73068. * Defines whether this extension is enabled.
  73069. */
  73070. enabled: boolean;
  73071. private _loader;
  73072. /** @hidden */
  73073. constructor(loader: GLTFLoader);
  73074. /** @hidden */
  73075. dispose(): void;
  73076. /** @hidden */
  73077. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73078. }
  73079. }
  73080. declare module BABYLON.GLTF2.Loader.Extensions {
  73081. /**
  73082. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73083. */
  73084. export class KHR_lights implements IGLTFLoaderExtension {
  73085. /**
  73086. * The name of this extension.
  73087. */
  73088. readonly name: string;
  73089. /**
  73090. * Defines whether this extension is enabled.
  73091. */
  73092. enabled: boolean;
  73093. private _loader;
  73094. private _lights?;
  73095. /** @hidden */
  73096. constructor(loader: GLTFLoader);
  73097. /** @hidden */
  73098. dispose(): void;
  73099. /** @hidden */
  73100. onLoading(): void;
  73101. /** @hidden */
  73102. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73103. }
  73104. }
  73105. declare module BABYLON.GLTF2.Loader.Extensions {
  73106. /**
  73107. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73108. */
  73109. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73110. /**
  73111. * The name of this extension.
  73112. */
  73113. readonly name: string;
  73114. /**
  73115. * Defines whether this extension is enabled.
  73116. */
  73117. enabled: boolean;
  73118. /**
  73119. * Defines a number that determines the order the extensions are applied.
  73120. */
  73121. order: number;
  73122. private _loader;
  73123. /** @hidden */
  73124. constructor(loader: GLTFLoader);
  73125. /** @hidden */
  73126. dispose(): void;
  73127. /** @hidden */
  73128. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73129. private _loadSpecularGlossinessPropertiesAsync;
  73130. }
  73131. }
  73132. declare module BABYLON.GLTF2.Loader.Extensions {
  73133. /**
  73134. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73135. */
  73136. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73137. /**
  73138. * The name of this extension.
  73139. */
  73140. readonly name: string;
  73141. /**
  73142. * Defines whether this extension is enabled.
  73143. */
  73144. enabled: boolean;
  73145. /**
  73146. * Defines a number that determines the order the extensions are applied.
  73147. */
  73148. order: number;
  73149. private _loader;
  73150. /** @hidden */
  73151. constructor(loader: GLTFLoader);
  73152. /** @hidden */
  73153. dispose(): void;
  73154. /** @hidden */
  73155. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73156. private _loadUnlitPropertiesAsync;
  73157. }
  73158. }
  73159. declare module BABYLON.GLTF2.Loader.Extensions {
  73160. /**
  73161. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73162. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73163. * !!! Experimental Extension Subject to Changes !!!
  73164. */
  73165. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73166. /**
  73167. * The name of this extension.
  73168. */
  73169. readonly name: string;
  73170. /**
  73171. * Defines whether this extension is enabled.
  73172. */
  73173. enabled: boolean;
  73174. /**
  73175. * Defines a number that determines the order the extensions are applied.
  73176. */
  73177. order: number;
  73178. private _loader;
  73179. /** @hidden */
  73180. constructor(loader: GLTFLoader);
  73181. /** @hidden */
  73182. dispose(): void;
  73183. /** @hidden */
  73184. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73185. private _loadClearCoatPropertiesAsync;
  73186. }
  73187. }
  73188. declare module BABYLON.GLTF2.Loader.Extensions {
  73189. /**
  73190. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73191. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73192. * !!! Experimental Extension Subject to Changes !!!
  73193. */
  73194. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73195. /**
  73196. * The name of this extension.
  73197. */
  73198. readonly name: string;
  73199. /**
  73200. * Defines whether this extension is enabled.
  73201. */
  73202. enabled: boolean;
  73203. /**
  73204. * Defines a number that determines the order the extensions are applied.
  73205. */
  73206. order: number;
  73207. private _loader;
  73208. /** @hidden */
  73209. constructor(loader: GLTFLoader);
  73210. /** @hidden */
  73211. dispose(): void;
  73212. /** @hidden */
  73213. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73214. private _loadSheenPropertiesAsync;
  73215. }
  73216. }
  73217. declare module BABYLON.GLTF2.Loader.Extensions {
  73218. /**
  73219. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73220. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73221. * !!! Experimental Extension Subject to Changes !!!
  73222. */
  73223. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73224. /**
  73225. * The name of this extension.
  73226. */
  73227. readonly name: string;
  73228. /**
  73229. * Defines whether this extension is enabled.
  73230. */
  73231. enabled: boolean;
  73232. /**
  73233. * Defines a number that determines the order the extensions are applied.
  73234. */
  73235. order: number;
  73236. private _loader;
  73237. /** @hidden */
  73238. constructor(loader: GLTFLoader);
  73239. /** @hidden */
  73240. dispose(): void;
  73241. /** @hidden */
  73242. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73243. private _loadSpecularPropertiesAsync;
  73244. }
  73245. }
  73246. declare module BABYLON.GLTF2.Loader.Extensions {
  73247. /**
  73248. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  73249. */
  73250. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  73251. /**
  73252. * The name of this extension.
  73253. */
  73254. readonly name: string;
  73255. /**
  73256. * Defines whether this extension is enabled.
  73257. */
  73258. enabled: boolean;
  73259. /** @hidden */
  73260. constructor(loader: GLTFLoader);
  73261. /** @hidden */
  73262. dispose(): void;
  73263. }
  73264. }
  73265. declare module BABYLON.GLTF2.Loader.Extensions {
  73266. /**
  73267. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  73268. */
  73269. export class KHR_texture_transform implements IGLTFLoaderExtension {
  73270. /**
  73271. * The name of this extension.
  73272. */
  73273. readonly name: string;
  73274. /**
  73275. * Defines whether this extension is enabled.
  73276. */
  73277. enabled: boolean;
  73278. private _loader;
  73279. /** @hidden */
  73280. constructor(loader: GLTFLoader);
  73281. /** @hidden */
  73282. dispose(): void;
  73283. /** @hidden */
  73284. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73285. }
  73286. }
  73287. declare module BABYLON.GLTF2.Loader.Extensions {
  73288. /**
  73289. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  73290. */
  73291. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  73292. /**
  73293. * The name of this extension.
  73294. */
  73295. readonly name: string;
  73296. /**
  73297. * Defines whether this extension is enabled.
  73298. */
  73299. enabled: boolean;
  73300. private _loader;
  73301. private _clips;
  73302. private _emitters;
  73303. /** @hidden */
  73304. constructor(loader: GLTFLoader);
  73305. /** @hidden */
  73306. dispose(): void;
  73307. /** @hidden */
  73308. onLoading(): void;
  73309. /** @hidden */
  73310. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73311. /** @hidden */
  73312. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73313. /** @hidden */
  73314. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73315. private _loadClipAsync;
  73316. private _loadEmitterAsync;
  73317. private _getEventAction;
  73318. private _loadAnimationEventAsync;
  73319. }
  73320. }
  73321. declare module BABYLON.GLTF2.Loader.Extensions {
  73322. /**
  73323. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  73324. */
  73325. export class MSFT_lod implements IGLTFLoaderExtension {
  73326. /**
  73327. * The name of this extension.
  73328. */
  73329. readonly name: string;
  73330. /**
  73331. * Defines whether this extension is enabled.
  73332. */
  73333. enabled: boolean;
  73334. /**
  73335. * Defines a number that determines the order the extensions are applied.
  73336. */
  73337. order: number;
  73338. /**
  73339. * Maximum number of LODs to load, starting from the lowest LOD.
  73340. */
  73341. maxLODsToLoad: number;
  73342. /**
  73343. * Observable raised when all node LODs of one level are loaded.
  73344. * The event data is the index of the loaded LOD starting from zero.
  73345. * Dispose the loader to cancel the loading of the next level of LODs.
  73346. */
  73347. onNodeLODsLoadedObservable: Observable<number>;
  73348. /**
  73349. * Observable raised when all material LODs of one level are loaded.
  73350. * The event data is the index of the loaded LOD starting from zero.
  73351. * Dispose the loader to cancel the loading of the next level of LODs.
  73352. */
  73353. onMaterialLODsLoadedObservable: Observable<number>;
  73354. private _loader;
  73355. private _nodeIndexLOD;
  73356. private _nodeSignalLODs;
  73357. private _nodePromiseLODs;
  73358. private _materialIndexLOD;
  73359. private _materialSignalLODs;
  73360. private _materialPromiseLODs;
  73361. private _indexLOD;
  73362. private _bufferLODs;
  73363. /** @hidden */
  73364. constructor(loader: GLTFLoader);
  73365. /** @hidden */
  73366. dispose(): void;
  73367. /** @hidden */
  73368. onReady(): void;
  73369. /** @hidden */
  73370. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73371. /** @hidden */
  73372. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73373. /** @hidden */
  73374. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73375. /** @hidden */
  73376. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73377. private _loadBufferLOD;
  73378. /**
  73379. * Gets an array of LOD properties from lowest to highest.
  73380. */
  73381. private _getLODs;
  73382. private _disposeUnusedMaterials;
  73383. }
  73384. }
  73385. declare module BABYLON.GLTF2.Loader.Extensions {
  73386. /** @hidden */
  73387. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  73388. readonly name: string;
  73389. enabled: boolean;
  73390. private _loader;
  73391. constructor(loader: GLTFLoader);
  73392. dispose(): void;
  73393. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73394. }
  73395. }
  73396. declare module BABYLON.GLTF2.Loader.Extensions {
  73397. /** @hidden */
  73398. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  73399. readonly name: string;
  73400. enabled: boolean;
  73401. private _loader;
  73402. constructor(loader: GLTFLoader);
  73403. dispose(): void;
  73404. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73405. }
  73406. }
  73407. declare module BABYLON.GLTF2.Loader.Extensions {
  73408. /**
  73409. * Store glTF extras (if present) in BJS objects' metadata
  73410. */
  73411. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  73412. /**
  73413. * The name of this extension.
  73414. */
  73415. readonly name: string;
  73416. /**
  73417. * Defines whether this extension is enabled.
  73418. */
  73419. enabled: boolean;
  73420. private _loader;
  73421. private _assignExtras;
  73422. /** @hidden */
  73423. constructor(loader: GLTFLoader);
  73424. /** @hidden */
  73425. dispose(): void;
  73426. /** @hidden */
  73427. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73428. /** @hidden */
  73429. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73430. /** @hidden */
  73431. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73432. }
  73433. }
  73434. declare module BABYLON {
  73435. /**
  73436. * Class reading and parsing the MTL file bundled with the obj file.
  73437. */
  73438. export class MTLFileLoader {
  73439. /**
  73440. * All material loaded from the mtl will be set here
  73441. */
  73442. materials: StandardMaterial[];
  73443. /**
  73444. * This function will read the mtl file and create each material described inside
  73445. * This function could be improve by adding :
  73446. * -some component missing (Ni, Tf...)
  73447. * -including the specific options available
  73448. *
  73449. * @param scene defines the scene the material will be created in
  73450. * @param data defines the mtl data to parse
  73451. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  73452. */
  73453. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  73454. /**
  73455. * Gets the texture for the material.
  73456. *
  73457. * If the material is imported from input file,
  73458. * We sanitize the url to ensure it takes the textre from aside the material.
  73459. *
  73460. * @param rootUrl The root url to load from
  73461. * @param value The value stored in the mtl
  73462. * @return The Texture
  73463. */
  73464. private static _getTexture;
  73465. }
  73466. /**
  73467. * Options for loading OBJ/MTL files
  73468. */
  73469. type MeshLoadOptions = {
  73470. /**
  73471. * Defines if UVs are optimized by default during load.
  73472. */
  73473. OptimizeWithUV: boolean;
  73474. /**
  73475. * Defines custom scaling of UV coordinates of loaded meshes.
  73476. */
  73477. UVScaling: Vector2;
  73478. /**
  73479. * Invert model on y-axis (does a model scaling inversion)
  73480. */
  73481. InvertY: boolean;
  73482. /**
  73483. * Invert Y-Axis of referenced textures on load
  73484. */
  73485. InvertTextureY: boolean;
  73486. /**
  73487. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73488. */
  73489. ImportVertexColors: boolean;
  73490. /**
  73491. * Compute the normals for the model, even if normals are present in the file.
  73492. */
  73493. ComputeNormals: boolean;
  73494. /**
  73495. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73496. */
  73497. SkipMaterials: boolean;
  73498. /**
  73499. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73500. */
  73501. MaterialLoadingFailsSilently: boolean;
  73502. };
  73503. /**
  73504. * OBJ file type loader.
  73505. * This is a babylon scene loader plugin.
  73506. */
  73507. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73508. /**
  73509. * Defines if UVs are optimized by default during load.
  73510. */
  73511. static OPTIMIZE_WITH_UV: boolean;
  73512. /**
  73513. * Invert model on y-axis (does a model scaling inversion)
  73514. */
  73515. static INVERT_Y: boolean;
  73516. /**
  73517. * Invert Y-Axis of referenced textures on load
  73518. */
  73519. static INVERT_TEXTURE_Y: boolean;
  73520. /**
  73521. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73522. */
  73523. static IMPORT_VERTEX_COLORS: boolean;
  73524. /**
  73525. * Compute the normals for the model, even if normals are present in the file.
  73526. */
  73527. static COMPUTE_NORMALS: boolean;
  73528. /**
  73529. * Defines custom scaling of UV coordinates of loaded meshes.
  73530. */
  73531. static UV_SCALING: Vector2;
  73532. /**
  73533. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73534. */
  73535. static SKIP_MATERIALS: boolean;
  73536. /**
  73537. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73538. *
  73539. * Defaults to true for backwards compatibility.
  73540. */
  73541. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  73542. /**
  73543. * Defines the name of the plugin.
  73544. */
  73545. name: string;
  73546. /**
  73547. * Defines the extension the plugin is able to load.
  73548. */
  73549. extensions: string;
  73550. /** @hidden */
  73551. obj: RegExp;
  73552. /** @hidden */
  73553. group: RegExp;
  73554. /** @hidden */
  73555. mtllib: RegExp;
  73556. /** @hidden */
  73557. usemtl: RegExp;
  73558. /** @hidden */
  73559. smooth: RegExp;
  73560. /** @hidden */
  73561. vertexPattern: RegExp;
  73562. /** @hidden */
  73563. normalPattern: RegExp;
  73564. /** @hidden */
  73565. uvPattern: RegExp;
  73566. /** @hidden */
  73567. facePattern1: RegExp;
  73568. /** @hidden */
  73569. facePattern2: RegExp;
  73570. /** @hidden */
  73571. facePattern3: RegExp;
  73572. /** @hidden */
  73573. facePattern4: RegExp;
  73574. /** @hidden */
  73575. facePattern5: RegExp;
  73576. private _meshLoadOptions;
  73577. /**
  73578. * Creates loader for .OBJ files
  73579. *
  73580. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  73581. */
  73582. constructor(meshLoadOptions?: MeshLoadOptions);
  73583. private static get currentMeshLoadOptions();
  73584. /**
  73585. * Calls synchronously the MTL file attached to this obj.
  73586. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  73587. * Without this function materials are not displayed in the first frame (but displayed after).
  73588. * In consequence it is impossible to get material information in your HTML file
  73589. *
  73590. * @param url The URL of the MTL file
  73591. * @param rootUrl
  73592. * @param onSuccess Callback function to be called when the MTL file is loaded
  73593. * @private
  73594. */
  73595. private _loadMTL;
  73596. /**
  73597. * Instantiates a OBJ file loader plugin.
  73598. * @returns the created plugin
  73599. */
  73600. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  73601. /**
  73602. * If the data string can be loaded directly.
  73603. *
  73604. * @param data string containing the file data
  73605. * @returns if the data can be loaded directly
  73606. */
  73607. canDirectLoad(data: string): boolean;
  73608. /**
  73609. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73610. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73611. * @param scene the scene the meshes should be added to
  73612. * @param data the OBJ data to load
  73613. * @param rootUrl root url to load from
  73614. * @param onProgress event that fires when loading progress has occured
  73615. * @param fileName Defines the name of the file to load
  73616. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73617. */
  73618. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73619. meshes: AbstractMesh[];
  73620. particleSystems: IParticleSystem[];
  73621. skeletons: Skeleton[];
  73622. animationGroups: AnimationGroup[];
  73623. }>;
  73624. /**
  73625. * Imports all objects from the loaded OBJ data and adds them to the scene
  73626. * @param scene the scene the objects should be added to
  73627. * @param data the OBJ data to load
  73628. * @param rootUrl root url to load from
  73629. * @param onProgress event that fires when loading progress has occured
  73630. * @param fileName Defines the name of the file to load
  73631. * @returns a promise which completes when objects have been loaded to the scene
  73632. */
  73633. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73634. /**
  73635. * Load into an asset container.
  73636. * @param scene The scene to load into
  73637. * @param data The data to import
  73638. * @param rootUrl The root url for scene and resources
  73639. * @param onProgress The callback when the load progresses
  73640. * @param fileName Defines the name of the file to load
  73641. * @returns The loaded asset container
  73642. */
  73643. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73644. /**
  73645. * Read the OBJ file and create an Array of meshes.
  73646. * Each mesh contains all information given by the OBJ and the MTL file.
  73647. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  73648. *
  73649. * @param meshesNames
  73650. * @param scene Scene The scene where are displayed the data
  73651. * @param data String The content of the obj file
  73652. * @param rootUrl String The path to the folder
  73653. * @returns Array<AbstractMesh>
  73654. * @private
  73655. */
  73656. private _parseSolid;
  73657. }
  73658. }
  73659. declare module BABYLON {
  73660. /**
  73661. * STL file type loader.
  73662. * This is a babylon scene loader plugin.
  73663. */
  73664. export class STLFileLoader implements ISceneLoaderPlugin {
  73665. /** @hidden */
  73666. solidPattern: RegExp;
  73667. /** @hidden */
  73668. facetsPattern: RegExp;
  73669. /** @hidden */
  73670. normalPattern: RegExp;
  73671. /** @hidden */
  73672. vertexPattern: RegExp;
  73673. /**
  73674. * Defines the name of the plugin.
  73675. */
  73676. name: string;
  73677. /**
  73678. * Defines the extensions the stl loader is able to load.
  73679. * force data to come in as an ArrayBuffer
  73680. * we'll convert to string if it looks like it's an ASCII .stl
  73681. */
  73682. extensions: ISceneLoaderPluginExtensions;
  73683. /**
  73684. * Import meshes into a scene.
  73685. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  73686. * @param scene The scene to import into
  73687. * @param data The data to import
  73688. * @param rootUrl The root url for scene and resources
  73689. * @param meshes The meshes array to import into
  73690. * @param particleSystems The particle systems array to import into
  73691. * @param skeletons The skeletons array to import into
  73692. * @param onError The callback when import fails
  73693. * @returns True if successful or false otherwise
  73694. */
  73695. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  73696. /**
  73697. * Load into a scene.
  73698. * @param scene The scene to load into
  73699. * @param data The data to import
  73700. * @param rootUrl The root url for scene and resources
  73701. * @param onError The callback when import fails
  73702. * @returns true if successful or false otherwise
  73703. */
  73704. load(scene: Scene, data: any, rootUrl: string): boolean;
  73705. /**
  73706. * Load into an asset container.
  73707. * @param scene The scene to load into
  73708. * @param data The data to import
  73709. * @param rootUrl The root url for scene and resources
  73710. * @param onError The callback when import fails
  73711. * @returns The loaded asset container
  73712. */
  73713. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  73714. private _isBinary;
  73715. private _parseBinary;
  73716. private _parseASCII;
  73717. }
  73718. }
  73719. declare module BABYLON {
  73720. /**
  73721. * Class for generating OBJ data from a Babylon scene.
  73722. */
  73723. export class OBJExport {
  73724. /**
  73725. * Exports the geometry of a Mesh array in .OBJ file format (text)
  73726. * @param mesh defines the list of meshes to serialize
  73727. * @param materials defines if materials should be exported
  73728. * @param matlibname defines the name of the associated mtl file
  73729. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  73730. * @returns the OBJ content
  73731. */
  73732. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  73733. /**
  73734. * Exports the material(s) of a mesh in .MTL file format (text)
  73735. * @param mesh defines the mesh to extract the material from
  73736. * @returns the mtl content
  73737. */
  73738. static MTL(mesh: Mesh): string;
  73739. }
  73740. }
  73741. declare module BABYLON {
  73742. /** @hidden */
  73743. export var __IGLTFExporterExtension: number;
  73744. /**
  73745. * Interface for extending the exporter
  73746. * @hidden
  73747. */
  73748. export interface IGLTFExporterExtension {
  73749. /**
  73750. * The name of this extension
  73751. */
  73752. readonly name: string;
  73753. /**
  73754. * Defines whether this extension is enabled
  73755. */
  73756. enabled: boolean;
  73757. /**
  73758. * Defines whether this extension is required
  73759. */
  73760. required: boolean;
  73761. }
  73762. }
  73763. declare module BABYLON.GLTF2.Exporter {
  73764. /** @hidden */
  73765. export var __IGLTFExporterExtensionV2: number;
  73766. /**
  73767. * Interface for a glTF exporter extension
  73768. * @hidden
  73769. */
  73770. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  73771. /**
  73772. * Define this method to modify the default behavior before exporting a texture
  73773. * @param context The context when loading the asset
  73774. * @param babylonTexture The Babylon.js texture
  73775. * @param mimeType The mime-type of the generated image
  73776. * @returns A promise that resolves with the exported texture
  73777. */
  73778. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73779. /**
  73780. * Define this method to get notified when a texture info is created
  73781. * @param context The context when loading the asset
  73782. * @param textureInfo The glTF texture info
  73783. * @param babylonTexture The Babylon.js texture
  73784. */
  73785. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73786. /**
  73787. * Define this method to modify the default behavior when exporting texture info
  73788. * @param context The context when loading the asset
  73789. * @param meshPrimitive glTF mesh primitive
  73790. * @param babylonSubMesh Babylon submesh
  73791. * @param binaryWriter glTF serializer binary writer instance
  73792. * @returns nullable IMeshPrimitive promise
  73793. */
  73794. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  73795. /**
  73796. * Define this method to modify the default behavior when exporting a node
  73797. * @param context The context when exporting the node
  73798. * @param node glTF node
  73799. * @param babylonNode BabylonJS node
  73800. * @returns nullable INode promise
  73801. */
  73802. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73803. /**
  73804. * Define this method to modify the default behavior when exporting a material
  73805. * @param material glTF material
  73806. * @param babylonMaterial BabylonJS material
  73807. * @returns nullable IMaterial promise
  73808. */
  73809. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73810. /**
  73811. * Define this method to return additional textures to export from a material
  73812. * @param material glTF material
  73813. * @param babylonMaterial BabylonJS material
  73814. * @returns List of textures
  73815. */
  73816. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73817. /** Gets a boolean indicating that this extension was used */
  73818. wasUsed: boolean;
  73819. /** Gets a boolean indicating that this extension is required for the file to work */
  73820. required: boolean;
  73821. /**
  73822. * Called after the exporter state changes to EXPORTING
  73823. */
  73824. onExporting?(): void;
  73825. }
  73826. }
  73827. declare module BABYLON.GLTF2.Exporter {
  73828. /**
  73829. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  73830. * @hidden
  73831. */
  73832. export class _GLTFMaterialExporter {
  73833. /**
  73834. * Represents the dielectric specular values for R, G and B
  73835. */
  73836. private static readonly _DielectricSpecular;
  73837. /**
  73838. * Allows the maximum specular power to be defined for material calculations
  73839. */
  73840. private static readonly _MaxSpecularPower;
  73841. /**
  73842. * Mapping to store textures
  73843. */
  73844. private _textureMap;
  73845. /**
  73846. * Numeric tolerance value
  73847. */
  73848. private static readonly _Epsilon;
  73849. /**
  73850. * Reference to the glTF Exporter
  73851. */
  73852. private _exporter;
  73853. constructor(exporter: _Exporter);
  73854. /**
  73855. * Specifies if two colors are approximately equal in value
  73856. * @param color1 first color to compare to
  73857. * @param color2 second color to compare to
  73858. * @param epsilon threshold value
  73859. */
  73860. private static FuzzyEquals;
  73861. /**
  73862. * Gets the materials from a Babylon scene and converts them to glTF materials
  73863. * @param scene babylonjs scene
  73864. * @param mimeType texture mime type
  73865. * @param images array of images
  73866. * @param textures array of textures
  73867. * @param materials array of materials
  73868. * @param imageData mapping of texture names to base64 textures
  73869. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73870. */
  73871. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73872. /**
  73873. * Makes a copy of the glTF material without the texture parameters
  73874. * @param originalMaterial original glTF material
  73875. * @returns glTF material without texture parameters
  73876. */
  73877. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73878. /**
  73879. * Specifies if the material has any texture parameters present
  73880. * @param material glTF Material
  73881. * @returns boolean specifying if texture parameters are present
  73882. */
  73883. _hasTexturesPresent(material: IMaterial): boolean;
  73884. /**
  73885. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73886. * @param babylonStandardMaterial
  73887. * @returns glTF Metallic Roughness Material representation
  73888. */
  73889. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73890. /**
  73891. * Computes the metallic factor
  73892. * @param diffuse diffused value
  73893. * @param specular specular value
  73894. * @param oneMinusSpecularStrength one minus the specular strength
  73895. * @returns metallic value
  73896. */
  73897. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73898. /**
  73899. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73900. * @param glTFMaterial glTF material
  73901. * @param babylonMaterial Babylon material
  73902. */
  73903. private static _SetAlphaMode;
  73904. /**
  73905. * Converts a Babylon Standard Material to a glTF Material
  73906. * @param babylonStandardMaterial BJS Standard Material
  73907. * @param mimeType mime type to use for the textures
  73908. * @param images array of glTF image interfaces
  73909. * @param textures array of glTF texture interfaces
  73910. * @param materials array of glTF material interfaces
  73911. * @param imageData map of image file name to data
  73912. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73913. */
  73914. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73915. private _finishMaterial;
  73916. /**
  73917. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73918. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73919. * @param mimeType mime type to use for the textures
  73920. * @param images array of glTF image interfaces
  73921. * @param textures array of glTF texture interfaces
  73922. * @param materials array of glTF material interfaces
  73923. * @param imageData map of image file name to data
  73924. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73925. */
  73926. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73927. /**
  73928. * Converts an image typed array buffer to a base64 image
  73929. * @param buffer typed array buffer
  73930. * @param width width of the image
  73931. * @param height height of the image
  73932. * @param mimeType mimetype of the image
  73933. * @returns base64 image string
  73934. */
  73935. private _createBase64FromCanvasAsync;
  73936. /**
  73937. * Generates a white texture based on the specified width and height
  73938. * @param width width of the texture in pixels
  73939. * @param height height of the texture in pixels
  73940. * @param scene babylonjs scene
  73941. * @returns white texture
  73942. */
  73943. private _createWhiteTexture;
  73944. /**
  73945. * 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
  73946. * @param texture1 first texture to resize
  73947. * @param texture2 second texture to resize
  73948. * @param scene babylonjs scene
  73949. * @returns resized textures or null
  73950. */
  73951. private _resizeTexturesToSameDimensions;
  73952. /**
  73953. * Converts an array of pixels to a Float32Array
  73954. * Throws an error if the pixel format is not supported
  73955. * @param pixels - array buffer containing pixel values
  73956. * @returns Float32 of pixels
  73957. */
  73958. private _convertPixelArrayToFloat32;
  73959. /**
  73960. * Convert Specular Glossiness Textures to Metallic Roughness
  73961. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  73962. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  73963. * @param diffuseTexture texture used to store diffuse information
  73964. * @param specularGlossinessTexture texture used to store specular and glossiness information
  73965. * @param factors specular glossiness material factors
  73966. * @param mimeType the mime type to use for the texture
  73967. * @returns pbr metallic roughness interface or null
  73968. */
  73969. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  73970. /**
  73971. * Converts specular glossiness material properties to metallic roughness
  73972. * @param specularGlossiness interface with specular glossiness material properties
  73973. * @returns interface with metallic roughness material properties
  73974. */
  73975. private _convertSpecularGlossinessToMetallicRoughness;
  73976. /**
  73977. * Calculates the surface reflectance, independent of lighting conditions
  73978. * @param color Color source to calculate brightness from
  73979. * @returns number representing the perceived brightness, or zero if color is undefined
  73980. */
  73981. private _getPerceivedBrightness;
  73982. /**
  73983. * Returns the maximum color component value
  73984. * @param color
  73985. * @returns maximum color component value, or zero if color is null or undefined
  73986. */
  73987. private _getMaxComponent;
  73988. /**
  73989. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  73990. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73991. * @param mimeType mime type to use for the textures
  73992. * @param images array of glTF image interfaces
  73993. * @param textures array of glTF texture interfaces
  73994. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73995. * @param imageData map of image file name to data
  73996. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73997. * @returns glTF PBR Metallic Roughness factors
  73998. */
  73999. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  74000. private _getGLTFTextureSampler;
  74001. private _getGLTFTextureWrapMode;
  74002. private _getGLTFTextureWrapModesSampler;
  74003. /**
  74004. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  74005. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74006. * @param mimeType mime type to use for the textures
  74007. * @param images array of glTF image interfaces
  74008. * @param textures array of glTF texture interfaces
  74009. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74010. * @param imageData map of image file name to data
  74011. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74012. * @returns glTF PBR Metallic Roughness factors
  74013. */
  74014. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  74015. /**
  74016. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74017. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74018. * @param mimeType mime type to use for the textures
  74019. * @param images array of glTF image interfaces
  74020. * @param textures array of glTF texture interfaces
  74021. * @param materials array of glTF material interfaces
  74022. * @param imageData map of image file name to data
  74023. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74024. */
  74025. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74026. private setMetallicRoughnessPbrMaterial;
  74027. private getPixelsFromTexture;
  74028. /**
  74029. * Extracts a texture from a Babylon texture into file data and glTF data
  74030. * @param babylonTexture Babylon texture to extract
  74031. * @param mimeType Mime Type of the babylonTexture
  74032. * @return glTF texture info, or null if the texture format is not supported
  74033. */
  74034. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74035. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74036. /**
  74037. * Builds a texture from base64 string
  74038. * @param base64Texture base64 texture string
  74039. * @param baseTextureName Name to use for the texture
  74040. * @param mimeType image mime type for the texture
  74041. * @param images array of images
  74042. * @param textures array of textures
  74043. * @param imageData map of image data
  74044. * @returns glTF texture info, or null if the texture format is not supported
  74045. */
  74046. private _getTextureInfoFromBase64;
  74047. }
  74048. }
  74049. declare module BABYLON {
  74050. /**
  74051. * Class for holding and downloading glTF file data
  74052. */
  74053. export class GLTFData {
  74054. /**
  74055. * Object which contains the file name as the key and its data as the value
  74056. */
  74057. glTFFiles: {
  74058. [fileName: string]: string | Blob;
  74059. };
  74060. /**
  74061. * Initializes the glTF file object
  74062. */
  74063. constructor();
  74064. /**
  74065. * Downloads the glTF data as files based on their names and data
  74066. */
  74067. downloadFiles(): void;
  74068. }
  74069. }
  74070. declare module BABYLON {
  74071. /**
  74072. * Holds a collection of exporter options and parameters
  74073. */
  74074. export interface IExportOptions {
  74075. /**
  74076. * Function which indicates whether a babylon node should be exported or not
  74077. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74078. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74079. */
  74080. shouldExportNode?(node: Node): boolean;
  74081. /**
  74082. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74083. * @param metadata source metadata to read from
  74084. * @returns the data to store to glTF node extras
  74085. */
  74086. metadataSelector?(metadata: any): any;
  74087. /**
  74088. * The sample rate to bake animation curves
  74089. */
  74090. animationSampleRate?: number;
  74091. /**
  74092. * Begin serialization without waiting for the scene to be ready
  74093. */
  74094. exportWithoutWaitingForScene?: boolean;
  74095. }
  74096. /**
  74097. * Class for generating glTF data from a Babylon scene.
  74098. */
  74099. export class GLTF2Export {
  74100. /**
  74101. * Exports the geometry of the scene to .gltf file format asynchronously
  74102. * @param scene Babylon scene with scene hierarchy information
  74103. * @param filePrefix File prefix to use when generating the glTF file
  74104. * @param options Exporter options
  74105. * @returns Returns an object with a .gltf file and associates texture names
  74106. * as keys and their data and paths as values
  74107. */
  74108. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74109. private static _PreExportAsync;
  74110. private static _PostExportAsync;
  74111. /**
  74112. * Exports the geometry of the scene to .glb file format asychronously
  74113. * @param scene Babylon scene with scene hierarchy information
  74114. * @param filePrefix File prefix to use when generating glb file
  74115. * @param options Exporter options
  74116. * @returns Returns an object with a .glb filename as key and data as value
  74117. */
  74118. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74119. }
  74120. }
  74121. declare module BABYLON.GLTF2.Exporter {
  74122. /**
  74123. * @hidden
  74124. */
  74125. export class _GLTFUtilities {
  74126. /**
  74127. * Creates a buffer view based on the supplied arguments
  74128. * @param bufferIndex index value of the specified buffer
  74129. * @param byteOffset byte offset value
  74130. * @param byteLength byte length of the bufferView
  74131. * @param byteStride byte distance between conequential elements
  74132. * @param name name of the buffer view
  74133. * @returns bufferView for glTF
  74134. */
  74135. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74136. /**
  74137. * Creates an accessor based on the supplied arguments
  74138. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74139. * @param name The name of the accessor
  74140. * @param type The type of the accessor
  74141. * @param componentType The datatype of components in the attribute
  74142. * @param count The number of attributes referenced by this accessor
  74143. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74144. * @param min Minimum value of each component in this attribute
  74145. * @param max Maximum value of each component in this attribute
  74146. * @returns accessor for glTF
  74147. */
  74148. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74149. /**
  74150. * Calculates the minimum and maximum values of an array of position floats
  74151. * @param positions Positions array of a mesh
  74152. * @param vertexStart Starting vertex offset to calculate min and max values
  74153. * @param vertexCount Number of vertices to check for min and max values
  74154. * @returns min number array and max number array
  74155. */
  74156. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74157. min: number[];
  74158. max: number[];
  74159. };
  74160. /**
  74161. * Converts a new right-handed Vector3
  74162. * @param vector vector3 array
  74163. * @returns right-handed Vector3
  74164. */
  74165. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74166. /**
  74167. * Converts a Vector3 to right-handed
  74168. * @param vector Vector3 to convert to right-handed
  74169. */
  74170. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74171. /**
  74172. * Converts a three element number array to right-handed
  74173. * @param vector number array to convert to right-handed
  74174. */
  74175. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74176. /**
  74177. * Converts a new right-handed Vector3
  74178. * @param vector vector3 array
  74179. * @returns right-handed Vector3
  74180. */
  74181. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74182. /**
  74183. * Converts a Vector3 to right-handed
  74184. * @param vector Vector3 to convert to right-handed
  74185. */
  74186. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74187. /**
  74188. * Converts a three element number array to right-handed
  74189. * @param vector number array to convert to right-handed
  74190. */
  74191. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74192. /**
  74193. * Converts a Vector4 to right-handed
  74194. * @param vector Vector4 to convert to right-handed
  74195. */
  74196. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74197. /**
  74198. * Converts a Vector4 to right-handed
  74199. * @param vector Vector4 to convert to right-handed
  74200. */
  74201. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74202. /**
  74203. * Converts a Quaternion to right-handed
  74204. * @param quaternion Source quaternion to convert to right-handed
  74205. */
  74206. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74207. /**
  74208. * Converts a Quaternion to right-handed
  74209. * @param quaternion Source quaternion to convert to right-handed
  74210. */
  74211. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74212. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74213. }
  74214. }
  74215. declare module BABYLON.GLTF2.Exporter {
  74216. /**
  74217. * Converts Babylon Scene into glTF 2.0.
  74218. * @hidden
  74219. */
  74220. export class _Exporter {
  74221. /**
  74222. * Stores the glTF to export
  74223. */
  74224. _glTF: IGLTF;
  74225. /**
  74226. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74227. */
  74228. _bufferViews: IBufferView[];
  74229. /**
  74230. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  74231. */
  74232. _accessors: IAccessor[];
  74233. /**
  74234. * Stores all the generated nodes, which contains transform and/or mesh information per node
  74235. */
  74236. private _nodes;
  74237. /**
  74238. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  74239. */
  74240. private _scenes;
  74241. /**
  74242. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  74243. */
  74244. private _meshes;
  74245. /**
  74246. * Stores all the generated material information, which represents the appearance of each primitive
  74247. */
  74248. _materials: IMaterial[];
  74249. _materialMap: {
  74250. [materialID: number]: number;
  74251. };
  74252. /**
  74253. * Stores all the generated texture information, which is referenced by glTF materials
  74254. */
  74255. _textures: ITexture[];
  74256. /**
  74257. * Stores all the generated image information, which is referenced by glTF textures
  74258. */
  74259. _images: IImage[];
  74260. /**
  74261. * Stores all the texture samplers
  74262. */
  74263. _samplers: ISampler[];
  74264. /**
  74265. * Stores all the generated animation samplers, which is referenced by glTF animations
  74266. */
  74267. /**
  74268. * Stores the animations for glTF models
  74269. */
  74270. private _animations;
  74271. /**
  74272. * Stores the total amount of bytes stored in the glTF buffer
  74273. */
  74274. private _totalByteLength;
  74275. /**
  74276. * Stores a reference to the Babylon scene containing the source geometry and material information
  74277. */
  74278. _babylonScene: Scene;
  74279. /**
  74280. * Stores a map of the image data, where the key is the file name and the value
  74281. * is the image data
  74282. */
  74283. _imageData: {
  74284. [fileName: string]: {
  74285. data: Uint8Array;
  74286. mimeType: ImageMimeType;
  74287. };
  74288. };
  74289. /**
  74290. * Stores a map of the unique id of a node to its index in the node array
  74291. */
  74292. private _nodeMap;
  74293. /**
  74294. * Specifies if the Babylon scene should be converted to right-handed on export
  74295. */
  74296. _convertToRightHandedSystem: boolean;
  74297. /**
  74298. * Baked animation sample rate
  74299. */
  74300. private _animationSampleRate;
  74301. private _options;
  74302. private _localEngine;
  74303. _glTFMaterialExporter: _GLTFMaterialExporter;
  74304. private _extensions;
  74305. private static _ExtensionNames;
  74306. private static _ExtensionFactories;
  74307. private _applyExtension;
  74308. private _applyExtensions;
  74309. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  74310. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  74311. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  74312. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  74313. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  74314. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74315. private _forEachExtensions;
  74316. private _extensionsOnExporting;
  74317. /**
  74318. * Load glTF serializer extensions
  74319. */
  74320. private _loadExtensions;
  74321. /**
  74322. * Creates a glTF Exporter instance, which can accept optional exporter options
  74323. * @param babylonScene Babylon scene object
  74324. * @param options Options to modify the behavior of the exporter
  74325. */
  74326. constructor(babylonScene: Scene, options?: IExportOptions);
  74327. dispose(): void;
  74328. /**
  74329. * Registers a glTF exporter extension
  74330. * @param name Name of the extension to export
  74331. * @param factory The factory function that creates the exporter extension
  74332. */
  74333. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  74334. /**
  74335. * Un-registers an exporter extension
  74336. * @param name The name fo the exporter extension
  74337. * @returns A boolean indicating whether the extension has been un-registered
  74338. */
  74339. static UnregisterExtension(name: string): boolean;
  74340. /**
  74341. * Lazy load a local engine with premultiplied alpha set to false
  74342. */
  74343. _getLocalEngine(): Engine;
  74344. private reorderIndicesBasedOnPrimitiveMode;
  74345. /**
  74346. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  74347. * clock-wise during export to glTF
  74348. * @param submesh BabylonJS submesh
  74349. * @param primitiveMode Primitive mode of the mesh
  74350. * @param sideOrientation the winding order of the submesh
  74351. * @param vertexBufferKind The type of vertex attribute
  74352. * @param meshAttributeArray The vertex attribute data
  74353. * @param byteOffset The offset to the binary data
  74354. * @param binaryWriter The binary data for the glTF file
  74355. */
  74356. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  74357. /**
  74358. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  74359. * clock-wise during export to glTF
  74360. * @param submesh BabylonJS submesh
  74361. * @param primitiveMode Primitive mode of the mesh
  74362. * @param sideOrientation the winding order of the submesh
  74363. * @param vertexBufferKind The type of vertex attribute
  74364. * @param meshAttributeArray The vertex attribute data
  74365. * @param byteOffset The offset to the binary data
  74366. * @param binaryWriter The binary data for the glTF file
  74367. */
  74368. private reorderTriangleFillMode;
  74369. /**
  74370. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  74371. * clock-wise during export to glTF
  74372. * @param submesh BabylonJS submesh
  74373. * @param primitiveMode Primitive mode of the mesh
  74374. * @param sideOrientation the winding order of the submesh
  74375. * @param vertexBufferKind The type of vertex attribute
  74376. * @param meshAttributeArray The vertex attribute data
  74377. * @param byteOffset The offset to the binary data
  74378. * @param binaryWriter The binary data for the glTF file
  74379. */
  74380. private reorderTriangleStripDrawMode;
  74381. /**
  74382. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  74383. * clock-wise during export to glTF
  74384. * @param submesh BabylonJS submesh
  74385. * @param primitiveMode Primitive mode of the mesh
  74386. * @param sideOrientation the winding order of the submesh
  74387. * @param vertexBufferKind The type of vertex attribute
  74388. * @param meshAttributeArray The vertex attribute data
  74389. * @param byteOffset The offset to the binary data
  74390. * @param binaryWriter The binary data for the glTF file
  74391. */
  74392. private reorderTriangleFanMode;
  74393. /**
  74394. * Writes the vertex attribute data to binary
  74395. * @param vertices The vertices to write to the binary writer
  74396. * @param byteOffset The offset into the binary writer to overwrite binary data
  74397. * @param vertexAttributeKind The vertex attribute type
  74398. * @param meshAttributeArray The vertex attribute data
  74399. * @param binaryWriter The writer containing the binary data
  74400. */
  74401. private writeVertexAttributeData;
  74402. /**
  74403. * Writes mesh attribute data to a data buffer
  74404. * Returns the bytelength of the data
  74405. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  74406. * @param meshAttributeArray Array containing the attribute data
  74407. * @param binaryWriter The buffer to write the binary data to
  74408. * @param indices Used to specify the order of the vertex data
  74409. */
  74410. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  74411. /**
  74412. * Generates glTF json data
  74413. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  74414. * @param glTFPrefix Text to use when prefixing a glTF file
  74415. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  74416. * @returns json data as string
  74417. */
  74418. private generateJSON;
  74419. /**
  74420. * Generates data for .gltf and .bin files based on the glTF prefix string
  74421. * @param glTFPrefix Text to use when prefixing a glTF file
  74422. * @param dispose Dispose the exporter
  74423. * @returns GLTFData with glTF file data
  74424. */
  74425. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74426. /**
  74427. * Creates a binary buffer for glTF
  74428. * @returns array buffer for binary data
  74429. */
  74430. private _generateBinaryAsync;
  74431. /**
  74432. * Pads the number to a multiple of 4
  74433. * @param num number to pad
  74434. * @returns padded number
  74435. */
  74436. private _getPadding;
  74437. /**
  74438. * @hidden
  74439. */
  74440. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74441. /**
  74442. * Sets the TRS for each node
  74443. * @param node glTF Node for storing the transformation data
  74444. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  74445. */
  74446. private setNodeTransformation;
  74447. private getVertexBufferFromMesh;
  74448. /**
  74449. * Creates a bufferview based on the vertices type for the Babylon mesh
  74450. * @param kind Indicates the type of vertices data
  74451. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  74452. * @param binaryWriter The buffer to write the bufferview data to
  74453. */
  74454. private createBufferViewKind;
  74455. /**
  74456. * The primitive mode of the Babylon mesh
  74457. * @param babylonMesh The BabylonJS mesh
  74458. */
  74459. private getMeshPrimitiveMode;
  74460. /**
  74461. * Sets the primitive mode of the glTF mesh primitive
  74462. * @param meshPrimitive glTF mesh primitive
  74463. * @param primitiveMode The primitive mode
  74464. */
  74465. private setPrimitiveMode;
  74466. /**
  74467. * Sets the vertex attribute accessor based of the glTF mesh primitive
  74468. * @param meshPrimitive glTF mesh primitive
  74469. * @param attributeKind vertex attribute
  74470. * @returns boolean specifying if uv coordinates are present
  74471. */
  74472. private setAttributeKind;
  74473. /**
  74474. * Sets data for the primitive attributes of each submesh
  74475. * @param mesh glTF Mesh object to store the primitive attribute information
  74476. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  74477. * @param binaryWriter Buffer to write the attribute data to
  74478. */
  74479. private setPrimitiveAttributesAsync;
  74480. /**
  74481. * Creates a glTF scene based on the array of meshes
  74482. * Returns the the total byte offset
  74483. * @param babylonScene Babylon scene to get the mesh data from
  74484. * @param binaryWriter Buffer to write binary data to
  74485. */
  74486. private createSceneAsync;
  74487. /**
  74488. * Creates a mapping of Node unique id to node index and handles animations
  74489. * @param babylonScene Babylon Scene
  74490. * @param nodes Babylon transform nodes
  74491. * @param binaryWriter Buffer to write binary data to
  74492. * @returns Node mapping of unique id to index
  74493. */
  74494. private createNodeMapAndAnimationsAsync;
  74495. /**
  74496. * Creates a glTF node from a Babylon mesh
  74497. * @param babylonMesh Source Babylon mesh
  74498. * @param binaryWriter Buffer for storing geometry data
  74499. * @returns glTF node
  74500. */
  74501. private createNodeAsync;
  74502. }
  74503. /**
  74504. * @hidden
  74505. *
  74506. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  74507. */
  74508. export class _BinaryWriter {
  74509. /**
  74510. * Array buffer which stores all binary data
  74511. */
  74512. private _arrayBuffer;
  74513. /**
  74514. * View of the array buffer
  74515. */
  74516. private _dataView;
  74517. /**
  74518. * byte offset of data in array buffer
  74519. */
  74520. private _byteOffset;
  74521. /**
  74522. * Initialize binary writer with an initial byte length
  74523. * @param byteLength Initial byte length of the array buffer
  74524. */
  74525. constructor(byteLength: number);
  74526. /**
  74527. * Resize the array buffer to the specified byte length
  74528. * @param byteLength
  74529. */
  74530. private resizeBuffer;
  74531. /**
  74532. * Get an array buffer with the length of the byte offset
  74533. * @returns ArrayBuffer resized to the byte offset
  74534. */
  74535. getArrayBuffer(): ArrayBuffer;
  74536. /**
  74537. * Get the byte offset of the array buffer
  74538. * @returns byte offset
  74539. */
  74540. getByteOffset(): number;
  74541. /**
  74542. * Stores an UInt8 in the array buffer
  74543. * @param entry
  74544. * @param byteOffset If defined, specifies where to set the value as an offset.
  74545. */
  74546. setUInt8(entry: number, byteOffset?: number): void;
  74547. /**
  74548. * Gets an UInt32 in the array buffer
  74549. * @param entry
  74550. * @param byteOffset If defined, specifies where to set the value as an offset.
  74551. */
  74552. getUInt32(byteOffset: number): number;
  74553. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74554. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74555. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74556. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74557. /**
  74558. * Stores a Float32 in the array buffer
  74559. * @param entry
  74560. */
  74561. setFloat32(entry: number, byteOffset?: number): void;
  74562. /**
  74563. * Stores an UInt32 in the array buffer
  74564. * @param entry
  74565. * @param byteOffset If defined, specifies where to set the value as an offset.
  74566. */
  74567. setUInt32(entry: number, byteOffset?: number): void;
  74568. }
  74569. }
  74570. declare module BABYLON.GLTF2.Exporter {
  74571. /**
  74572. * @hidden
  74573. * Interface to store animation data.
  74574. */
  74575. export interface _IAnimationData {
  74576. /**
  74577. * Keyframe data.
  74578. */
  74579. inputs: number[];
  74580. /**
  74581. * Value data.
  74582. */
  74583. outputs: number[][];
  74584. /**
  74585. * Animation interpolation data.
  74586. */
  74587. samplerInterpolation: AnimationSamplerInterpolation;
  74588. /**
  74589. * Minimum keyframe value.
  74590. */
  74591. inputsMin: number;
  74592. /**
  74593. * Maximum keyframe value.
  74594. */
  74595. inputsMax: number;
  74596. }
  74597. /**
  74598. * @hidden
  74599. */
  74600. export interface _IAnimationInfo {
  74601. /**
  74602. * The target channel for the animation
  74603. */
  74604. animationChannelTargetPath: AnimationChannelTargetPath;
  74605. /**
  74606. * The glTF accessor type for the data.
  74607. */
  74608. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  74609. /**
  74610. * Specifies if quaternions should be used.
  74611. */
  74612. useQuaternion: boolean;
  74613. }
  74614. /**
  74615. * @hidden
  74616. * Utility class for generating glTF animation data from BabylonJS.
  74617. */
  74618. export class _GLTFAnimation {
  74619. /**
  74620. * @ignore
  74621. *
  74622. * Creates glTF channel animation from BabylonJS animation.
  74623. * @param babylonTransformNode - BabylonJS mesh.
  74624. * @param animation - animation.
  74625. * @param animationChannelTargetPath - The target animation channel.
  74626. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  74627. * @param useQuaternion - Specifies if quaternions are used.
  74628. * @returns nullable IAnimationData
  74629. */
  74630. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  74631. private static _DeduceAnimationInfo;
  74632. /**
  74633. * @ignore
  74634. * Create node animations from the transform node animations
  74635. * @param babylonNode
  74636. * @param runtimeGLTFAnimation
  74637. * @param idleGLTFAnimations
  74638. * @param nodeMap
  74639. * @param nodes
  74640. * @param binaryWriter
  74641. * @param bufferViews
  74642. * @param accessors
  74643. * @param convertToRightHandedSystem
  74644. */
  74645. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  74646. [key: number]: number;
  74647. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74648. /**
  74649. * @ignore
  74650. * Create node animations from the animation groups
  74651. * @param babylonScene
  74652. * @param glTFAnimations
  74653. * @param nodeMap
  74654. * @param nodes
  74655. * @param binaryWriter
  74656. * @param bufferViews
  74657. * @param accessors
  74658. * @param convertToRightHandedSystem
  74659. */
  74660. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  74661. [key: number]: number;
  74662. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74663. private static AddAnimation;
  74664. /**
  74665. * Create a baked animation
  74666. * @param babylonTransformNode BabylonJS mesh
  74667. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  74668. * @param animationChannelTargetPath animation target channel
  74669. * @param minFrame minimum animation frame
  74670. * @param maxFrame maximum animation frame
  74671. * @param fps frames per second of the animation
  74672. * @param inputs input key frames of the animation
  74673. * @param outputs output key frame data of the animation
  74674. * @param convertToRightHandedSystem converts the values to right-handed
  74675. * @param useQuaternion specifies if quaternions should be used
  74676. */
  74677. private static _CreateBakedAnimation;
  74678. private static _ConvertFactorToVector3OrQuaternion;
  74679. private static _SetInterpolatedValue;
  74680. /**
  74681. * Creates linear animation from the animation key frames
  74682. * @param babylonTransformNode BabylonJS mesh
  74683. * @param animation BabylonJS animation
  74684. * @param animationChannelTargetPath The target animation channel
  74685. * @param frameDelta The difference between the last and first frame of the animation
  74686. * @param inputs Array to store the key frame times
  74687. * @param outputs Array to store the key frame data
  74688. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74689. * @param useQuaternion Specifies if quaternions are used in the animation
  74690. */
  74691. private static _CreateLinearOrStepAnimation;
  74692. /**
  74693. * Creates cubic spline animation from the animation key frames
  74694. * @param babylonTransformNode BabylonJS mesh
  74695. * @param animation BabylonJS animation
  74696. * @param animationChannelTargetPath The target animation channel
  74697. * @param frameDelta The difference between the last and first frame of the animation
  74698. * @param inputs Array to store the key frame times
  74699. * @param outputs Array to store the key frame data
  74700. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74701. * @param useQuaternion Specifies if quaternions are used in the animation
  74702. */
  74703. private static _CreateCubicSplineAnimation;
  74704. private static _GetBasePositionRotationOrScale;
  74705. /**
  74706. * Adds a key frame value
  74707. * @param keyFrame
  74708. * @param animation
  74709. * @param outputs
  74710. * @param animationChannelTargetPath
  74711. * @param basePositionRotationOrScale
  74712. * @param convertToRightHandedSystem
  74713. * @param useQuaternion
  74714. */
  74715. private static _AddKeyframeValue;
  74716. /**
  74717. * Determine the interpolation based on the key frames
  74718. * @param keyFrames
  74719. * @param animationChannelTargetPath
  74720. * @param useQuaternion
  74721. */
  74722. private static _DeduceInterpolation;
  74723. /**
  74724. * Adds an input tangent or output tangent to the output data
  74725. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  74726. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  74727. * @param outputs The animation data by keyframe
  74728. * @param animationChannelTargetPath The target animation channel
  74729. * @param interpolation The interpolation type
  74730. * @param keyFrame The key frame with the animation data
  74731. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  74732. * @param useQuaternion Specifies if quaternions are used
  74733. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  74734. */
  74735. private static AddSplineTangent;
  74736. /**
  74737. * Get the minimum and maximum key frames' frame values
  74738. * @param keyFrames animation key frames
  74739. * @returns the minimum and maximum key frame value
  74740. */
  74741. private static calculateMinMaxKeyFrames;
  74742. }
  74743. }
  74744. declare module BABYLON.GLTF2.Exporter {
  74745. /** @hidden */
  74746. export var textureTransformPixelShader: {
  74747. name: string;
  74748. shader: string;
  74749. };
  74750. }
  74751. declare module BABYLON.GLTF2.Exporter.Extensions {
  74752. /**
  74753. * @hidden
  74754. */
  74755. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  74756. private _recordedTextures;
  74757. /** Name of this extension */
  74758. readonly name: string;
  74759. /** Defines whether this extension is enabled */
  74760. enabled: boolean;
  74761. /** Defines whether this extension is required */
  74762. required: boolean;
  74763. /** Reference to the glTF exporter */
  74764. private _wasUsed;
  74765. constructor(exporter: _Exporter);
  74766. dispose(): void;
  74767. /** @hidden */
  74768. get wasUsed(): boolean;
  74769. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74770. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74771. /**
  74772. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  74773. * @param babylonTexture
  74774. * @param offset
  74775. * @param rotation
  74776. * @param scale
  74777. * @param scene
  74778. */
  74779. private _textureTransformTextureAsync;
  74780. }
  74781. }
  74782. declare module BABYLON.GLTF2.Exporter.Extensions {
  74783. /**
  74784. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74785. */
  74786. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  74787. /** The name of this extension. */
  74788. readonly name: string;
  74789. /** Defines whether this extension is enabled. */
  74790. enabled: boolean;
  74791. /** Defines whether this extension is required */
  74792. required: boolean;
  74793. /** Reference to the glTF exporter */
  74794. private _exporter;
  74795. private _lights;
  74796. /** @hidden */
  74797. constructor(exporter: _Exporter);
  74798. /** @hidden */
  74799. dispose(): void;
  74800. /** @hidden */
  74801. get wasUsed(): boolean;
  74802. /** @hidden */
  74803. onExporting(): void;
  74804. /**
  74805. * Define this method to modify the default behavior when exporting a node
  74806. * @param context The context when exporting the node
  74807. * @param node glTF node
  74808. * @param babylonNode BabylonJS node
  74809. * @returns nullable INode promise
  74810. */
  74811. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74812. }
  74813. }
  74814. declare module BABYLON.GLTF2.Exporter.Extensions {
  74815. /**
  74816. * @hidden
  74817. */
  74818. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  74819. /** Name of this extension */
  74820. readonly name: string;
  74821. /** Defines whether this extension is enabled */
  74822. enabled: boolean;
  74823. /** Defines whether this extension is required */
  74824. required: boolean;
  74825. /** Reference to the glTF exporter */
  74826. private _textureInfos;
  74827. private _exportedTextures;
  74828. private _wasUsed;
  74829. constructor(exporter: _Exporter);
  74830. dispose(): void;
  74831. /** @hidden */
  74832. get wasUsed(): boolean;
  74833. private _getTextureIndex;
  74834. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74835. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74836. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74837. }
  74838. }
  74839. declare module BABYLON {
  74840. /**
  74841. * Class for generating STL data from a Babylon scene.
  74842. */
  74843. export class STLExport {
  74844. /**
  74845. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  74846. * @param meshes list defines the mesh to serialize
  74847. * @param download triggers the automatic download of the file.
  74848. * @param fileName changes the downloads fileName.
  74849. * @param binary changes the STL to a binary type.
  74850. * @param isLittleEndian toggle for binary type exporter.
  74851. * @returns the STL as UTF8 string
  74852. */
  74853. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  74854. }
  74855. }
  74856. declare module "babylonjs-gltf2interface" {
  74857. export = BABYLON.GLTF2;
  74858. }
  74859. /**
  74860. * Module for glTF 2.0 Interface
  74861. */
  74862. declare module BABYLON.GLTF2 {
  74863. /**
  74864. * The datatype of the components in the attribute
  74865. */
  74866. const enum AccessorComponentType {
  74867. /**
  74868. * Byte
  74869. */
  74870. BYTE = 5120,
  74871. /**
  74872. * Unsigned Byte
  74873. */
  74874. UNSIGNED_BYTE = 5121,
  74875. /**
  74876. * Short
  74877. */
  74878. SHORT = 5122,
  74879. /**
  74880. * Unsigned Short
  74881. */
  74882. UNSIGNED_SHORT = 5123,
  74883. /**
  74884. * Unsigned Int
  74885. */
  74886. UNSIGNED_INT = 5125,
  74887. /**
  74888. * Float
  74889. */
  74890. FLOAT = 5126,
  74891. }
  74892. /**
  74893. * Specifies if the attirbute is a scalar, vector, or matrix
  74894. */
  74895. const enum AccessorType {
  74896. /**
  74897. * Scalar
  74898. */
  74899. SCALAR = "SCALAR",
  74900. /**
  74901. * Vector2
  74902. */
  74903. VEC2 = "VEC2",
  74904. /**
  74905. * Vector3
  74906. */
  74907. VEC3 = "VEC3",
  74908. /**
  74909. * Vector4
  74910. */
  74911. VEC4 = "VEC4",
  74912. /**
  74913. * Matrix2x2
  74914. */
  74915. MAT2 = "MAT2",
  74916. /**
  74917. * Matrix3x3
  74918. */
  74919. MAT3 = "MAT3",
  74920. /**
  74921. * Matrix4x4
  74922. */
  74923. MAT4 = "MAT4",
  74924. }
  74925. /**
  74926. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74927. */
  74928. const enum AnimationChannelTargetPath {
  74929. /**
  74930. * Translation
  74931. */
  74932. TRANSLATION = "translation",
  74933. /**
  74934. * Rotation
  74935. */
  74936. ROTATION = "rotation",
  74937. /**
  74938. * Scale
  74939. */
  74940. SCALE = "scale",
  74941. /**
  74942. * Weights
  74943. */
  74944. WEIGHTS = "weights",
  74945. }
  74946. /**
  74947. * Interpolation algorithm
  74948. */
  74949. const enum AnimationSamplerInterpolation {
  74950. /**
  74951. * The animated values are linearly interpolated between keyframes
  74952. */
  74953. LINEAR = "LINEAR",
  74954. /**
  74955. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  74956. */
  74957. STEP = "STEP",
  74958. /**
  74959. * The animation's interpolation is computed using a cubic spline with specified tangents
  74960. */
  74961. CUBICSPLINE = "CUBICSPLINE",
  74962. }
  74963. /**
  74964. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74965. */
  74966. const enum CameraType {
  74967. /**
  74968. * A perspective camera containing properties to create a perspective projection matrix
  74969. */
  74970. PERSPECTIVE = "perspective",
  74971. /**
  74972. * An orthographic camera containing properties to create an orthographic projection matrix
  74973. */
  74974. ORTHOGRAPHIC = "orthographic",
  74975. }
  74976. /**
  74977. * The mime-type of the image
  74978. */
  74979. const enum ImageMimeType {
  74980. /**
  74981. * JPEG Mime-type
  74982. */
  74983. JPEG = "image/jpeg",
  74984. /**
  74985. * PNG Mime-type
  74986. */
  74987. PNG = "image/png",
  74988. }
  74989. /**
  74990. * The alpha rendering mode of the material
  74991. */
  74992. const enum MaterialAlphaMode {
  74993. /**
  74994. * The alpha value is ignored and the rendered output is fully opaque
  74995. */
  74996. OPAQUE = "OPAQUE",
  74997. /**
  74998. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  74999. */
  75000. MASK = "MASK",
  75001. /**
  75002. * 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)
  75003. */
  75004. BLEND = "BLEND",
  75005. }
  75006. /**
  75007. * The type of the primitives to render
  75008. */
  75009. const enum MeshPrimitiveMode {
  75010. /**
  75011. * Points
  75012. */
  75013. POINTS = 0,
  75014. /**
  75015. * Lines
  75016. */
  75017. LINES = 1,
  75018. /**
  75019. * Line Loop
  75020. */
  75021. LINE_LOOP = 2,
  75022. /**
  75023. * Line Strip
  75024. */
  75025. LINE_STRIP = 3,
  75026. /**
  75027. * Triangles
  75028. */
  75029. TRIANGLES = 4,
  75030. /**
  75031. * Triangle Strip
  75032. */
  75033. TRIANGLE_STRIP = 5,
  75034. /**
  75035. * Triangle Fan
  75036. */
  75037. TRIANGLE_FAN = 6,
  75038. }
  75039. /**
  75040. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75041. */
  75042. const enum TextureMagFilter {
  75043. /**
  75044. * Nearest
  75045. */
  75046. NEAREST = 9728,
  75047. /**
  75048. * Linear
  75049. */
  75050. LINEAR = 9729,
  75051. }
  75052. /**
  75053. * Minification filter. All valid values correspond to WebGL enums
  75054. */
  75055. const enum TextureMinFilter {
  75056. /**
  75057. * Nearest
  75058. */
  75059. NEAREST = 9728,
  75060. /**
  75061. * Linear
  75062. */
  75063. LINEAR = 9729,
  75064. /**
  75065. * Nearest Mip-Map Nearest
  75066. */
  75067. NEAREST_MIPMAP_NEAREST = 9984,
  75068. /**
  75069. * Linear Mipmap Nearest
  75070. */
  75071. LINEAR_MIPMAP_NEAREST = 9985,
  75072. /**
  75073. * Nearest Mipmap Linear
  75074. */
  75075. NEAREST_MIPMAP_LINEAR = 9986,
  75076. /**
  75077. * Linear Mipmap Linear
  75078. */
  75079. LINEAR_MIPMAP_LINEAR = 9987,
  75080. }
  75081. /**
  75082. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75083. */
  75084. const enum TextureWrapMode {
  75085. /**
  75086. * Clamp to Edge
  75087. */
  75088. CLAMP_TO_EDGE = 33071,
  75089. /**
  75090. * Mirrored Repeat
  75091. */
  75092. MIRRORED_REPEAT = 33648,
  75093. /**
  75094. * Repeat
  75095. */
  75096. REPEAT = 10497,
  75097. }
  75098. /**
  75099. * glTF Property
  75100. */
  75101. interface IProperty {
  75102. /**
  75103. * Dictionary object with extension-specific objects
  75104. */
  75105. extensions?: {
  75106. [key: string]: any;
  75107. };
  75108. /**
  75109. * Application-Specific data
  75110. */
  75111. extras?: any;
  75112. }
  75113. /**
  75114. * glTF Child of Root Property
  75115. */
  75116. interface IChildRootProperty extends IProperty {
  75117. /**
  75118. * The user-defined name of this object
  75119. */
  75120. name?: string;
  75121. }
  75122. /**
  75123. * Indices of those attributes that deviate from their initialization value
  75124. */
  75125. interface IAccessorSparseIndices extends IProperty {
  75126. /**
  75127. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75128. */
  75129. bufferView: number;
  75130. /**
  75131. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75132. */
  75133. byteOffset?: number;
  75134. /**
  75135. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75136. */
  75137. componentType: AccessorComponentType;
  75138. }
  75139. /**
  75140. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75141. */
  75142. interface IAccessorSparseValues extends IProperty {
  75143. /**
  75144. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75145. */
  75146. bufferView: number;
  75147. /**
  75148. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75149. */
  75150. byteOffset?: number;
  75151. }
  75152. /**
  75153. * Sparse storage of attributes that deviate from their initialization value
  75154. */
  75155. interface IAccessorSparse extends IProperty {
  75156. /**
  75157. * The number of attributes encoded in this sparse accessor
  75158. */
  75159. count: number;
  75160. /**
  75161. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75162. */
  75163. indices: IAccessorSparseIndices;
  75164. /**
  75165. * 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
  75166. */
  75167. values: IAccessorSparseValues;
  75168. }
  75169. /**
  75170. * 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
  75171. */
  75172. interface IAccessor extends IChildRootProperty {
  75173. /**
  75174. * The index of the bufferview
  75175. */
  75176. bufferView?: number;
  75177. /**
  75178. * The offset relative to the start of the bufferView in bytes
  75179. */
  75180. byteOffset?: number;
  75181. /**
  75182. * The datatype of components in the attribute
  75183. */
  75184. componentType: AccessorComponentType;
  75185. /**
  75186. * Specifies whether integer data values should be normalized
  75187. */
  75188. normalized?: boolean;
  75189. /**
  75190. * The number of attributes referenced by this accessor
  75191. */
  75192. count: number;
  75193. /**
  75194. * Specifies if the attribute is a scalar, vector, or matrix
  75195. */
  75196. type: AccessorType;
  75197. /**
  75198. * Maximum value of each component in this attribute
  75199. */
  75200. max?: number[];
  75201. /**
  75202. * Minimum value of each component in this attribute
  75203. */
  75204. min?: number[];
  75205. /**
  75206. * Sparse storage of attributes that deviate from their initialization value
  75207. */
  75208. sparse?: IAccessorSparse;
  75209. }
  75210. /**
  75211. * Targets an animation's sampler at a node's property
  75212. */
  75213. interface IAnimationChannel extends IProperty {
  75214. /**
  75215. * The index of a sampler in this animation used to compute the value for the target
  75216. */
  75217. sampler: number;
  75218. /**
  75219. * The index of the node and TRS property to target
  75220. */
  75221. target: IAnimationChannelTarget;
  75222. }
  75223. /**
  75224. * The index of the node and TRS property that an animation channel targets
  75225. */
  75226. interface IAnimationChannelTarget extends IProperty {
  75227. /**
  75228. * The index of the node to target
  75229. */
  75230. node: number;
  75231. /**
  75232. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75233. */
  75234. path: AnimationChannelTargetPath;
  75235. }
  75236. /**
  75237. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75238. */
  75239. interface IAnimationSampler extends IProperty {
  75240. /**
  75241. * The index of an accessor containing keyframe input values, e.g., time
  75242. */
  75243. input: number;
  75244. /**
  75245. * Interpolation algorithm
  75246. */
  75247. interpolation?: AnimationSamplerInterpolation;
  75248. /**
  75249. * The index of an accessor, containing keyframe output values
  75250. */
  75251. output: number;
  75252. }
  75253. /**
  75254. * A keyframe animation
  75255. */
  75256. interface IAnimation extends IChildRootProperty {
  75257. /**
  75258. * An array of channels, each of which targets an animation's sampler at a node's property
  75259. */
  75260. channels: IAnimationChannel[];
  75261. /**
  75262. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75263. */
  75264. samplers: IAnimationSampler[];
  75265. }
  75266. /**
  75267. * Metadata about the glTF asset
  75268. */
  75269. interface IAsset extends IChildRootProperty {
  75270. /**
  75271. * A copyright message suitable for display to credit the content creator
  75272. */
  75273. copyright?: string;
  75274. /**
  75275. * Tool that generated this glTF model. Useful for debugging
  75276. */
  75277. generator?: string;
  75278. /**
  75279. * The glTF version that this asset targets
  75280. */
  75281. version: string;
  75282. /**
  75283. * The minimum glTF version that this asset targets
  75284. */
  75285. minVersion?: string;
  75286. }
  75287. /**
  75288. * A buffer points to binary geometry, animation, or skins
  75289. */
  75290. interface IBuffer extends IChildRootProperty {
  75291. /**
  75292. * 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
  75293. */
  75294. uri?: string;
  75295. /**
  75296. * The length of the buffer in bytes
  75297. */
  75298. byteLength: number;
  75299. }
  75300. /**
  75301. * A view into a buffer generally representing a subset of the buffer
  75302. */
  75303. interface IBufferView extends IChildRootProperty {
  75304. /**
  75305. * The index of the buffer
  75306. */
  75307. buffer: number;
  75308. /**
  75309. * The offset into the buffer in bytes
  75310. */
  75311. byteOffset?: number;
  75312. /**
  75313. * The lenth of the bufferView in bytes
  75314. */
  75315. byteLength: number;
  75316. /**
  75317. * The stride, in bytes
  75318. */
  75319. byteStride?: number;
  75320. }
  75321. /**
  75322. * An orthographic camera containing properties to create an orthographic projection matrix
  75323. */
  75324. interface ICameraOrthographic extends IProperty {
  75325. /**
  75326. * The floating-point horizontal magnification of the view. Must not be zero
  75327. */
  75328. xmag: number;
  75329. /**
  75330. * The floating-point vertical magnification of the view. Must not be zero
  75331. */
  75332. ymag: number;
  75333. /**
  75334. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  75335. */
  75336. zfar: number;
  75337. /**
  75338. * The floating-point distance to the near clipping plane
  75339. */
  75340. znear: number;
  75341. }
  75342. /**
  75343. * A perspective camera containing properties to create a perspective projection matrix
  75344. */
  75345. interface ICameraPerspective extends IProperty {
  75346. /**
  75347. * The floating-point aspect ratio of the field of view
  75348. */
  75349. aspectRatio?: number;
  75350. /**
  75351. * The floating-point vertical field of view in radians
  75352. */
  75353. yfov: number;
  75354. /**
  75355. * The floating-point distance to the far clipping plane
  75356. */
  75357. zfar?: number;
  75358. /**
  75359. * The floating-point distance to the near clipping plane
  75360. */
  75361. znear: number;
  75362. }
  75363. /**
  75364. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75365. */
  75366. interface ICamera extends IChildRootProperty {
  75367. /**
  75368. * An orthographic camera containing properties to create an orthographic projection matrix
  75369. */
  75370. orthographic?: ICameraOrthographic;
  75371. /**
  75372. * A perspective camera containing properties to create a perspective projection matrix
  75373. */
  75374. perspective?: ICameraPerspective;
  75375. /**
  75376. * Specifies if the camera uses a perspective or orthographic projection
  75377. */
  75378. type: CameraType;
  75379. }
  75380. /**
  75381. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  75382. */
  75383. interface IImage extends IChildRootProperty {
  75384. /**
  75385. * 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
  75386. */
  75387. uri?: string;
  75388. /**
  75389. * The image's MIME type
  75390. */
  75391. mimeType?: ImageMimeType;
  75392. /**
  75393. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  75394. */
  75395. bufferView?: number;
  75396. }
  75397. /**
  75398. * Material Normal Texture Info
  75399. */
  75400. interface IMaterialNormalTextureInfo extends ITextureInfo {
  75401. /**
  75402. * The scalar multiplier applied to each normal vector of the normal texture
  75403. */
  75404. scale?: number;
  75405. }
  75406. /**
  75407. * Material Occlusion Texture Info
  75408. */
  75409. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  75410. /**
  75411. * A scalar multiplier controlling the amount of occlusion applied
  75412. */
  75413. strength?: number;
  75414. }
  75415. /**
  75416. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  75417. */
  75418. interface IMaterialPbrMetallicRoughness {
  75419. /**
  75420. * The material's base color factor
  75421. */
  75422. baseColorFactor?: number[];
  75423. /**
  75424. * The base color texture
  75425. */
  75426. baseColorTexture?: ITextureInfo;
  75427. /**
  75428. * The metalness of the material
  75429. */
  75430. metallicFactor?: number;
  75431. /**
  75432. * The roughness of the material
  75433. */
  75434. roughnessFactor?: number;
  75435. /**
  75436. * The metallic-roughness texture
  75437. */
  75438. metallicRoughnessTexture?: ITextureInfo;
  75439. }
  75440. /**
  75441. * The material appearance of a primitive
  75442. */
  75443. interface IMaterial extends IChildRootProperty {
  75444. /**
  75445. * 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
  75446. */
  75447. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75448. /**
  75449. * The normal map texture
  75450. */
  75451. normalTexture?: IMaterialNormalTextureInfo;
  75452. /**
  75453. * The occlusion map texture
  75454. */
  75455. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75456. /**
  75457. * The emissive map texture
  75458. */
  75459. emissiveTexture?: ITextureInfo;
  75460. /**
  75461. * 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
  75462. */
  75463. emissiveFactor?: number[];
  75464. /**
  75465. * The alpha rendering mode of the material
  75466. */
  75467. alphaMode?: MaterialAlphaMode;
  75468. /**
  75469. * The alpha cutoff value of the material
  75470. */
  75471. alphaCutoff?: number;
  75472. /**
  75473. * Specifies whether the material is double sided
  75474. */
  75475. doubleSided?: boolean;
  75476. }
  75477. /**
  75478. * Geometry to be rendered with the given material
  75479. */
  75480. interface IMeshPrimitive extends IProperty {
  75481. /**
  75482. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  75483. */
  75484. attributes: {
  75485. [name: string]: number;
  75486. };
  75487. /**
  75488. * The index of the accessor that contains the indices
  75489. */
  75490. indices?: number;
  75491. /**
  75492. * The index of the material to apply to this primitive when rendering
  75493. */
  75494. material?: number;
  75495. /**
  75496. * The type of primitives to render. All valid values correspond to WebGL enums
  75497. */
  75498. mode?: MeshPrimitiveMode;
  75499. /**
  75500. * 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
  75501. */
  75502. targets?: {
  75503. [name: string]: number;
  75504. }[];
  75505. }
  75506. /**
  75507. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  75508. */
  75509. interface IMesh extends IChildRootProperty {
  75510. /**
  75511. * An array of primitives, each defining geometry to be rendered with a material
  75512. */
  75513. primitives: IMeshPrimitive[];
  75514. /**
  75515. * Array of weights to be applied to the Morph Targets
  75516. */
  75517. weights?: number[];
  75518. }
  75519. /**
  75520. * A node in the node hierarchy
  75521. */
  75522. interface INode extends IChildRootProperty {
  75523. /**
  75524. * The index of the camera referenced by this node
  75525. */
  75526. camera?: number;
  75527. /**
  75528. * The indices of this node's children
  75529. */
  75530. children?: number[];
  75531. /**
  75532. * The index of the skin referenced by this node
  75533. */
  75534. skin?: number;
  75535. /**
  75536. * A floating-point 4x4 transformation matrix stored in column-major order
  75537. */
  75538. matrix?: number[];
  75539. /**
  75540. * The index of the mesh in this node
  75541. */
  75542. mesh?: number;
  75543. /**
  75544. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  75545. */
  75546. rotation?: number[];
  75547. /**
  75548. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  75549. */
  75550. scale?: number[];
  75551. /**
  75552. * The node's translation along the x, y, and z axes
  75553. */
  75554. translation?: number[];
  75555. /**
  75556. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  75557. */
  75558. weights?: number[];
  75559. }
  75560. /**
  75561. * Texture sampler properties for filtering and wrapping modes
  75562. */
  75563. interface ISampler extends IChildRootProperty {
  75564. /**
  75565. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75566. */
  75567. magFilter?: TextureMagFilter;
  75568. /**
  75569. * Minification filter. All valid values correspond to WebGL enums
  75570. */
  75571. minFilter?: TextureMinFilter;
  75572. /**
  75573. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75574. */
  75575. wrapS?: TextureWrapMode;
  75576. /**
  75577. * T (V) wrapping mode. All valid values correspond to WebGL enums
  75578. */
  75579. wrapT?: TextureWrapMode;
  75580. }
  75581. /**
  75582. * The root nodes of a scene
  75583. */
  75584. interface IScene extends IChildRootProperty {
  75585. /**
  75586. * The indices of each root node
  75587. */
  75588. nodes: number[];
  75589. }
  75590. /**
  75591. * Joints and matrices defining a skin
  75592. */
  75593. interface ISkin extends IChildRootProperty {
  75594. /**
  75595. * 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
  75596. */
  75597. inverseBindMatrices?: number;
  75598. /**
  75599. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  75600. */
  75601. skeleton?: number;
  75602. /**
  75603. * 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)
  75604. */
  75605. joints: number[];
  75606. }
  75607. /**
  75608. * A texture and its sampler
  75609. */
  75610. interface ITexture extends IChildRootProperty {
  75611. /**
  75612. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  75613. */
  75614. sampler?: number;
  75615. /**
  75616. * The index of the image used by this texture
  75617. */
  75618. source: number;
  75619. }
  75620. /**
  75621. * Reference to a texture
  75622. */
  75623. interface ITextureInfo extends IProperty {
  75624. /**
  75625. * The index of the texture
  75626. */
  75627. index: number;
  75628. /**
  75629. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  75630. */
  75631. texCoord?: number;
  75632. }
  75633. /**
  75634. * The root object for a glTF asset
  75635. */
  75636. interface IGLTF extends IProperty {
  75637. /**
  75638. * An array of accessors. An accessor is a typed view into a bufferView
  75639. */
  75640. accessors?: IAccessor[];
  75641. /**
  75642. * An array of keyframe animations
  75643. */
  75644. animations?: IAnimation[];
  75645. /**
  75646. * Metadata about the glTF asset
  75647. */
  75648. asset: IAsset;
  75649. /**
  75650. * An array of buffers. A buffer points to binary geometry, animation, or skins
  75651. */
  75652. buffers?: IBuffer[];
  75653. /**
  75654. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  75655. */
  75656. bufferViews?: IBufferView[];
  75657. /**
  75658. * An array of cameras
  75659. */
  75660. cameras?: ICamera[];
  75661. /**
  75662. * Names of glTF extensions used somewhere in this asset
  75663. */
  75664. extensionsUsed?: string[];
  75665. /**
  75666. * Names of glTF extensions required to properly load this asset
  75667. */
  75668. extensionsRequired?: string[];
  75669. /**
  75670. * An array of images. An image defines data used to create a texture
  75671. */
  75672. images?: IImage[];
  75673. /**
  75674. * An array of materials. A material defines the appearance of a primitive
  75675. */
  75676. materials?: IMaterial[];
  75677. /**
  75678. * An array of meshes. A mesh is a set of primitives to be rendered
  75679. */
  75680. meshes?: IMesh[];
  75681. /**
  75682. * An array of nodes
  75683. */
  75684. nodes?: INode[];
  75685. /**
  75686. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  75687. */
  75688. samplers?: ISampler[];
  75689. /**
  75690. * The index of the default scene
  75691. */
  75692. scene?: number;
  75693. /**
  75694. * An array of scenes
  75695. */
  75696. scenes?: IScene[];
  75697. /**
  75698. * An array of skins. A skin is defined by joints and matrices
  75699. */
  75700. skins?: ISkin[];
  75701. /**
  75702. * An array of textures
  75703. */
  75704. textures?: ITexture[];
  75705. }
  75706. /**
  75707. * The glTF validation results
  75708. * @ignore
  75709. */
  75710. interface IGLTFValidationResults {
  75711. info: {
  75712. generator: string;
  75713. hasAnimations: boolean;
  75714. hasDefaultScene: boolean;
  75715. hasMaterials: boolean;
  75716. hasMorphTargets: boolean;
  75717. hasSkins: boolean;
  75718. hasTextures: boolean;
  75719. maxAttributesUsed: number;
  75720. primitivesCount: number
  75721. };
  75722. issues: {
  75723. messages: Array<string>;
  75724. numErrors: number;
  75725. numHints: number;
  75726. numInfos: number;
  75727. numWarnings: number;
  75728. truncated: boolean
  75729. };
  75730. mimeType: string;
  75731. uri: string;
  75732. validatedAt: string;
  75733. validatorVersion: string;
  75734. }
  75735. /**
  75736. * The glTF validation options
  75737. */
  75738. interface IGLTFValidationOptions {
  75739. /** Uri to use */
  75740. uri?: string;
  75741. /** Function used to load external resources */
  75742. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  75743. /** Boolean indicating that we need to validate accessor data */
  75744. validateAccessorData?: boolean;
  75745. /** max number of issues allowed */
  75746. maxIssues?: number;
  75747. /** Ignored issues */
  75748. ignoredIssues?: Array<string>;
  75749. /** Value to override severy settings */
  75750. severityOverrides?: Object;
  75751. }
  75752. /**
  75753. * The glTF validator object
  75754. * @ignore
  75755. */
  75756. interface IGLTFValidator {
  75757. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75758. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75759. }
  75760. }
  75761. declare module BABYLON {
  75762. /** @hidden */
  75763. export var cellPixelShader: {
  75764. name: string;
  75765. shader: string;
  75766. };
  75767. }
  75768. declare module BABYLON {
  75769. /** @hidden */
  75770. export var cellVertexShader: {
  75771. name: string;
  75772. shader: string;
  75773. };
  75774. }
  75775. declare module BABYLON {
  75776. export class CellMaterial extends BABYLON.PushMaterial {
  75777. private _diffuseTexture;
  75778. diffuseTexture: BABYLON.BaseTexture;
  75779. diffuseColor: BABYLON.Color3;
  75780. _computeHighLevel: boolean;
  75781. computeHighLevel: boolean;
  75782. private _disableLighting;
  75783. disableLighting: boolean;
  75784. private _maxSimultaneousLights;
  75785. maxSimultaneousLights: number;
  75786. private _renderId;
  75787. constructor(name: string, scene: BABYLON.Scene);
  75788. needAlphaBlending(): boolean;
  75789. needAlphaTesting(): boolean;
  75790. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75791. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75793. getAnimatables(): BABYLON.IAnimatable[];
  75794. getActiveTextures(): BABYLON.BaseTexture[];
  75795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75796. dispose(forceDisposeEffect?: boolean): void;
  75797. getClassName(): string;
  75798. clone(name: string): CellMaterial;
  75799. serialize(): any;
  75800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  75801. }
  75802. }
  75803. declare module BABYLON {
  75804. export class CustomShaderStructure {
  75805. FragmentStore: string;
  75806. VertexStore: string;
  75807. constructor();
  75808. }
  75809. export class ShaderSpecialParts {
  75810. constructor();
  75811. Fragment_Begin: string;
  75812. Fragment_Definitions: string;
  75813. Fragment_MainBegin: string;
  75814. Fragment_Custom_Diffuse: string;
  75815. Fragment_Before_Lights: string;
  75816. Fragment_Before_Fog: string;
  75817. Fragment_Custom_Alpha: string;
  75818. Fragment_Before_FragColor: string;
  75819. Vertex_Begin: string;
  75820. Vertex_Definitions: string;
  75821. Vertex_MainBegin: string;
  75822. Vertex_Before_PositionUpdated: string;
  75823. Vertex_Before_NormalUpdated: string;
  75824. Vertex_MainEnd: string;
  75825. }
  75826. export class CustomMaterial extends BABYLON.StandardMaterial {
  75827. static ShaderIndexer: number;
  75828. CustomParts: ShaderSpecialParts;
  75829. _isCreatedShader: boolean;
  75830. _createdShaderName: string;
  75831. _customUniform: string[];
  75832. _newUniforms: string[];
  75833. _newUniformInstances: any[];
  75834. _newSamplerInstances: BABYLON.Texture[];
  75835. FragmentShader: string;
  75836. VertexShader: string;
  75837. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75838. ReviewUniform(name: string, arr: string[]): string[];
  75839. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  75840. constructor(name: string, scene: BABYLON.Scene);
  75841. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  75842. Fragment_Begin(shaderPart: string): CustomMaterial;
  75843. Fragment_Definitions(shaderPart: string): CustomMaterial;
  75844. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  75845. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  75846. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  75847. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  75848. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  75849. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  75850. Vertex_Begin(shaderPart: string): CustomMaterial;
  75851. Vertex_Definitions(shaderPart: string): CustomMaterial;
  75852. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  75853. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  75854. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  75855. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75856. }
  75857. }
  75858. declare module BABYLON {
  75859. export class ShaderAlebdoParts {
  75860. constructor();
  75861. Fragment_Begin: string;
  75862. Fragment_Definitions: string;
  75863. Fragment_MainBegin: string;
  75864. Fragment_Custom_Albedo: string;
  75865. Fragment_Before_Lights: string;
  75866. Fragment_Custom_MetallicRoughness: string;
  75867. Fragment_Custom_MicroSurface: string;
  75868. Fragment_Before_Fog: string;
  75869. Fragment_Custom_Alpha: string;
  75870. Fragment_Before_FragColor: string;
  75871. Vertex_Begin: string;
  75872. Vertex_Definitions: string;
  75873. Vertex_MainBegin: string;
  75874. Vertex_Before_PositionUpdated: string;
  75875. Vertex_Before_NormalUpdated: string;
  75876. Vertex_MainEnd: string;
  75877. }
  75878. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75879. static ShaderIndexer: number;
  75880. CustomParts: ShaderAlebdoParts;
  75881. _isCreatedShader: boolean;
  75882. _createdShaderName: string;
  75883. _customUniform: string[];
  75884. _newUniforms: string[];
  75885. _newUniformInstances: any[];
  75886. _newSamplerInstances: BABYLON.Texture[];
  75887. FragmentShader: string;
  75888. VertexShader: string;
  75889. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75890. ReviewUniform(name: string, arr: string[]): string[];
  75891. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75892. constructor(name: string, scene: BABYLON.Scene);
  75893. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75894. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75895. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75896. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75897. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75898. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75899. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75900. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75901. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75902. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75903. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75904. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75905. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75906. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75907. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75908. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75909. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75910. }
  75911. }
  75912. declare module BABYLON {
  75913. /** @hidden */
  75914. export var firePixelShader: {
  75915. name: string;
  75916. shader: string;
  75917. };
  75918. }
  75919. declare module BABYLON {
  75920. /** @hidden */
  75921. export var fireVertexShader: {
  75922. name: string;
  75923. shader: string;
  75924. };
  75925. }
  75926. declare module BABYLON {
  75927. export class FireMaterial extends BABYLON.PushMaterial {
  75928. private _diffuseTexture;
  75929. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75930. private _distortionTexture;
  75931. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75932. private _opacityTexture;
  75933. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75934. diffuseColor: BABYLON.Color3;
  75935. speed: number;
  75936. private _scaledDiffuse;
  75937. private _renderId;
  75938. private _lastTime;
  75939. constructor(name: string, scene: BABYLON.Scene);
  75940. needAlphaBlending(): boolean;
  75941. needAlphaTesting(): boolean;
  75942. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75943. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75944. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75945. getAnimatables(): BABYLON.IAnimatable[];
  75946. getActiveTextures(): BABYLON.BaseTexture[];
  75947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75948. getClassName(): string;
  75949. dispose(forceDisposeEffect?: boolean): void;
  75950. clone(name: string): FireMaterial;
  75951. serialize(): any;
  75952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  75953. }
  75954. }
  75955. declare module BABYLON {
  75956. /** @hidden */
  75957. export var furPixelShader: {
  75958. name: string;
  75959. shader: string;
  75960. };
  75961. }
  75962. declare module BABYLON {
  75963. /** @hidden */
  75964. export var furVertexShader: {
  75965. name: string;
  75966. shader: string;
  75967. };
  75968. }
  75969. declare module BABYLON {
  75970. export class FurMaterial extends BABYLON.PushMaterial {
  75971. private _diffuseTexture;
  75972. diffuseTexture: BABYLON.BaseTexture;
  75973. private _heightTexture;
  75974. heightTexture: BABYLON.BaseTexture;
  75975. diffuseColor: BABYLON.Color3;
  75976. furLength: number;
  75977. furAngle: number;
  75978. furColor: BABYLON.Color3;
  75979. furOffset: number;
  75980. furSpacing: number;
  75981. furGravity: BABYLON.Vector3;
  75982. furSpeed: number;
  75983. furDensity: number;
  75984. furOcclusion: number;
  75985. furTexture: BABYLON.DynamicTexture;
  75986. private _disableLighting;
  75987. disableLighting: boolean;
  75988. private _maxSimultaneousLights;
  75989. maxSimultaneousLights: number;
  75990. highLevelFur: boolean;
  75991. _meshes: BABYLON.AbstractMesh[];
  75992. private _renderId;
  75993. private _furTime;
  75994. constructor(name: string, scene: BABYLON.Scene);
  75995. get furTime(): number;
  75996. set furTime(furTime: number);
  75997. needAlphaBlending(): boolean;
  75998. needAlphaTesting(): boolean;
  75999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76000. updateFur(): void;
  76001. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76002. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76003. getAnimatables(): BABYLON.IAnimatable[];
  76004. getActiveTextures(): BABYLON.BaseTexture[];
  76005. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76006. dispose(forceDisposeEffect?: boolean): void;
  76007. clone(name: string): FurMaterial;
  76008. serialize(): any;
  76009. getClassName(): string;
  76010. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  76011. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  76012. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  76013. }
  76014. }
  76015. declare module BABYLON {
  76016. /** @hidden */
  76017. export var gradientPixelShader: {
  76018. name: string;
  76019. shader: string;
  76020. };
  76021. }
  76022. declare module BABYLON {
  76023. /** @hidden */
  76024. export var gradientVertexShader: {
  76025. name: string;
  76026. shader: string;
  76027. };
  76028. }
  76029. declare module BABYLON {
  76030. export class GradientMaterial extends BABYLON.PushMaterial {
  76031. private _maxSimultaneousLights;
  76032. maxSimultaneousLights: number;
  76033. topColor: BABYLON.Color3;
  76034. topColorAlpha: number;
  76035. bottomColor: BABYLON.Color3;
  76036. bottomColorAlpha: number;
  76037. offset: number;
  76038. scale: number;
  76039. smoothness: number;
  76040. private _disableLighting;
  76041. disableLighting: boolean;
  76042. private _renderId;
  76043. constructor(name: string, scene: BABYLON.Scene);
  76044. needAlphaBlending(): boolean;
  76045. needAlphaTesting(): boolean;
  76046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76049. getAnimatables(): BABYLON.IAnimatable[];
  76050. dispose(forceDisposeEffect?: boolean): void;
  76051. clone(name: string): GradientMaterial;
  76052. serialize(): any;
  76053. getClassName(): string;
  76054. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76055. }
  76056. }
  76057. declare module BABYLON {
  76058. /** @hidden */
  76059. export var gridPixelShader: {
  76060. name: string;
  76061. shader: string;
  76062. };
  76063. }
  76064. declare module BABYLON {
  76065. /** @hidden */
  76066. export var gridVertexShader: {
  76067. name: string;
  76068. shader: string;
  76069. };
  76070. }
  76071. declare module BABYLON {
  76072. /**
  76073. * The grid materials allows you to wrap any shape with a grid.
  76074. * Colors are customizable.
  76075. */
  76076. export class GridMaterial extends BABYLON.PushMaterial {
  76077. /**
  76078. * Main color of the grid (e.g. between lines)
  76079. */
  76080. mainColor: BABYLON.Color3;
  76081. /**
  76082. * Color of the grid lines.
  76083. */
  76084. lineColor: BABYLON.Color3;
  76085. /**
  76086. * The scale of the grid compared to unit.
  76087. */
  76088. gridRatio: number;
  76089. /**
  76090. * Allows setting an offset for the grid lines.
  76091. */
  76092. gridOffset: BABYLON.Vector3;
  76093. /**
  76094. * The frequency of thicker lines.
  76095. */
  76096. majorUnitFrequency: number;
  76097. /**
  76098. * The visibility of minor units in the grid.
  76099. */
  76100. minorUnitVisibility: number;
  76101. /**
  76102. * The grid opacity outside of the lines.
  76103. */
  76104. opacity: number;
  76105. /**
  76106. * Determine RBG output is premultiplied by alpha value.
  76107. */
  76108. preMultiplyAlpha: boolean;
  76109. private _opacityTexture;
  76110. opacityTexture: BABYLON.BaseTexture;
  76111. private _gridControl;
  76112. private _renderId;
  76113. /**
  76114. * constructor
  76115. * @param name The name given to the material in order to identify it afterwards.
  76116. * @param scene The scene the material is used in.
  76117. */
  76118. constructor(name: string, scene: BABYLON.Scene);
  76119. /**
  76120. * Returns wehter or not the grid requires alpha blending.
  76121. */
  76122. needAlphaBlending(): boolean;
  76123. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76124. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76125. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76126. /**
  76127. * Dispose the material and its associated resources.
  76128. * @param forceDisposeEffect will also dispose the used effect when true
  76129. */
  76130. dispose(forceDisposeEffect?: boolean): void;
  76131. clone(name: string): GridMaterial;
  76132. serialize(): any;
  76133. getClassName(): string;
  76134. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76135. }
  76136. }
  76137. declare module BABYLON {
  76138. /** @hidden */
  76139. export var lavaPixelShader: {
  76140. name: string;
  76141. shader: string;
  76142. };
  76143. }
  76144. declare module BABYLON {
  76145. /** @hidden */
  76146. export var lavaVertexShader: {
  76147. name: string;
  76148. shader: string;
  76149. };
  76150. }
  76151. declare module BABYLON {
  76152. export class LavaMaterial extends BABYLON.PushMaterial {
  76153. private _diffuseTexture;
  76154. diffuseTexture: BABYLON.BaseTexture;
  76155. noiseTexture: BABYLON.BaseTexture;
  76156. fogColor: BABYLON.Color3;
  76157. speed: number;
  76158. movingSpeed: number;
  76159. lowFrequencySpeed: number;
  76160. fogDensity: number;
  76161. private _lastTime;
  76162. diffuseColor: BABYLON.Color3;
  76163. private _disableLighting;
  76164. disableLighting: boolean;
  76165. private _unlit;
  76166. unlit: boolean;
  76167. private _maxSimultaneousLights;
  76168. maxSimultaneousLights: number;
  76169. private _scaledDiffuse;
  76170. private _renderId;
  76171. constructor(name: string, scene: BABYLON.Scene);
  76172. needAlphaBlending(): boolean;
  76173. needAlphaTesting(): boolean;
  76174. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76175. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76177. getAnimatables(): BABYLON.IAnimatable[];
  76178. getActiveTextures(): BABYLON.BaseTexture[];
  76179. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76180. dispose(forceDisposeEffect?: boolean): void;
  76181. clone(name: string): LavaMaterial;
  76182. serialize(): any;
  76183. getClassName(): string;
  76184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76185. }
  76186. }
  76187. declare module BABYLON {
  76188. /** @hidden */
  76189. export var mixPixelShader: {
  76190. name: string;
  76191. shader: string;
  76192. };
  76193. }
  76194. declare module BABYLON {
  76195. /** @hidden */
  76196. export var mixVertexShader: {
  76197. name: string;
  76198. shader: string;
  76199. };
  76200. }
  76201. declare module BABYLON {
  76202. export class MixMaterial extends BABYLON.PushMaterial {
  76203. /**
  76204. * Mix textures
  76205. */
  76206. private _mixTexture1;
  76207. mixTexture1: BABYLON.BaseTexture;
  76208. private _mixTexture2;
  76209. mixTexture2: BABYLON.BaseTexture;
  76210. /**
  76211. * Diffuse textures
  76212. */
  76213. private _diffuseTexture1;
  76214. diffuseTexture1: BABYLON.Texture;
  76215. private _diffuseTexture2;
  76216. diffuseTexture2: BABYLON.Texture;
  76217. private _diffuseTexture3;
  76218. diffuseTexture3: BABYLON.Texture;
  76219. private _diffuseTexture4;
  76220. diffuseTexture4: BABYLON.Texture;
  76221. private _diffuseTexture5;
  76222. diffuseTexture5: BABYLON.Texture;
  76223. private _diffuseTexture6;
  76224. diffuseTexture6: BABYLON.Texture;
  76225. private _diffuseTexture7;
  76226. diffuseTexture7: BABYLON.Texture;
  76227. private _diffuseTexture8;
  76228. diffuseTexture8: BABYLON.Texture;
  76229. /**
  76230. * Uniforms
  76231. */
  76232. diffuseColor: BABYLON.Color3;
  76233. specularColor: BABYLON.Color3;
  76234. specularPower: number;
  76235. private _disableLighting;
  76236. disableLighting: boolean;
  76237. private _maxSimultaneousLights;
  76238. maxSimultaneousLights: number;
  76239. private _renderId;
  76240. constructor(name: string, scene: BABYLON.Scene);
  76241. needAlphaBlending(): boolean;
  76242. needAlphaTesting(): boolean;
  76243. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76244. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76245. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76246. getAnimatables(): BABYLON.IAnimatable[];
  76247. getActiveTextures(): BABYLON.BaseTexture[];
  76248. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76249. dispose(forceDisposeEffect?: boolean): void;
  76250. clone(name: string): MixMaterial;
  76251. serialize(): any;
  76252. getClassName(): string;
  76253. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  76254. }
  76255. }
  76256. declare module BABYLON {
  76257. /** @hidden */
  76258. export var normalPixelShader: {
  76259. name: string;
  76260. shader: string;
  76261. };
  76262. }
  76263. declare module BABYLON {
  76264. /** @hidden */
  76265. export var normalVertexShader: {
  76266. name: string;
  76267. shader: string;
  76268. };
  76269. }
  76270. declare module BABYLON {
  76271. export class NormalMaterial extends BABYLON.PushMaterial {
  76272. private _diffuseTexture;
  76273. diffuseTexture: BABYLON.BaseTexture;
  76274. diffuseColor: BABYLON.Color3;
  76275. private _disableLighting;
  76276. disableLighting: boolean;
  76277. private _maxSimultaneousLights;
  76278. maxSimultaneousLights: number;
  76279. private _renderId;
  76280. constructor(name: string, scene: BABYLON.Scene);
  76281. needAlphaBlending(): boolean;
  76282. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76283. needAlphaTesting(): boolean;
  76284. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76285. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76286. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76287. getAnimatables(): BABYLON.IAnimatable[];
  76288. getActiveTextures(): BABYLON.BaseTexture[];
  76289. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76290. dispose(forceDisposeEffect?: boolean): void;
  76291. clone(name: string): NormalMaterial;
  76292. serialize(): any;
  76293. getClassName(): string;
  76294. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  76295. }
  76296. }
  76297. declare module BABYLON {
  76298. /** @hidden */
  76299. export var shadowOnlyPixelShader: {
  76300. name: string;
  76301. shader: string;
  76302. };
  76303. }
  76304. declare module BABYLON {
  76305. /** @hidden */
  76306. export var shadowOnlyVertexShader: {
  76307. name: string;
  76308. shader: string;
  76309. };
  76310. }
  76311. declare module BABYLON {
  76312. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  76313. private _renderId;
  76314. private _activeLight;
  76315. constructor(name: string, scene: BABYLON.Scene);
  76316. shadowColor: BABYLON.Color3;
  76317. needAlphaBlending(): boolean;
  76318. needAlphaTesting(): boolean;
  76319. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76320. get activeLight(): BABYLON.IShadowLight;
  76321. set activeLight(light: BABYLON.IShadowLight);
  76322. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76323. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76324. clone(name: string): ShadowOnlyMaterial;
  76325. serialize(): any;
  76326. getClassName(): string;
  76327. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  76328. }
  76329. }
  76330. declare module BABYLON {
  76331. /** @hidden */
  76332. export var simplePixelShader: {
  76333. name: string;
  76334. shader: string;
  76335. };
  76336. }
  76337. declare module BABYLON {
  76338. /** @hidden */
  76339. export var simpleVertexShader: {
  76340. name: string;
  76341. shader: string;
  76342. };
  76343. }
  76344. declare module BABYLON {
  76345. export class SimpleMaterial extends BABYLON.PushMaterial {
  76346. private _diffuseTexture;
  76347. diffuseTexture: BABYLON.BaseTexture;
  76348. diffuseColor: BABYLON.Color3;
  76349. private _disableLighting;
  76350. disableLighting: boolean;
  76351. private _maxSimultaneousLights;
  76352. maxSimultaneousLights: number;
  76353. private _renderId;
  76354. constructor(name: string, scene: BABYLON.Scene);
  76355. needAlphaBlending(): boolean;
  76356. needAlphaTesting(): boolean;
  76357. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76358. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76359. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76360. getAnimatables(): BABYLON.IAnimatable[];
  76361. getActiveTextures(): BABYLON.BaseTexture[];
  76362. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76363. dispose(forceDisposeEffect?: boolean): void;
  76364. clone(name: string): SimpleMaterial;
  76365. serialize(): any;
  76366. getClassName(): string;
  76367. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  76368. }
  76369. }
  76370. declare module BABYLON {
  76371. /** @hidden */
  76372. export var skyPixelShader: {
  76373. name: string;
  76374. shader: string;
  76375. };
  76376. }
  76377. declare module BABYLON {
  76378. /** @hidden */
  76379. export var skyVertexShader: {
  76380. name: string;
  76381. shader: string;
  76382. };
  76383. }
  76384. declare module BABYLON {
  76385. /**
  76386. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  76387. * @see https://doc.babylonjs.com/extensions/sky
  76388. */
  76389. export class SkyMaterial extends BABYLON.PushMaterial {
  76390. /**
  76391. * Defines the overall luminance of sky in interval ]0, 1[.
  76392. */
  76393. luminance: number;
  76394. /**
  76395. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  76396. */
  76397. turbidity: number;
  76398. /**
  76399. * Defines the sky appearance (light intensity).
  76400. */
  76401. rayleigh: number;
  76402. /**
  76403. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  76404. */
  76405. mieCoefficient: number;
  76406. /**
  76407. * Defines the amount of haze particles following the Mie scattering theory.
  76408. */
  76409. mieDirectionalG: number;
  76410. /**
  76411. * Defines the distance of the sun according to the active scene camera.
  76412. */
  76413. distance: number;
  76414. /**
  76415. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  76416. * "inclined".
  76417. */
  76418. inclination: number;
  76419. /**
  76420. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  76421. * an object direction and a reference direction.
  76422. */
  76423. azimuth: number;
  76424. /**
  76425. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  76426. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  76427. */
  76428. sunPosition: BABYLON.Vector3;
  76429. /**
  76430. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  76431. * .sunPosition property.
  76432. */
  76433. useSunPosition: boolean;
  76434. /**
  76435. * Defines an offset vector used to get a horizon offset.
  76436. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  76437. */
  76438. cameraOffset: BABYLON.Vector3;
  76439. private _cameraPosition;
  76440. private _renderId;
  76441. /**
  76442. * Instantiates a new sky material.
  76443. * This material allows to create dynamic and texture free
  76444. * effects for skyboxes by taking care of the atmosphere state.
  76445. * @see https://doc.babylonjs.com/extensions/sky
  76446. * @param name Define the name of the material in the scene
  76447. * @param scene Define the scene the material belong to
  76448. */
  76449. constructor(name: string, scene: BABYLON.Scene);
  76450. /**
  76451. * Specifies if the material will require alpha blending
  76452. * @returns a boolean specifying if alpha blending is needed
  76453. */
  76454. needAlphaBlending(): boolean;
  76455. /**
  76456. * Specifies if this material should be rendered in alpha test mode
  76457. * @returns false as the sky material doesn't need alpha testing.
  76458. */
  76459. needAlphaTesting(): boolean;
  76460. /**
  76461. * Get the texture used for alpha test purpose.
  76462. * @returns null as the sky material has no texture.
  76463. */
  76464. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76465. /**
  76466. * Get if the submesh is ready to be used and all its information available.
  76467. * Child classes can use it to update shaders
  76468. * @param mesh defines the mesh to check
  76469. * @param subMesh defines which submesh to check
  76470. * @param useInstances specifies that instances should be used
  76471. * @returns a boolean indicating that the submesh is ready or not
  76472. */
  76473. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76474. /**
  76475. * Binds the submesh to this material by preparing the effect and shader to draw
  76476. * @param world defines the world transformation matrix
  76477. * @param mesh defines the mesh containing the submesh
  76478. * @param subMesh defines the submesh to bind the material to
  76479. */
  76480. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76481. /**
  76482. * Get the list of animatables in the material.
  76483. * @returns the list of animatables object used in the material
  76484. */
  76485. getAnimatables(): BABYLON.IAnimatable[];
  76486. /**
  76487. * Disposes the material
  76488. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76489. */
  76490. dispose(forceDisposeEffect?: boolean): void;
  76491. /**
  76492. * Makes a duplicate of the material, and gives it a new name
  76493. * @param name defines the new name for the duplicated material
  76494. * @returns the cloned material
  76495. */
  76496. clone(name: string): SkyMaterial;
  76497. /**
  76498. * Serializes this material in a JSON representation
  76499. * @returns the serialized material object
  76500. */
  76501. serialize(): any;
  76502. /**
  76503. * Gets the current class name of the material e.g. "SkyMaterial"
  76504. * Mainly use in serialization.
  76505. * @returns the class name
  76506. */
  76507. getClassName(): string;
  76508. /**
  76509. * Creates a sky material from parsed material data
  76510. * @param source defines the JSON representation of the material
  76511. * @param scene defines the hosting scene
  76512. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76513. * @returns a new sky material
  76514. */
  76515. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  76516. }
  76517. }
  76518. declare module BABYLON {
  76519. /** @hidden */
  76520. export var terrainPixelShader: {
  76521. name: string;
  76522. shader: string;
  76523. };
  76524. }
  76525. declare module BABYLON {
  76526. /** @hidden */
  76527. export var terrainVertexShader: {
  76528. name: string;
  76529. shader: string;
  76530. };
  76531. }
  76532. declare module BABYLON {
  76533. export class TerrainMaterial extends BABYLON.PushMaterial {
  76534. private _mixTexture;
  76535. mixTexture: BABYLON.BaseTexture;
  76536. private _diffuseTexture1;
  76537. diffuseTexture1: BABYLON.Texture;
  76538. private _diffuseTexture2;
  76539. diffuseTexture2: BABYLON.Texture;
  76540. private _diffuseTexture3;
  76541. diffuseTexture3: BABYLON.Texture;
  76542. private _bumpTexture1;
  76543. bumpTexture1: BABYLON.Texture;
  76544. private _bumpTexture2;
  76545. bumpTexture2: BABYLON.Texture;
  76546. private _bumpTexture3;
  76547. bumpTexture3: BABYLON.Texture;
  76548. diffuseColor: BABYLON.Color3;
  76549. specularColor: BABYLON.Color3;
  76550. specularPower: number;
  76551. private _disableLighting;
  76552. disableLighting: boolean;
  76553. private _maxSimultaneousLights;
  76554. maxSimultaneousLights: number;
  76555. private _renderId;
  76556. constructor(name: string, scene: BABYLON.Scene);
  76557. needAlphaBlending(): boolean;
  76558. needAlphaTesting(): boolean;
  76559. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76561. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76562. getAnimatables(): BABYLON.IAnimatable[];
  76563. getActiveTextures(): BABYLON.BaseTexture[];
  76564. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76565. dispose(forceDisposeEffect?: boolean): void;
  76566. clone(name: string): TerrainMaterial;
  76567. serialize(): any;
  76568. getClassName(): string;
  76569. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  76570. }
  76571. }
  76572. declare module BABYLON {
  76573. /** @hidden */
  76574. export var triplanarPixelShader: {
  76575. name: string;
  76576. shader: string;
  76577. };
  76578. }
  76579. declare module BABYLON {
  76580. /** @hidden */
  76581. export var triplanarVertexShader: {
  76582. name: string;
  76583. shader: string;
  76584. };
  76585. }
  76586. declare module BABYLON {
  76587. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  76588. mixTexture: BABYLON.BaseTexture;
  76589. private _diffuseTextureX;
  76590. diffuseTextureX: BABYLON.BaseTexture;
  76591. private _diffuseTextureY;
  76592. diffuseTextureY: BABYLON.BaseTexture;
  76593. private _diffuseTextureZ;
  76594. diffuseTextureZ: BABYLON.BaseTexture;
  76595. private _normalTextureX;
  76596. normalTextureX: BABYLON.BaseTexture;
  76597. private _normalTextureY;
  76598. normalTextureY: BABYLON.BaseTexture;
  76599. private _normalTextureZ;
  76600. normalTextureZ: BABYLON.BaseTexture;
  76601. tileSize: number;
  76602. diffuseColor: BABYLON.Color3;
  76603. specularColor: BABYLON.Color3;
  76604. specularPower: number;
  76605. private _disableLighting;
  76606. disableLighting: boolean;
  76607. private _maxSimultaneousLights;
  76608. maxSimultaneousLights: number;
  76609. private _renderId;
  76610. constructor(name: string, scene: BABYLON.Scene);
  76611. needAlphaBlending(): boolean;
  76612. needAlphaTesting(): boolean;
  76613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76614. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76615. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76616. getAnimatables(): BABYLON.IAnimatable[];
  76617. getActiveTextures(): BABYLON.BaseTexture[];
  76618. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76619. dispose(forceDisposeEffect?: boolean): void;
  76620. clone(name: string): TriPlanarMaterial;
  76621. serialize(): any;
  76622. getClassName(): string;
  76623. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  76624. }
  76625. }
  76626. declare module BABYLON {
  76627. /** @hidden */
  76628. export var waterPixelShader: {
  76629. name: string;
  76630. shader: string;
  76631. };
  76632. }
  76633. declare module BABYLON {
  76634. /** @hidden */
  76635. export var waterVertexShader: {
  76636. name: string;
  76637. shader: string;
  76638. };
  76639. }
  76640. declare module BABYLON {
  76641. export class WaterMaterial extends BABYLON.PushMaterial {
  76642. renderTargetSize: BABYLON.Vector2;
  76643. private _bumpTexture;
  76644. bumpTexture: BABYLON.BaseTexture;
  76645. diffuseColor: BABYLON.Color3;
  76646. specularColor: BABYLON.Color3;
  76647. specularPower: number;
  76648. private _disableLighting;
  76649. disableLighting: boolean;
  76650. private _maxSimultaneousLights;
  76651. maxSimultaneousLights: number;
  76652. /**
  76653. * @param {number}: Represents the wind force
  76654. */
  76655. windForce: number;
  76656. /**
  76657. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  76658. */
  76659. windDirection: BABYLON.Vector2;
  76660. /**
  76661. * @param {number}: Wave height, represents the height of the waves
  76662. */
  76663. waveHeight: number;
  76664. /**
  76665. * @param {number}: Bump height, represents the bump height related to the bump map
  76666. */
  76667. bumpHeight: number;
  76668. /**
  76669. * @param {boolean}: Add a smaller moving bump to less steady waves.
  76670. */
  76671. private _bumpSuperimpose;
  76672. bumpSuperimpose: boolean;
  76673. /**
  76674. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  76675. */
  76676. private _fresnelSeparate;
  76677. fresnelSeparate: boolean;
  76678. /**
  76679. * @param {boolean}: bump Waves modify the reflection.
  76680. */
  76681. private _bumpAffectsReflection;
  76682. bumpAffectsReflection: boolean;
  76683. /**
  76684. * @param {number}: The water color blended with the refraction (near)
  76685. */
  76686. waterColor: BABYLON.Color3;
  76687. /**
  76688. * @param {number}: The blend factor related to the water color
  76689. */
  76690. colorBlendFactor: number;
  76691. /**
  76692. * @param {number}: The water color blended with the reflection (far)
  76693. */
  76694. waterColor2: BABYLON.Color3;
  76695. /**
  76696. * @param {number}: The blend factor related to the water color (reflection, far)
  76697. */
  76698. colorBlendFactor2: number;
  76699. /**
  76700. * @param {number}: Represents the maximum length of a wave
  76701. */
  76702. waveLength: number;
  76703. /**
  76704. * @param {number}: Defines the waves speed
  76705. */
  76706. waveSpeed: number;
  76707. /**
  76708. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  76709. * will avoid calculating useless pixels in the pixel shader of the water material.
  76710. */
  76711. disableClipPlane: boolean;
  76712. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  76713. private _mesh;
  76714. private _refractionRTT;
  76715. private _reflectionRTT;
  76716. private _reflectionTransform;
  76717. private _lastTime;
  76718. private _lastDeltaTime;
  76719. private _renderId;
  76720. private _useLogarithmicDepth;
  76721. private _waitingRenderList;
  76722. private _imageProcessingConfiguration;
  76723. private _imageProcessingObserver;
  76724. /**
  76725. * Gets a boolean indicating that current material needs to register RTT
  76726. */
  76727. get hasRenderTargetTextures(): boolean;
  76728. /**
  76729. * Constructor
  76730. */
  76731. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  76732. get useLogarithmicDepth(): boolean;
  76733. set useLogarithmicDepth(value: boolean);
  76734. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76735. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76736. addToRenderList(node: any): void;
  76737. enableRenderTargets(enable: boolean): void;
  76738. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  76739. get renderTargetsEnabled(): boolean;
  76740. needAlphaBlending(): boolean;
  76741. needAlphaTesting(): boolean;
  76742. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76743. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76744. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76745. private _createRenderTargets;
  76746. getAnimatables(): BABYLON.IAnimatable[];
  76747. getActiveTextures(): BABYLON.BaseTexture[];
  76748. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76749. dispose(forceDisposeEffect?: boolean): void;
  76750. clone(name: string): WaterMaterial;
  76751. serialize(): any;
  76752. getClassName(): string;
  76753. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  76754. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  76755. }
  76756. }
  76757. declare module BABYLON {
  76758. /** @hidden */
  76759. export var asciiartPixelShader: {
  76760. name: string;
  76761. shader: string;
  76762. };
  76763. }
  76764. declare module BABYLON {
  76765. /**
  76766. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  76767. *
  76768. * It basically takes care rendering the font front the given font size to a texture.
  76769. * This is used later on in the postprocess.
  76770. */
  76771. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  76772. private _font;
  76773. private _text;
  76774. private _charSize;
  76775. /**
  76776. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76777. */
  76778. get charSize(): number;
  76779. /**
  76780. * Create a new instance of the Ascii Art FontTexture class
  76781. * @param name the name of the texture
  76782. * @param font the font to use, use the W3C CSS notation
  76783. * @param text the caracter set to use in the rendering.
  76784. * @param scene the scene that owns the texture
  76785. */
  76786. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76787. /**
  76788. * Gets the max char width of a font.
  76789. * @param font the font to use, use the W3C CSS notation
  76790. * @return the max char width
  76791. */
  76792. private getFontWidth;
  76793. /**
  76794. * Gets the max char height of a font.
  76795. * @param font the font to use, use the W3C CSS notation
  76796. * @return the max char height
  76797. */
  76798. private getFontHeight;
  76799. /**
  76800. * Clones the current AsciiArtTexture.
  76801. * @return the clone of the texture.
  76802. */
  76803. clone(): AsciiArtFontTexture;
  76804. /**
  76805. * Parses a json object representing the texture and returns an instance of it.
  76806. * @param source the source JSON representation
  76807. * @param scene the scene to create the texture for
  76808. * @return the parsed texture
  76809. */
  76810. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  76811. }
  76812. /**
  76813. * Option available in the Ascii Art Post Process.
  76814. */
  76815. export interface IAsciiArtPostProcessOptions {
  76816. /**
  76817. * The font to use following the w3c font definition.
  76818. */
  76819. font?: string;
  76820. /**
  76821. * The character set to use in the postprocess.
  76822. */
  76823. characterSet?: string;
  76824. /**
  76825. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76826. * This number is defined between 0 and 1;
  76827. */
  76828. mixToTile?: number;
  76829. /**
  76830. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76831. * This number is defined between 0 and 1;
  76832. */
  76833. mixToNormal?: number;
  76834. }
  76835. /**
  76836. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  76837. *
  76838. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76839. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  76840. */
  76841. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  76842. /**
  76843. * The font texture used to render the char in the post process.
  76844. */
  76845. private _asciiArtFontTexture;
  76846. /**
  76847. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76848. * This number is defined between 0 and 1;
  76849. */
  76850. mixToTile: number;
  76851. /**
  76852. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76853. * This number is defined between 0 and 1;
  76854. */
  76855. mixToNormal: number;
  76856. /**
  76857. * Instantiates a new Ascii Art Post Process.
  76858. * @param name the name to give to the postprocess
  76859. * @camera the camera to apply the post process to.
  76860. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76861. */
  76862. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76863. }
  76864. }
  76865. declare module BABYLON {
  76866. /** @hidden */
  76867. export var digitalrainPixelShader: {
  76868. name: string;
  76869. shader: string;
  76870. };
  76871. }
  76872. declare module BABYLON {
  76873. /**
  76874. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76875. *
  76876. * It basically takes care rendering the font front the given font size to a texture.
  76877. * This is used later on in the postprocess.
  76878. */
  76879. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76880. private _font;
  76881. private _text;
  76882. private _charSize;
  76883. /**
  76884. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76885. */
  76886. get charSize(): number;
  76887. /**
  76888. * Create a new instance of the Digital Rain FontTexture class
  76889. * @param name the name of the texture
  76890. * @param font the font to use, use the W3C CSS notation
  76891. * @param text the caracter set to use in the rendering.
  76892. * @param scene the scene that owns the texture
  76893. */
  76894. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76895. /**
  76896. * Gets the max char width of a font.
  76897. * @param font the font to use, use the W3C CSS notation
  76898. * @return the max char width
  76899. */
  76900. private getFontWidth;
  76901. /**
  76902. * Gets the max char height of a font.
  76903. * @param font the font to use, use the W3C CSS notation
  76904. * @return the max char height
  76905. */
  76906. private getFontHeight;
  76907. /**
  76908. * Clones the current DigitalRainFontTexture.
  76909. * @return the clone of the texture.
  76910. */
  76911. clone(): DigitalRainFontTexture;
  76912. /**
  76913. * Parses a json object representing the texture and returns an instance of it.
  76914. * @param source the source JSON representation
  76915. * @param scene the scene to create the texture for
  76916. * @return the parsed texture
  76917. */
  76918. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76919. }
  76920. /**
  76921. * Option available in the Digital Rain Post Process.
  76922. */
  76923. export interface IDigitalRainPostProcessOptions {
  76924. /**
  76925. * The font to use following the w3c font definition.
  76926. */
  76927. font?: string;
  76928. /**
  76929. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76930. * This number is defined between 0 and 1;
  76931. */
  76932. mixToTile?: number;
  76933. /**
  76934. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76935. * This number is defined between 0 and 1;
  76936. */
  76937. mixToNormal?: number;
  76938. }
  76939. /**
  76940. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76941. *
  76942. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76943. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76944. */
  76945. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76946. /**
  76947. * The font texture used to render the char in the post process.
  76948. */
  76949. private _digitalRainFontTexture;
  76950. /**
  76951. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76952. * This number is defined between 0 and 1;
  76953. */
  76954. mixToTile: number;
  76955. /**
  76956. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76957. * This number is defined between 0 and 1;
  76958. */
  76959. mixToNormal: number;
  76960. /**
  76961. * Instantiates a new Digital Rain Post Process.
  76962. * @param name the name to give to the postprocess
  76963. * @camera the camera to apply the post process to.
  76964. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  76965. */
  76966. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  76967. }
  76968. }
  76969. declare module BABYLON {
  76970. /** @hidden */
  76971. export var oceanPostProcessPixelShader: {
  76972. name: string;
  76973. shader: string;
  76974. };
  76975. }
  76976. declare module BABYLON {
  76977. /**
  76978. * Option available in the Ocean Post Process.
  76979. */
  76980. export interface IOceanPostProcessOptions {
  76981. /**
  76982. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76983. */
  76984. reflectionSize?: number | {
  76985. width: number;
  76986. height: number;
  76987. } | {
  76988. ratio: number;
  76989. };
  76990. /**
  76991. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76992. */
  76993. refractionSize?: number | {
  76994. width: number;
  76995. height: number;
  76996. } | {
  76997. ratio: number;
  76998. };
  76999. }
  77000. /**
  77001. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  77002. *
  77003. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77004. * Example usage:
  77005. * var pp = new OceanPostProcess("myOcean", camera);
  77006. * pp.reflectionEnabled = true;
  77007. * pp.refractionEnabled = true;
  77008. */
  77009. export class OceanPostProcess extends BABYLON.PostProcess {
  77010. /**
  77011. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  77012. */
  77013. get reflectionEnabled(): boolean;
  77014. /**
  77015. * Sets weither or not the real-time reflection is enabled on the ocean.
  77016. * Is set to true, the reflection mirror texture will be used as reflection texture.
  77017. */
  77018. set reflectionEnabled(enabled: boolean);
  77019. /**
  77020. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  77021. */
  77022. get refractionEnabled(): boolean;
  77023. /**
  77024. * Sets weither or not the real-time refraction is enabled on the ocean.
  77025. * Is set to true, the refraction render target texture will be used as refraction texture.
  77026. */
  77027. set refractionEnabled(enabled: boolean);
  77028. /**
  77029. * Gets wether or not the post-processes is supported by the running hardware.
  77030. * This requires draw buffer supports.
  77031. */
  77032. get isSupported(): boolean;
  77033. /**
  77034. * This is the reflection mirror texture used to display reflections on the ocean.
  77035. * By default, render list is empty.
  77036. */
  77037. reflectionTexture: BABYLON.MirrorTexture;
  77038. /**
  77039. * This is the refraction render target texture used to display refraction on the ocean.
  77040. * By default, render list is empty.
  77041. */
  77042. refractionTexture: BABYLON.RenderTargetTexture;
  77043. private _time;
  77044. private _cameraRotation;
  77045. private _cameraViewMatrix;
  77046. private _reflectionEnabled;
  77047. private _refractionEnabled;
  77048. private _geometryRenderer;
  77049. /**
  77050. * Instantiates a new Ocean Post Process.
  77051. * @param name the name to give to the postprocess.
  77052. * @camera the camera to apply the post process to.
  77053. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77054. */
  77055. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77056. /**
  77057. * Returns the appropriate defines according to the current configuration.
  77058. */
  77059. private _getDefines;
  77060. /**
  77061. * Computes the current camera rotation as the shader requires a camera rotation.
  77062. */
  77063. private _computeCameraRotation;
  77064. }
  77065. }
  77066. declare module BABYLON {
  77067. /** @hidden */
  77068. export var brickProceduralTexturePixelShader: {
  77069. name: string;
  77070. shader: string;
  77071. };
  77072. }
  77073. declare module BABYLON {
  77074. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77075. private _numberOfBricksHeight;
  77076. private _numberOfBricksWidth;
  77077. private _jointColor;
  77078. private _brickColor;
  77079. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77080. updateShaderUniforms(): void;
  77081. get numberOfBricksHeight(): number;
  77082. set numberOfBricksHeight(value: number);
  77083. get numberOfBricksWidth(): number;
  77084. set numberOfBricksWidth(value: number);
  77085. get jointColor(): BABYLON.Color3;
  77086. set jointColor(value: BABYLON.Color3);
  77087. get brickColor(): BABYLON.Color3;
  77088. set brickColor(value: BABYLON.Color3);
  77089. /**
  77090. * Serializes this brick procedural texture
  77091. * @returns a serialized brick procedural texture object
  77092. */
  77093. serialize(): any;
  77094. /**
  77095. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77096. * @param parsedTexture defines parsed texture data
  77097. * @param scene defines the current scene
  77098. * @param rootUrl defines the root URL containing brick procedural texture information
  77099. * @returns a parsed Brick Procedural BABYLON.Texture
  77100. */
  77101. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77102. }
  77103. }
  77104. declare module BABYLON {
  77105. /** @hidden */
  77106. export var cloudProceduralTexturePixelShader: {
  77107. name: string;
  77108. shader: string;
  77109. };
  77110. }
  77111. declare module BABYLON {
  77112. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77113. private _skyColor;
  77114. private _cloudColor;
  77115. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77116. updateShaderUniforms(): void;
  77117. get skyColor(): BABYLON.Color4;
  77118. set skyColor(value: BABYLON.Color4);
  77119. get cloudColor(): BABYLON.Color4;
  77120. set cloudColor(value: BABYLON.Color4);
  77121. /**
  77122. * Serializes this cloud procedural texture
  77123. * @returns a serialized cloud procedural texture object
  77124. */
  77125. serialize(): any;
  77126. /**
  77127. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77128. * @param parsedTexture defines parsed texture data
  77129. * @param scene defines the current scene
  77130. * @param rootUrl defines the root URL containing cloud procedural texture information
  77131. * @returns a parsed Cloud Procedural BABYLON.Texture
  77132. */
  77133. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77134. }
  77135. }
  77136. declare module BABYLON {
  77137. /** @hidden */
  77138. export var fireProceduralTexturePixelShader: {
  77139. name: string;
  77140. shader: string;
  77141. };
  77142. }
  77143. declare module BABYLON {
  77144. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77145. private _time;
  77146. private _speed;
  77147. private _autoGenerateTime;
  77148. private _fireColors;
  77149. private _alphaThreshold;
  77150. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77151. updateShaderUniforms(): void;
  77152. render(useCameraPostProcess?: boolean): void;
  77153. static get PurpleFireColors(): BABYLON.Color3[];
  77154. static get GreenFireColors(): BABYLON.Color3[];
  77155. static get RedFireColors(): BABYLON.Color3[];
  77156. static get BlueFireColors(): BABYLON.Color3[];
  77157. get autoGenerateTime(): boolean;
  77158. set autoGenerateTime(value: boolean);
  77159. get fireColors(): BABYLON.Color3[];
  77160. set fireColors(value: BABYLON.Color3[]);
  77161. get time(): number;
  77162. set time(value: number);
  77163. get speed(): BABYLON.Vector2;
  77164. set speed(value: BABYLON.Vector2);
  77165. get alphaThreshold(): number;
  77166. set alphaThreshold(value: number);
  77167. /**
  77168. * Serializes this fire procedural texture
  77169. * @returns a serialized fire procedural texture object
  77170. */
  77171. serialize(): any;
  77172. /**
  77173. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77174. * @param parsedTexture defines parsed texture data
  77175. * @param scene defines the current scene
  77176. * @param rootUrl defines the root URL containing fire procedural texture information
  77177. * @returns a parsed Fire Procedural BABYLON.Texture
  77178. */
  77179. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77180. }
  77181. }
  77182. declare module BABYLON {
  77183. /** @hidden */
  77184. export var grassProceduralTexturePixelShader: {
  77185. name: string;
  77186. shader: string;
  77187. };
  77188. }
  77189. declare module BABYLON {
  77190. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77191. private _grassColors;
  77192. private _groundColor;
  77193. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77194. updateShaderUniforms(): void;
  77195. get grassColors(): BABYLON.Color3[];
  77196. set grassColors(value: BABYLON.Color3[]);
  77197. get groundColor(): BABYLON.Color3;
  77198. set groundColor(value: BABYLON.Color3);
  77199. /**
  77200. * Serializes this grass procedural texture
  77201. * @returns a serialized grass procedural texture object
  77202. */
  77203. serialize(): any;
  77204. /**
  77205. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77206. * @param parsedTexture defines parsed texture data
  77207. * @param scene defines the current scene
  77208. * @param rootUrl defines the root URL containing grass procedural texture information
  77209. * @returns a parsed Grass Procedural BABYLON.Texture
  77210. */
  77211. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77212. }
  77213. }
  77214. declare module BABYLON {
  77215. /** @hidden */
  77216. export var marbleProceduralTexturePixelShader: {
  77217. name: string;
  77218. shader: string;
  77219. };
  77220. }
  77221. declare module BABYLON {
  77222. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77223. private _numberOfTilesHeight;
  77224. private _numberOfTilesWidth;
  77225. private _amplitude;
  77226. private _jointColor;
  77227. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77228. updateShaderUniforms(): void;
  77229. get numberOfTilesHeight(): number;
  77230. set numberOfTilesHeight(value: number);
  77231. get amplitude(): number;
  77232. set amplitude(value: number);
  77233. get numberOfTilesWidth(): number;
  77234. set numberOfTilesWidth(value: number);
  77235. get jointColor(): BABYLON.Color3;
  77236. set jointColor(value: BABYLON.Color3);
  77237. /**
  77238. * Serializes this marble procedural texture
  77239. * @returns a serialized marble procedural texture object
  77240. */
  77241. serialize(): any;
  77242. /**
  77243. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  77244. * @param parsedTexture defines parsed texture data
  77245. * @param scene defines the current scene
  77246. * @param rootUrl defines the root URL containing marble procedural texture information
  77247. * @returns a parsed Marble Procedural BABYLON.Texture
  77248. */
  77249. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  77250. }
  77251. }
  77252. declare module BABYLON {
  77253. /** @hidden */
  77254. export var normalMapProceduralTexturePixelShader: {
  77255. name: string;
  77256. shader: string;
  77257. };
  77258. }
  77259. declare module BABYLON {
  77260. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  77261. private _baseTexture;
  77262. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77263. updateShaderUniforms(): void;
  77264. render(useCameraPostProcess?: boolean): void;
  77265. resize(size: any, generateMipMaps: any): void;
  77266. get baseTexture(): BABYLON.Texture;
  77267. set baseTexture(texture: BABYLON.Texture);
  77268. /**
  77269. * Serializes this normal map procedural texture
  77270. * @returns a serialized normal map procedural texture object
  77271. */
  77272. serialize(): any;
  77273. /**
  77274. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  77275. * @param parsedTexture defines parsed texture data
  77276. * @param scene defines the current scene
  77277. * @param rootUrl defines the root URL containing normal map procedural texture information
  77278. * @returns a parsed Normal Map Procedural BABYLON.Texture
  77279. */
  77280. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  77281. }
  77282. }
  77283. declare module BABYLON {
  77284. /** @hidden */
  77285. export var perlinNoiseProceduralTexturePixelShader: {
  77286. name: string;
  77287. shader: string;
  77288. };
  77289. }
  77290. declare module BABYLON {
  77291. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  77292. time: number;
  77293. timeScale: number;
  77294. translationSpeed: number;
  77295. private _currentTranslation;
  77296. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77297. updateShaderUniforms(): void;
  77298. render(useCameraPostProcess?: boolean): void;
  77299. resize(size: any, generateMipMaps: any): void;
  77300. /**
  77301. * Serializes this perlin noise procedural texture
  77302. * @returns a serialized perlin noise procedural texture object
  77303. */
  77304. serialize(): any;
  77305. /**
  77306. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  77307. * @param parsedTexture defines parsed texture data
  77308. * @param scene defines the current scene
  77309. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  77310. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  77311. */
  77312. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  77313. }
  77314. }
  77315. declare module BABYLON {
  77316. /** @hidden */
  77317. export var roadProceduralTexturePixelShader: {
  77318. name: string;
  77319. shader: string;
  77320. };
  77321. }
  77322. declare module BABYLON {
  77323. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  77324. private _roadColor;
  77325. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77326. updateShaderUniforms(): void;
  77327. get roadColor(): BABYLON.Color3;
  77328. set roadColor(value: BABYLON.Color3);
  77329. /**
  77330. * Serializes this road procedural texture
  77331. * @returns a serialized road procedural texture object
  77332. */
  77333. serialize(): any;
  77334. /**
  77335. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  77336. * @param parsedTexture defines parsed texture data
  77337. * @param scene defines the current scene
  77338. * @param rootUrl defines the root URL containing road procedural texture information
  77339. * @returns a parsed Road Procedural BABYLON.Texture
  77340. */
  77341. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /** @hidden */
  77346. export var starfieldProceduralTexturePixelShader: {
  77347. name: string;
  77348. shader: string;
  77349. };
  77350. }
  77351. declare module BABYLON {
  77352. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  77353. private _time;
  77354. private _alpha;
  77355. private _beta;
  77356. private _zoom;
  77357. private _formuparam;
  77358. private _stepsize;
  77359. private _tile;
  77360. private _brightness;
  77361. private _darkmatter;
  77362. private _distfading;
  77363. private _saturation;
  77364. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77365. updateShaderUniforms(): void;
  77366. get time(): number;
  77367. set time(value: number);
  77368. get alpha(): number;
  77369. set alpha(value: number);
  77370. get beta(): number;
  77371. set beta(value: number);
  77372. get formuparam(): number;
  77373. set formuparam(value: number);
  77374. get stepsize(): number;
  77375. set stepsize(value: number);
  77376. get zoom(): number;
  77377. set zoom(value: number);
  77378. get tile(): number;
  77379. set tile(value: number);
  77380. get brightness(): number;
  77381. set brightness(value: number);
  77382. get darkmatter(): number;
  77383. set darkmatter(value: number);
  77384. get distfading(): number;
  77385. set distfading(value: number);
  77386. get saturation(): number;
  77387. set saturation(value: number);
  77388. /**
  77389. * Serializes this starfield procedural texture
  77390. * @returns a serialized starfield procedural texture object
  77391. */
  77392. serialize(): any;
  77393. /**
  77394. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  77395. * @param parsedTexture defines parsed texture data
  77396. * @param scene defines the current scene
  77397. * @param rootUrl defines the root URL containing startfield procedural texture information
  77398. * @returns a parsed Starfield Procedural BABYLON.Texture
  77399. */
  77400. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  77401. }
  77402. }
  77403. declare module BABYLON {
  77404. /** @hidden */
  77405. export var woodProceduralTexturePixelShader: {
  77406. name: string;
  77407. shader: string;
  77408. };
  77409. }
  77410. declare module BABYLON {
  77411. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  77412. private _ampScale;
  77413. private _woodColor;
  77414. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77415. updateShaderUniforms(): void;
  77416. get ampScale(): number;
  77417. set ampScale(value: number);
  77418. get woodColor(): BABYLON.Color3;
  77419. set woodColor(value: BABYLON.Color3);
  77420. /**
  77421. * Serializes this wood procedural texture
  77422. * @returns a serialized wood procedural texture object
  77423. */
  77424. serialize(): any;
  77425. /**
  77426. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  77427. * @param parsedTexture defines parsed texture data
  77428. * @param scene defines the current scene
  77429. * @param rootUrl defines the root URL containing wood procedural texture information
  77430. * @returns a parsed Wood Procedural BABYLON.Texture
  77431. */
  77432. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  77433. }
  77434. }